To anyone having this issue, it seems iOS 17.1.1 and Xcode from the App Store wasn't compatible which is very strange. I didn't see any updates either. I ended up downloading Xcode 15.1 beta 3 and all is working now.
Post
Replies
Boosts
Views
Activity
Below is close to what I'm using in my CarPlay SceneDelegate. I'm still seeing the same results as before and I've minimized most of the code to reduce any chance of more issues arising. When the knob is focused on the tab selection I'm still getting a flicker upon calling func updateSections(_ sections: [CPListSection]). When an item is selected in the list and my app refreshes the list of items, then selected highlighted cell jumps from index 1 to random indexes in the list. My app handles a notification and refreshes the list template section and without updating sections the list never updates when adding or removing items.
class MyCarPlaySceneDelegate: NSObject, CPTemplateApplicationSceneDelegate, CPInterfaceControllerDelegate {
private var interfaceController: CPInterfaceController?
private var template: CPListTemplate?
private var items: [Item] = [] /// Maintain the list of items
var tabTemplates = [CPTemplate]()
func listTemplate() -> CPListTemplate {
loadItems() /// Load items here to avoid code duplication
var list: [CPListItem] = []
for item in items {
list.append(item)
}
let template = CPListTemplate(title: "Library", sections: [CPListSection(items: list)])
template.updateSections([CPListSection(items: list)]) /// Without this here the second value in the list is highlighted
self.template = template
return template
}
func loadItems() {
/// Loading data here
}
/// handle changes here to reload list
@objc func handleNotification(_ notification: Notification) {
var list: [CPListItem] = []
if let template = self.template {
loadItems() /// Reload items when a notification is received
template.updateSections([CPListSection(items: list)])
}
}
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController) {
NotificationCenter.default.addObserver(
self,
selector: #selector(handleNotification(_:)),
name: Notification.Name.HELLOWORLD,
object: nil
)
self.interfaceController = interfaceController
self.interfaceController?.delegate = self
let template = listTemplate()
tabTemplates.append(template)
interfaceController.setRootTemplate(CPTabBarTemplate(templates: tabTemplates), animated: true, completion: nil)
}
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didDisconnectInterfaceController interfaceController: CPInterfaceController) {
self.interfaceController = nil
NotificationCenter.default.removeObserver(self)
}
}
After more tinkering with, I’m left with the same issue when using with SwiftData. Adding/Removing items triggers a change in the highlighted item which is very strange behaviour and unable to resolve. Also the tab never really looks selected. The first indexed value should be highlighted but it switches randomly when updating template sections.
I resolved my issue by adding correct Entitlements! 🙄
I uninstalled Xcode and reinstalled, now it’s working again.
I’m having the exact same issue with Menu in SwiftUI dismissing itself. I’m using SwiftData and Core Data but I’m not using CloudKit though. I don’t remember this happening back on iOS 16 either.
I noticed if I switch between tabs and toggle the menu, it dismisses itself. I’m running a task in the view and ended up moving it to my view model and calling it in the initializer, now I’m not seeing the Menu being dismissed.
I'm not having an issue while using async in another project I'm working on using a different API. The application it's crashing on never experienced this before, but after the recent update to Xcode it's crashing. It's not a constant crash, it's not predictable.
Checking the documentation doesn't specify. I haven't heard back from any Apple engineering members but I assume the answer is yes, you need a paid developer account.
Deleting Package.resolved corrected the issue.