Post

Replies

Boosts

Views

Activity

Reply to Access Core App Data from IOS widget
Problem: Since app extensions run as part of a host application rather than as part of their containing app (i.e. your app’s extensions run in somebody else’s app), data sharing isn’t automatic. Solution: The preferred way is to track changes (History Tracking) in the app's entities and update into widget's entities.  Refer: https://developer.apple.com/documentation/coredata/consuming_relevant_store_changes Approach: 1.0 - Create App Groups 2.1 - Create separete app entities and widget entities 2.2 - Create separate configurations for app entities and widget entities   2.3 - Assign them configuration to their entities 3.0 - Use app group while creating and loading the container 4.0 - Use history tracking to track changes from the app's entities and update into widget's entites.
Topic: App & System Services SubTopic: General Tags:
Oct ’22
Reply to What build setting causes `PreviewProvider`s to be stripped when archiving?
Your solution to use #if DEBUG <…> #endif however it is not very obvious before reading your post. I am wondering why SwiftPreview structs would ever be included in the archive? I wish Apple could come up with a property wrapper (example: @SwiftUIPreview or @Devlopment) that could be used for previews, that way there might be a way to avoid the inclusion of code marked with this property wrapper in the archive solving this problem.
Sep ’22
Reply to How to make Xcode Cloud compile code compiled in Xcode beta ?
Thanks for the reply but I am facing another issue before getting to try your suggestion. While trying to create a workflow I get the following error "<App name>" could not be added to Xcode Cloud The product with Bundle ID (<Bundle ID>) has already been created in this team. Some background details: I was using Xcode cloud before on a Xcode release version Later I upgraded macOS 13.0 Beta and the used Xcode Beta Xcode Cloud workflow was not appearing on Xcode I tried several times and later I think I ended up deleting the workflow on AppStoreConnect Then I tried adding the Xcode error when I face this error Any help would be much appreciated, many thanks!!
Sep ’22
Reply to Drag and Drop using SwiftUI
Environment macOS 13.0 Beta (22A5321d) Xcode 14.0 beta 5 (14A5294e) macOS Single item drag and drop with in app - Works Multiple items drag and drop in a list - Doesn't work - Bug Drag and Drop from one app to another - Works Drag and Drop from app to Finder - Doesn't work (only proxy representation works) - Bug iOS Simulator Single item drag and drop with in app - Works Multiple items drag and drop in a list - Works Drag and Drop from one app to another - Works Drag and Drop from app to Finder - Works
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to Can I add a CKDatabaseOperation to the queue belonging to a CKContainer object using CKContainer.add(_:)?
Concept Assume user A uses the app and CKFetchRecordsOperation.fetchCurrentUserRecordOperation gets executed, user A's record would be returned. User is a system defined record type User A will have access to the following: Public database Private database (if authenticated) Shared database (if authenticated) User B will have his / her own private and shared database. Only user can be logged on to one device at a given time, you can't have 2 iCloud accounts signed on the device (In Settings) So you can only get one record for the current user. Reference: https://developer.apple.com/icloud/cloudkit/designing/ Queue to use For CKFetchRecordsOperation is a subclass of CKDatabaseOperation so you need to use CKDatabase.add If you use CKContainer.add an exception will be thrown *** Terminating app due to uncaught exception 'CKException', reason: 'CKDatabaseOperations must be submitted to a CKDatabase'
Topic: App & System Services SubTopic: iCloud Tags:
Aug ’22
Reply to Prevent CloudKit sync / trigger sync manually
Short term approaches 1. User to turn off iCloud manually The user of the app can turn off iCloud for the App by doing the following on iOS: Settings > iCloud > YourAppName You will see a toggle switch to turn off iCloud usage for the app Every user will have to do that by himself / herself manually 2. CloudKit Dashboard (turn off visibility) Warning: Please test using a dummy container before you turn off your real container's visibility Go to CloudKit Dashboard Tap on the container name, a drop down would show up Tap on Manage Containers Warning: Please test using another container before turning off visibility on the real production container Long term approaches In the long term, you could try one of the following which ever suits you best 1. Separate Entity that doesn't sync automatically On your CoreData Model, create a separate configuration and add an entity to that configuration. Do all your saving into the new entity (which doesn't sync automatically), when you are ready move it to another entity which uses the default configuration which would sync. You need to make changes to your store descriptions and new store description for that new configuration. Refer: https://developer.apple.com/wwdc19/202 2. Don't save view context directly, instead use a child context (not 100% sure) If you save the viewContext, it would save to file and would trigger a sync, instead create a child context to the view context and save it in the child context That way your views will reflect the change but it is not saved to disk, but you need to save it before app quits or leaves a view so that user doesn't loose the data. 3. Change your logic and see how you group records and then save together
Topic: App & System Services SubTopic: iCloud Tags:
Aug ’22
Reply to Error: Failed to sync user keys in simulator
Problem 1: NSPersistentCloudKitContainer doesn't seem to work on simulator Solution: Use device, haven't found a way to make it work on the simulator. Problem2 When using CloudKit APIs (not NSPersistentCloudKitContainer) on the simulator I was getting CKError.notAuthenticated even though I had signed into iCloud on the simulator Root cause This happens when 2FA was enabled on the iCloud account but the 2FA code was asked on the simulator Solution Go to https://appleid.apple.com/, select devices on the sidebar Remove simulator (I found 2 simulators, removed both) Reset Xcode simulator Log into iCloud on the simulator Run the app Hopefully that should work.
Topic: App & System Services SubTopic: iCloud Tags:
Aug ’22
Reply to CloudKit Public Database
Go to Developer App (available for Mac, iOS) and search for CloudKit Shar (you will find a lot of content) https://developer.apple.com/videos/play/tech-talks/10874 https://developer.apple.com/wwdc21/10015 Sample projects https://github.com/apple?q=cloudkit-sample&type=repository%E2%80%9D
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to CloudKit Design
If you want something accessible only to the individual use Private database, Public database is common to all users. Example: Restaurant Menu data can be in the Public database, food items ordered should be stored in Private database. So only the individual can view his ordered items. Refer to https://developer.apple.com/icloud/cloudkit/designing/.
Aug ’22
Reply to CoreData+CloudKit custom Zone
Are you using manually syncing your CloudKit with CoreData or are you using NSPersistentCloudKitContainer? If you using NSPersistentCloudKitContainer does the syncing for you, don't have to set any custom zone, it would set a custom zone automatically. If you are doing it manually, then you would need to set a custom zone when you are saving a record and when you are retrieving it not while loading the container's persistent stores (which is what you are doing).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to Access Core App Data from IOS widget
Problem: Since app extensions run as part of a host application rather than as part of their containing app (i.e. your app’s extensions run in somebody else’s app), data sharing isn’t automatic. Solution: The preferred way is to track changes (History Tracking) in the app's entities and update into widget's entities.  Refer: https://developer.apple.com/documentation/coredata/consuming_relevant_store_changes Approach: 1.0 - Create App Groups 2.1 - Create separete app entities and widget entities 2.2 - Create separate configurations for app entities and widget entities   2.3 - Assign them configuration to their entities 3.0 - Use app group while creating and loading the container 4.0 - Use history tracking to track changes from the app's entities and update into widget's entites.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to How to disable cache in URLSession.shared.data in SwiftUI
Create a new URLSession as follows: URLSession(configuration: .ephemeral) And then use that session in your code
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to What build setting causes `PreviewProvider`s to be stripped when archiving?
Your solution to use #if DEBUG <…> #endif however it is not very obvious before reading your post. I am wondering why SwiftPreview structs would ever be included in the archive? I wish Apple could come up with a property wrapper (example: @SwiftUIPreview or @Devlopment) that could be used for previews, that way there might be a way to avoid the inclusion of code marked with this property wrapper in the archive solving this problem.
Replies
Boosts
Views
Activity
Sep ’22
Reply to How to make Xcode Cloud compile code compiled in Xcode beta ?
Thanks for the reply but I am facing another issue before getting to try your suggestion. While trying to create a workflow I get the following error "<App name>" could not be added to Xcode Cloud The product with Bundle ID (<Bundle ID>) has already been created in this team. Some background details: I was using Xcode cloud before on a Xcode release version Later I upgraded macOS 13.0 Beta and the used Xcode Beta Xcode Cloud workflow was not appearing on Xcode I tried several times and later I think I ended up deleting the workflow on AppStoreConnect Then I tried adding the Xcode error when I face this error Any help would be much appreciated, many thanks!!
Replies
Boosts
Views
Activity
Sep ’22
Reply to 'The app references non-public selectors in Payload'
Looks like a bug, better file a feedback using the feedback app.
Replies
Boosts
Views
Activity
Sep ’22
Reply to CloudKit - “Invalid bundle ID for container”
This happens sometimes when creating a new project, do the following: Go to developer.apple.com and sign in Select Certificates, Identifiers & Profiles Select Identifiers (App IDs) Edit App ID for the app Uncheck iCloud Save Check iCloud Quit Xcode and Clear DerivedData Run app
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Drag and Drop using SwiftUI
Environment macOS 13.0 Beta (22A5321d) Xcode 14.0 beta 5 (14A5294e) macOS Single item drag and drop with in app - Works Multiple items drag and drop in a list - Doesn't work - Bug Drag and Drop from one app to another - Works Drag and Drop from app to Finder - Doesn't work (only proxy representation works) - Bug iOS Simulator Single item drag and drop with in app - Works Multiple items drag and drop in a list - Works Drag and Drop from one app to another - Works Drag and Drop from app to Finder - Works
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Can I add a CKDatabaseOperation to the queue belonging to a CKContainer object using CKContainer.add(_:)?
Concept Assume user A uses the app and CKFetchRecordsOperation.fetchCurrentUserRecordOperation gets executed, user A's record would be returned. User is a system defined record type User A will have access to the following: Public database Private database (if authenticated) Shared database (if authenticated) User B will have his / her own private and shared database. Only user can be logged on to one device at a given time, you can't have 2 iCloud accounts signed on the device (In Settings) So you can only get one record for the current user. Reference: https://developer.apple.com/icloud/cloudkit/designing/ Queue to use For CKFetchRecordsOperation is a subclass of CKDatabaseOperation so you need to use CKDatabase.add If you use CKContainer.add an exception will be thrown *** Terminating app due to uncaught exception 'CKException', reason: 'CKDatabaseOperations must be submitted to a CKDatabase'
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Prevent CloudKit sync / trigger sync manually
Short term approaches 1. User to turn off iCloud manually The user of the app can turn off iCloud for the App by doing the following on iOS: Settings > iCloud > YourAppName You will see a toggle switch to turn off iCloud usage for the app Every user will have to do that by himself / herself manually 2. CloudKit Dashboard (turn off visibility) Warning: Please test using a dummy container before you turn off your real container's visibility Go to CloudKit Dashboard Tap on the container name, a drop down would show up Tap on Manage Containers Warning: Please test using another container before turning off visibility on the real production container Long term approaches In the long term, you could try one of the following which ever suits you best 1. Separate Entity that doesn't sync automatically On your CoreData Model, create a separate configuration and add an entity to that configuration. Do all your saving into the new entity (which doesn't sync automatically), when you are ready move it to another entity which uses the default configuration which would sync. You need to make changes to your store descriptions and new store description for that new configuration. Refer: https://developer.apple.com/wwdc19/202 2. Don't save view context directly, instead use a child context (not 100% sure) If you save the viewContext, it would save to file and would trigger a sync, instead create a child context to the view context and save it in the child context That way your views will reflect the change but it is not saved to disk, but you need to save it before app quits or leaves a view so that user doesn't loose the data. 3. Change your logic and see how you group records and then save together
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Error: Failed to sync user keys in simulator
Problem 1: NSPersistentCloudKitContainer doesn't seem to work on simulator Solution: Use device, haven't found a way to make it work on the simulator. Problem2 When using CloudKit APIs (not NSPersistentCloudKitContainer) on the simulator I was getting CKError.notAuthenticated even though I had signed into iCloud on the simulator Root cause This happens when 2FA was enabled on the iCloud account but the 2FA code was asked on the simulator Solution Go to https://appleid.apple.com/, select devices on the sidebar Remove simulator (I found 2 simulators, removed both) Reset Xcode simulator Log into iCloud on the simulator Run the app Hopefully that should work.
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to CloudKit Public Database
Go to Developer App (available for Mac, iOS) and search for CloudKit Shar (you will find a lot of content) https://developer.apple.com/videos/play/tech-talks/10874 https://developer.apple.com/wwdc21/10015 Sample projects https://github.com/apple?q=cloudkit-sample&type=repository%E2%80%9D
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to CloudKit Crashing after App Release
Go to CloudKit Console and click on "Deploy schema changes", once you deploy the changes, the schema's would be created in Production as in Development and your app should ideally work with no code changes, but test the app after deploying.
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to CloudKit Design
If you want something accessible only to the individual use Private database, Public database is common to all users. Example: Restaurant Menu data can be in the Public database, food items ordered should be stored in Private database. So only the individual can view his ordered items. Refer to https://developer.apple.com/icloud/cloudkit/designing/.
Replies
Boosts
Views
Activity
Aug ’22
Reply to CoreData+CloudKit custom Zone
Are you using manually syncing your CloudKit with CoreData or are you using NSPersistentCloudKitContainer? If you using NSPersistentCloudKitContainer does the syncing for you, don't have to set any custom zone, it would set a custom zone automatically. If you are doing it manually, then you would need to set a custom zone when you are saving a record and when you are retrieving it not while loading the container's persistent stores (which is what you are doing).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Cloudkit request permission not working
What is the error? Are you on simulator? Can you use a device with iCloud account signed in
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’22