I'm developing a CarPlay Audio app that works with both 13.x and 14.x.
iOS 13.x uses Media Player framework and iOS 14.x uses CarPlay framework.
The code for iOS 14.x is designed to work on 14.0 and above as shown below.
However, when I run it on 13.7, it crashes when the app starts.
I've found that using one of the following methods causes the app to crash:
Only the CPNowPlayingButton is ok.
Why does code that should only work on iOS 14 and above affect iOS 13?
The following simple code crashes when running on iOS 13:
iOS 13.x uses Media Player framework and iOS 14.x uses CarPlay framework.
The code for iOS 14.x is designed to work on 14.0 and above as shown below.
Code Block swift @available(iOS 14.0, *) class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate { var interfaceController: CPInterfaceController?
However, when I run it on 13.7, it crashes when the app starts.
I've found that using one of the following methods causes the app to crash:
Code Block swift CPNowPlayingAddToLibraryButton CPNowPlayingMoreButton CPNowPlayingRepeatButton CPNowPlayingShuffleButton CPNowPlayingPlaybackRateButton CPNowPlayingImageButton
Only the CPNowPlayingButton is ok.
Why does code that should only work on iOS 14 and above affect iOS 13?
The following simple code crashes when running on iOS 13:
Code Block swift import UIKit import CarPlay @main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { if #available(iOS 14, *) { _ = CPNowPlayingShuffleButton { (button) in } } return true }