I have been working on implementing CarPlay into my audio app. It works as intended when I am using the Xcode Simulator but when testing in a real car, the app crashes immediately upon trying to open the app from the car display.
The app uses the com.apple.developer.playable-content entitlement and Media Player framework, which I think is still backwards compatible with iOS 14 despite there being a new CarPlay audio framework for iOS 14.
Other than the crashing when trying to open the app in CarPlay. The app when used without a car connected functions perfectly fine.
I have attached the crashlogs below.
What could be causing the app to crash in a real car but work fine in the simulator? Here is part of my AppDelegate where I call a function to setup carplay:
Code Block import UIKit import AVFoundation import AVKit import GoogleInteractiveMediaAds import MediaPlayer import GoogleMobileAds import UserNotifications import WebKit import SafariServices import Hero import Firebase @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { [...] // CarPlay var playableContentManager: MPPlayableContentManager? let carplayPlaylist = CarPlayPlaylist() func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { [...] setupCarPlay() return true }
and two files containing the CarPlay logic
AppDelegate+CarPlay.swift
CarPlayPlaylist.swift