ioscarplay

CarPlay app using CarPlay framework crashes on iOS 13 or older version


I am developing a CarPlay audio app that works with both iOS 14 and ios 13.

I use Media Player framework for iOS 13 and CarPlay framework for iOS 14 or later following the guide here. https://developer.apple.com/documentation/carplay/supporting_previous_versions_of_ios?language=objc

It runs well on iOS 14, but crashes on iOS 13/12 with the

dyld: Symbol not found: OBJC_CLASS$_CPNowPlayingAddToLibraryButton

I've found that using the following classes causes the app to crash.

CPNowPlayingAddToLibraryButton
CPNowPlayingRepeatButton
CPNowPlayingShuffleButton
CPNowPlayingImageButton

Just adding the one of the classes causes crash when running previous versions of iOS.

CPNowPlayingAddToLibraryButton* addToButton = [CPNowPlayingAddToLibraryButton.alloc initWithHandler:^(CPNowPlayingAddToLibraryButton*)
{
    ...
}];


Solution

  • You need to weakly link the CarPlay framework. In your target's Build Phases go the the Link Binary With Libraries section and check if CarPlay is already there (add it if not). Then make sure the Status is set to Optional enter image description here