Post

Replies

Boosts

Views

Activity

SwiftData ignore changes on App Intents
Hello everyone, Xcode 16.0 SwiftData project. CloudKit. WidgetConfigurationIntent. For some reason, I see a really weird behavior. I have a shared ModelContainer and an interactive widget where I update the model data through an app intent. This is my model - @MainActor class ItemsContainer { static let shared = ItemsContainer() var sharedModelContainer: ModelContainer! init() { self.sharedModelContainer = container() } func container() -> ModelContainer? { if let sharedModelContainer { return sharedModelContainer } let schema = Schema([ Session.self, ]) let modelConfiguration: ModelConfiguration modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false, cloudKitDatabase: .automatic) do { let container = try ModelContainer(for: schema, configurations: [modelConfiguration]) self.sharedModelContainer = container return container } catch { fatalError("Could not create ModelContainer: \(error)") } } } And this is how I get the model context across the app and the app intent - let modelContext = ModelContext(ItemsContainer.shared.sharedModelContainer) The problem is that somehow, when I update the model context in the app and then in the widget (I save the context after every change), the data is synced between the app and the widget, but then, the data is changed back to the previous state and kind of ignores the widget changes. Didn't happen before iOS 18/Xcode 16. Any idea? Thanks a lot!
2
0
457
Sep ’24
Apple Watch Crash - iOS 18
Hello everyone, I really need your help here :-)) iOS App. 17 and up. Widget extensions and watchOS app as well. New build for iOS 18 earlier this week. All platforms works perfect, except the Apple Watch version, which crash constantly on launch. Testing on simulator and testing devices - works perfect. Uploading to TestFlight and running on the same device - crash. The only thing I see in the crash report is StoredLocationBased.get error. It takes me to nowhere inside the project. Opened a DTS to Apple as well. Any help here will be fully appreciated. Thank you so much!
1
0
339
Sep ’24
AppIntent - Widget & ControlWidget
Hey all, iOS 18 - RC I have an app that supports both Widgets and ControlWidget, which resides on the same AppIntent. The following sync works fine when any action is taken on any of the three players - App - Widget - both directions - works as expected App - Control Widget - both directions - works as expected However - Widget - ControlWidget - the UI not always sync in real time (the values are ok) So if for instance I increase a counter on the widget from 1 to 2, the comtrolwidget will still show 1, but if I tap it, it will increase to 3. For any update/action taken on the AppInten, I call - WidgetCenter.shared.reloadAllTimelines() ControlCenter.shared.reloadAllControls() Any idea how to ensure this sync? Thanks a lot! Dudi
1
0
422
Sep ’24
RealityKit gesture doesn't work on child entity
Hello all, RealityKit. visionOS. I have a parent entity (surface in the code below) that I'm adding him a child entity with all the required components for gestures (collision & input target). I'm setting the TapGesture as expected (same for SpatialTapGesture). Result: gesture is not working. Neither the hover effect. The entity is not recognized as a tappable element. However, if I'm adding the child entity to the content and not to the parent entity - everything is working. Enclosed code below for both scenarios. Any idea? Many thanks, Dudi Doesn't work - RealityView { content, attachments in let scene = clonedEntity.clone(recursive: true) ... surface.addChild(scene) // <- Doesn't work } attachments: { ... } .gesture(SpatialTapGesture().targetedToAnyEntity().onEnded { value in openWindow(id: "detailed-window") }) .hoverEffect() Work - RealityView { content, attachments in let scene = clonedEntity.clone(recursive: true) ... content.add(scene) // <- Work } attachments: { ... } .gesture(SpatialTapGesture().targetedToAnyEntity().onEnded { value in openWindow(id: "detailed-window") }) .hoverEffect()
9
0
1.6k
Feb ’24
WidgetKit and VisionOS
Hello all, Is there any best practice how it's possible to add native visionOS support for existing app, that already includes WidgetKit extension, where both targets should share some files? "Your target is built for visionOS but contains embedded content built for the iOS platform (WidgetsExtension.appex), which is not allowed" Thanks a lot!
2
1
620
Feb ’24
SwiftData - different containers in one app
Hello to team, I have a very challenging issue that I'm not able to fix. I have an app that works with SwiftData Model Container that is generated when the app is launched. In the app I also added a Demo Mode area, where the user can load a mock data and simulating app behavior with more data. In order to switch to demo mode, I'm loading new UI layer and loading a new model container, which is configured to work with the same scheme, but isStoredInMemoryOnly = true. Everything works fine. Now, when the user toggles off the demo mode and go back to the main UI, any persistent changes to the modelContext leads to a crash where it says that the create store is different from the open store. Tried almost everything - I'm not sure even if it's possible to have this flow with SwiftData, butI'm trying. Please advice. Thanks a lot!
0
1
694
Nov ’23
Xcode 15 archive failed - file name too long
Hello all, Working on Xcode 15 GA. I'd like to archive my new iOS 17 project, which works properly on iOS and macOS (includes SwiftData library, new WidgetKit extension and StoreKit). However, when I'm trying to archive the project (either for iOS or macOS) I get an error as follows - "Error opening _.stringsdata for output: File name too long. I tried everything - still happens. When I'm looking inside the build folder, I see that this error probably related to new @__swiftmacro files. Have no idea how to proceed from here. Blocked from distributing my new app. Any idea? Thanks a lot! Dudi
4
2
2.4k
Sep ’23
Embedded SWCollaborationView in SwiftUI
Hello to the team, Our app (targeting iOS 16) is sharing data between users via CloudKit, and now we'd like to add the new SWCollaborationView feature. I created a CollaborationViewRep: UIViewRepresentable view as follows -     var activityItem: NSItemProvider     var eventName: String     @Binding var isCollaborationViewPresented: Bool     func makeUIView(context: Context) -> SWCollaborationView {         let collaborationView = SWCollaborationView(itemProvider: activityItem)         collaborationView.delegate = context.coordinator         return collaborationView     }     func updateUIView(_ uiView: SWCollaborationView, context: Context) {     }     class Coordinator: NSObject, SWCollaborationViewDelegate {         var parent: CollaborationViewRep         init(_ parent: CollaborationViewRep) {             self.parent = parent         }                  func collaborationViewShouldPresentPopover(_ collaborationView: SWCollaborationView) -> Bool {             return true         }         func collaborationViewWillPresentPopover(_ collaborationView: SWCollaborationView) {         }     }     func makeCoordinator() -> Coordinator {         Coordinator(self)     } } And when I'm trying to add this view as a toolbar item to my SwiftUI view, it doesn't work properly. If I'm adding this view as the toolbar item, without wrap it into a button, then nothing happens when I'm tapping the view (as it should work on UIKit). If I do wrap it with a button, and present the view as popover, then the view icon is presented and then, only when I tap this popover, the content view is presented (screenshot attached). It feels like this feature is not fully available for SwiftUI, unless I'm missing something. Unfortunately, the documentation is not covering the SwiftUI flow and there is no sample app for reference. Any idea how to best practice this situation? Thanks a lot!
0
2
1.3k
Oct ’22
StoreKit 2 isEligibleForIntroOffer
Hello all, Created and tested successfully auto renewal subscription products in my app. Both products offer 7 days free trial. Once purchased for the first time, isEligibleForIntroOffer value was true and when I tried to subscribe again later, the value is false - everything worked as expected. However, when I reset the eligibility for my sandbox user through the edit subscription screen, I do see that the Free Trial offering becomes available again, as expected, but when I test it in the app, the value for isEligibleForIntroOffer is still false. The value is false for the group (Product.SubscriptionInfo.isEligibleForIntroOffer(for: renewableSubscription.subscriptionGroupID)) and also for the product (renewableSubscription.isEligibleForIntroOffer). iOS 15.4. Is this a bug? Can I still trust this property value as the only source to check whether the user is eligible for intro in production? Thanks a lot.
3
2
2.9k
Jun ’22