Post

Replies

Boosts

Views

Activity

@Binding bools within a VStack getting conflated
I am running into an issue where two distinct bool bindings are both being toggled when I toggle only one of them. My component looks like VStack { Checkbox(label: "Checkbox 1", isOn: $stateVar1) Checkbox(label: "Checkbox 2", isOn: $stateVar2) } where my CheckBox component looks like struct Checkbox: View { let label: String @Binding var isOn: Bool var body: some View { Button { isOn.toggle() } label: { HStack { Image(systemName: isOn ? "checkmark.square" : "square") Text(label) } .foregroundStyle(.black) } } } If I click on one checkbox, both of them get toggled. However, if I simply remove the checkboxes from the VStack, then I am able to toggle them both independently. I believe this is a bug with bool Bindings, but if anyone can point out why I am mistaken that would be much appreciated :)
1
0
140
3d
Crashes when trying to destroy persistent store
I am running into some issues when trying to destroy CoreData persistentStores. When a user logs out of my app, I want to completely reset CoreData and delete any existing data. My code to reset CoreData looks like this: let coordinator = self.persistentContainer.persistentStoreCoordinator self.persistentContainer.viewContext.reset() coordinator.persistentStores.forEach { store in guard let url = store.url else { return } do { try coordinator.destroyPersistentStore(at: url, type: .sqlite) _ = try coordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: url) } catch { print(error) } } However, my app is crashing with Object 0xb2b5cc80445813de <x-coredata://BDB999D4-49A4-4CB3-AC3A-666AD60BEFC6/AccountEntity/p5> persistent store is not reachable from this NSManagedObjectContext's coordinator It seems this is related to the SwiftUI @FetchRequest wrappers. If I do not open the views where I am using @FetchRequest, the logout goes smoothly. Otherwise, I get the crash above. Has anyone run into anything similar? Is there something else I need to do to get the underlying FRC to release its references to those entities? I was under the impression that calling reset() on the managed object context would be enough to remove those items from memory and get the destroying of the persistent store to go smoothly. Alternately, is there another/better way I should be destroying the DB? Any advice or related observations would be greatly appreciated. Thank you!
2
0
303
1w
Unable to find a destination matching the provided destination specifier
I am attempting to test my app from the command line using fastlane but am running into issues with the build due to xcodebuild not being able to find the specified simulator. I have been attempting to debug by running the xcodebuild command manually and here is what I have been able to gather: Running xcodebuild -scheme MyAppName -destination "platform=iOS Simulator,OS=18.1,name=iPhone 16 Pro" errors with a message saying xcodebuild: error: Unable to find a destination matching the provided destination specifier: { platform:iOS Simulator, OS:18.1, name:iPhone 16 Pro } If I run xcodebuild -scheme MyAppName -showdestinations, I can see { platform:iOS Simulator, id:7F3E4A35-E5DB-4EF4-AFAD-156EC463FEA8, OS:18.1, name:iPhone 16 Pro } listed in the options. Specifying the destination using the id yields the same result. However, if I run xcodebuild -scheme MyAppName -destination "platform=iOS Simulator,OS=18.1,name=iPhone 16 Pro" test (note the extra test at the end) the tests run successfully. I have checked that my minimum deployment number is correct (iOS 16), ensured that my supported platforms is set to iOS, and followed every other suggestion I could find on this matter. What am I missing here?
1
0
421
Dec ’24