Post

Replies

Boosts

Views

Activity

Reply to Why can't i see my widget logs on device?
Xcode 14.1 known issue: Xcode 14.1 release notes seems to mention a known issue After Running a widget extension, users will need to manually start the debugging session with Debug -> Attach to Process. (99285608) Approach (works on simulator and device) Run app target and widget target at the same time Attach debugger to your widget Steps Select app scheme and run on iOS device (don't stop) Select widget scheme and run on iOS (don't stop) So both the targets are running at the same time Select widget scheme then Debug > Attach to Process > Select your widget target name On device / simulator add widget Note: You need to attach the debugger every time you run (Xcode forgets debugger added for the previous run) Now your breakpoints should work as expected and you can debug
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’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:
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'
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
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.
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