Posts

Post marked as unsolved
249 Views

Compile errors with package in Release mode w/CoreData resources

I get a ton of compile errors when I compile in Release mode (i.e. Archive) my swift package that contains my CoreData .xcdatamodel file. Works fine in debug mode, but when archiving, I get tons of “error reading dependency file…unexpected character in prerequisites at position…” errors. Same errors as this issue: https://developer.apple.com/forums/thread/657264 If I move the .xcdatamodel to the main project (out of the package), then it's all good again, but I'd like to keep the database model file inside the package if possible.
Asked
Last updated .
Post marked as unsolved
158 Views

@FetchResults doesn't refresh view when updating related fields

If I query an entity with a relationship to another entity, and then I update that related entity, the view does not refresh automatically. I'm 'forcing' it now, but that doesn't seem right. What's the right way? See code sample: struct ContentView: View { &#9;&#9;@Environment(\.managedObjectContext) private var viewContext &#9;&#9;@FetchRequest( &#9;&#9;&#9;&#9;sortDescriptors: [], &#9;&#9;&#9;&#9;animation: .none) &#9;&#9;private var categories: FetchedResults<Category> &#9;&#9;private func forceRefresh() { &#9;&#9;&#9;&#9;viewContext.refresh(categories[0], mergeChanges: true) &#9;&#9;} &#9;&#9;var body: some View { &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;VStack { &#9;&#9;&#9;&#9;&#9;&#9;List { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;ForEach(categories) { category in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Section { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("\(category.name!)").font(.title) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;ForEach(category.items?.allObjects as! [Item]) { item in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Button { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;item.name = "\(UUID())" &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} label: { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("\(item.name!)").font(.caption) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;Divider() &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;Button { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;forceRefresh() &#9;&#9;&#9;&#9;&#9;&#9;} label: { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("Force Refresh").foregroundColor(.blue) &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;} &#9;&#9;} }
Asked
Last updated .
Post marked as solved
630 Views

'iOS + Mac' or 'iOS/Catalyst' universal app?

What's the best practices recommendation for creating new projects? In Xcode it seems I could go either way, either an iOS/iPadOS app and select the 'Mac' checkbox (Catalyst) or use the new Universal app template which creates specific iOS and Mac targets. They both use SwiftUI, so it's not 100% clear what the 'correct' way to go.
Asked
Last updated .