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.
crashlog1 - https://developer.apple.com/forums/content/attachment/619c899b-3032-42f7-9061-7e2dcd6b3d86
crashlog2 - https://developer.apple.com/forums/content/attachment/ba1af908-5519-4036-a7b6-9c11056f692b
crashlog3 - https://developer.apple.com/forums/content/attachment/ceaa0bbb-74a5-4cef-a7ae-236a5a22f32e
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:
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
AppDelegate+CarPlayPlaylist.swift - https://developer.apple.com/forums/content/attachment/27aec079-528f-4b4f-a325-a1a0f3f59027
CarPlayPlaylist.swift
CarPlayPlaylist.swift - https://developer.apple.com/forums/content/attachment/8c461a2f-73ad-4e04-bf8b-6807936e79f5
Selecting any option will automatically load the page