Posts

Post not yet marked as solved
1 Replies
I had a similar issue when adding entities on a background thread. Got it working by working in a different context. So rather than passing in the entity I passed in the model container and entity persistent id and recreated in in a new context. Share more about it here: https://www.simplykyra.com/swiftdata-solving-fatal-errors-and-exc_bad_access-while-handling-entities-on-different-threads/
Post not yet marked as solved
1 Replies
Is this on the website or for the app? I have a personal account with no issues on the website. That said my iPhone app was giving me that problem. I ended up deleting and reinstalling the app and it worked fine after that… so far.
Post marked as solved
2 Replies
In case anyone is looking into this in the future. I asked on StackOverflow (https://stackoverflow.com/questions/74159031/swiftui-publishing-changes-from-async-model) and was told to put it on the main thread with ‘@MainActor’ or use DispatchQueue.main.async. I enclosed each of my assignments with the DispatchQueue.main.async and it now works without the warnings. For example my async method now looks like: class myAsyncViewModel:  ObservableObject  {     @Published var imageName: String = "questionmark"     @Published var title: String = "title"     @Published var subTitle: String = "subtitle"     func thisMethodTakesTime() async -> String? {         print("In method: \(imageName), \(title), \(subTitle)")         DispatchQueue.main.async {             self.title = "MY METHOD"             self.subTitle = "Starting out!"         }         try? await Task.sleep(nanoseconds: 1_000_000_000)         DispatchQueue.main.async {             self.subTitle = "Between"         }         try? await Task.sleep(nanoseconds: 1_000_000_000)         DispatchQueue.main.async {             self.subTitle = "About to return. Success!"         }         print("In method: \(imageName), \(title), \(subTitle)")         return "RETURN RESULT"     } }
Post marked as solved
1 Replies
In case anyone has the same issue I wanted to share how I fixed it. The original question complained about the following error: Error Domain=com.apple.healthkit Code=4 "Missing com.apple.developer.healthkit entitlement." UserInfo={NSLocalizedDescription=Missing com.apple.developer.healthkit entitlement.} I ultimately fixed it by going to App > Target > Info tab and added the three Privacy - Health... Usage Description Strings. Later I realized I only needed one for my purposes. Also, before or during this process, I went to App > Target > Signing & Capabilities tab and pressed the plus in the top left corner to add HealthKit iOS. Here are the photos showing this: The signing and capabilities needed HealthKit added (not sure if this is REQUIRED but figured I'd share. This fixed the above error but brought me to the next one. Error Domain=com.apple.healthkit Code=4 "Missing application-identifier entitlement" UserInfo={NSLocalizedDescription=Missing application-identifier entitlement} I couldn't figure it out and then finally asked on StackOverflow and got the answer.. The main portion was adding the Privacy - Health Update Usage Description string to the Info tab. Originally I added all three Privacy - Health --- Usage Description but after it worked I went back and removed the ones that weren't needed. . To fix it you need to go to your entitlements file (icon has a yellow checkmark with a squiggly circle around it) and manually add application-identifier, change the type to a String, and set the value to your Bundle Identifier (found under App > Target > Signing and Capabilities > Signing). Later I noticed the Bundle Display Name under the info tab so not sure if those two are connected. Good luck :)
Post not yet marked as solved
2 Replies
I've been converting my image to Data and then storing it that way. Not sure if that's the proper way or not. Plus, since the upgrade, my normal macOS way to convert isn't working. Used to use tiffRepresentation?.bitmap?.png but now there's no bitmap on the tiffRepresentation.
Post marked as solved
2 Replies
Fixed it by destroying more my store through the code. Basically right after creating my container in the persistence file I added: `do{ try container.persistentStoreCoordinator.destroyPersistentStore(at: container.persistentStoreDescriptions.first!.url!, type: .sqlite, options: nil) }catch{ print(error) } Works great now. Solved it by asking this question in stackOverflow. Full question and answer here: https://stackoverflow.com/questions/73094220/how-to-fully-remove-macos-xcode-application
Post not yet marked as solved
3 Replies
I had the same issue. The App Store Xcode doesn't work as Ventura has bypassed it. Since we're using the Beta the warning hasn't upgraded, I'm assuming. After reinstalling several times I realized I needed to download the Xcode Beta (not in the App Store) and it now works.
Post marked as solved
1 Replies
If anyone is curious the first part of a post (https://www.andrewcbancroft.com/blog/ios-development/data-persistence/getting-started-with-nspersistentcloudkitcontainer/) got me started and then the Apple Documentation - specifically Setting Up Core Data with CloudKit to me the rest of the way. I mostly jumped around the documentation from there (got data loading when I started the app) and then Hacking with Swift got me the rest of the way.
Post marked as solved
1 Replies
Replied In Dark Mode
You can set it with .preferredColorScheme(.dark).
Post not yet marked as solved
6 Replies
I haven’t submitted an app yet and so can’t tell you. That said, I asked about app submission in a lab session at WWDC this year and was told if I was rejected I could ask for call clarification so I’d know the why. I wonder if they could also answer your question then too. I haven’t watched it yet but was also referred to this video (not sure what it goes over): https://developer.apple.com/videos/play/tech-talks/10885
Post not yet marked as solved
2 Replies
Not sure what the persistence file would look like but like @MatKuznik said you'd need a relationship. Remove the binary data recipe from PlannedRecipe. Then add a relationship (called recipe) to PlannedRecipe. In Recipe itself add a relationship to PlannedRecipe (I'll call it plans for now). Both will have to point to each other so switch the third tab to the other one so they point each way. On the far right pane you'll want to direct if it's a one-to-many (one-to-one or many-to-many) relationship by setting either side. I'd image a recipe can be in multiple planned recipes but a planned recipe can only have one plan? Unless your plan consists of multiple (WWDC example with pie crust, filling, and whip cream idea comes to mind) in which case you'd want a "to-many" on either side.
Post not yet marked as solved
1 Replies
Just to confirm you have an NSSet of objects and you can't turn it into an array, right? Getting an error/warning for Cast from 'NSSet?' to unrelated type '[EntityName]' always fails... There's a parameter allObjects on, at least, the Core Data relationship NSSet that you can use to convert it to an array. In my case I use it when taken a set of Entities from a relationship. So: FirstEntityName?.relationshipNameWithNSSet?.allObjects as? [SecondEntityName] If they NEED a result I sometimes use ?? [SecondEntityName]() to create an empty default array.
Post marked as solved
1 Replies
Sure. The project itself is called Food Truck. Documentation with link to download: https://developer.apple.com/documentation/swiftui/food_truck_building_a_swiftui_multiplatform_app GitHub page: https://github.com/apple/sample-food-truck And link to all the sample code used in the WWDC 2022 videos here: https://developer.apple.com/sample-code/wwdc/2022/