iOS13 SKStoreProductViewController cannot be subclassed

Starting in iOS13 in beta 5 or 6, we started to see this exception when using our store view controller: "SKStoreProductViewController May not be subclassed.", and the store fails to load. This is a problem because without being able to subclass SKStoreProductViewController, then we run into a crash on apps that are configured for landscape only.


Steps:

- Configure app to support device orientations of landscape left and landscape right

- Try to display SKStoreProductViewController on devices such as iPhone XS Max, iPhone XR, iPhone 8, etc

- You will receive a crash because the store view prefers to be displayed in portrait, but portrait is not a supported orientation of the app:

"Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'"


The only way around this crash previously was to subclass SKStoreProductViewController to set shouldAutorotate to NO. Is it expected that we are no longer able to subclass SKStoreProductViewController? This restriction didn't exist in earlier betas and only happened more recently. If this is an expected change, then what is the workaround for the orientation crash?

Replies

Any updates on this?

Giving kudos to this SO post for giving me the idea. I happened upon this crash in my app and I used the approach outlined there to keep my app fixed in landscape while allowing the SKStoreProductViewController to be presented in portrait. It's not the perfect experience when on an iPhone, the SKProductViewController will present in portrait although the screen launching it will be in landscape. For me this experience is better than a crash.
In you AppDelegate file:
Code Block
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window {
if (UIDevice.isPad) {
/* I have `isPad` in a Swift extension as a computed class var on UIDevice ->
`current.userInterfaceIdiom == .pad`*/
return UIInterfaceOrientationMaskAll;
} else {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
}

Then in your base view controller use:
Code Block
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

It's working perfectly for me and no more crash! Hope it helps someone even though the original question is from a year ago.