Post

Replies

Boosts

Views

Activity

Selecting which data models sync with iCloud SwiftData
So I am trying to sync only some of my Models with iCloud and others kept locally in the default.store. I am having a world of issues so before I start looking for the needle in my haystack. I would like to ask this forum, is my approach one that should work as desired or is my code obviously why things are not working? All my Models have default values and relationships where needed are optionals. iCloud is working but my issue arises when i try to exclude some models. So I want to sync "modelsForCloudSyncing" but not "modelNotForCloudSyncing" In advance thank you var avoidCloudSyncModelContainer : ModelContainer = { let modelNotForCloudSyncing = Schema([NoCloudSyncModel.self]) let modelConfigForNoCloudSync = ModelConfiguration(schema: modelNotForCloudSyncing, cloudKitDatabase: .none) let modelsForCloudSyncing = Schema([CloudSyncModelA.self, CloudSyncModelB.self, CloudSyncModelC.self]) let modelConfigForCloudSync = ModelConfiguration(schema: modelsForCloudSyncing, cloudKitDatabase: .automatic) do { return try ModelContainer(for: NoCloudSyncModel.self, CloudSyncModelA.self, CloudSyncModelB.self, CloudSyncModelC.self, configurations: modelConfigForNoCloudSync, modelConfigForCloudSync) } catch { fatalError("Could not create ModelContainer: \(error)") } }() ... { ContentView() }.modelContainer(avoidCloudSyncModelContainer)
11
2
1.8k
Nov ’23
What happens at the end of a promo code duration
I have yearly auto renew subscription. in ASC I generate a promo code. giving user free subscription. At the end of the year are they [A ] renewed automatically for free so promo code continues? [B ] renewed automatically at the actual subscription price [ C] not renewed so effectively get to choose to start a subscription at the current price [D ] none of the above
2
0
483
Jun ’24
storekit configuration file Only for testing ?
I was using the storekit configuration file to test subscriptio renewals so set it to renew every 30 seconds. I have since shipped the App. Should I have set the storekit configuration file back to real time for the renewals, or the storekit configuration file is only for non release builds so anything I have changed in their won’t effect the released build ?
1
0
375
Jun ’24
Deep Link to Files app
Is there a system deep link URI to the built in files app? I would like to direct users to my apps location in the files app. For example files://myApp The only exposed deep links for system I can find are the ones for mail, sms, FaceTime etc. Thank you (tag used for post was because I couldn’t find a deep link tag)
3
0
686
May ’24
Xcode 16 crash trying to remove a package dependency
Feedback Submitted FB13898610 Xcode crashes with below. Pressing the "-" to remove a package dependancy. Solutions most welcome Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 6 Abort trap: 6 Terminating Process: Xcode [27376] Application Specific Information: abort() called Application Specific Signatures: NSInvalidArgumentException Application Specific Backtrace 0: 0 CoreFoundation 0x00007ff815134dc6 __exceptionPreprocess + 242 1 DVTFoundation 0x000000011257fd3e DVTFailureHintExceptionPreprocessor + 448 2 libobjc.A.dylib 0x00007ff814c24e9d objc_exception_throw + 48 3 CoreFoundation 0x00007ff81504f400 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 604 4 CoreFoundation 0x00007ff81504f18a +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49 5 DevToolsCore 0x000000012118ca09 -[PBXTarget removePackageProductDependencies:] + 1053 6 DevToolsCore 0x00000001211b1c65 -[PBXTarget packageReferenceWillBeRemoved:] + 273 7 CoreFoundation 0x00007ff8150b742a -[NSArray makeObjectsPerformSelector:withObject:] + 252 8 DevToolsCore 0x000000012116200c -[PBXProject(PBXTargetedNotifications) packageReferenceWillBeRemoved:] + 267 9 DevToolsCore 0x0000000121157026 -[PBXProject removePackageReference:] + 219 10 Xcode3UI 0x0000000128db10c8 __56-[Xcode3PackageReferenceListViewController removeItems:]_block_invoke + 319 11 Xcode3UI 0x0000000128db0c7b -[Xcode3PackageReferenceListViewController removeItems:] + 1925 12 AppKit 0x00007ff81891e34d -[NSApplication(NSResponder) sendAction:to:from:] + 337 13 IDEKit 0x00000001162a8e5f __37-[IDEApplication sendAction:to:from:]_block_invoke + 315 14 DVTFoundation 0x000000011257f51d DVTInvokeWithFailureHint + 78 15 IDEKit 0x0000000116202bc0 -[IDEApplicationController application:setFailureHintMessage:duringBlock:] + 118 16 IDEKit 0x00000001162a8f2b -[IDEApplication _invokeWithFailureHint:block:] + 105 17 IDEKit 0x00000001162a8cb8 -[IDEApplication sendAction:to:from:] + 333 18 AppKit 0x00007ff81891e1c3 -[NSControl sendAction:to:] + 86 19 AppKit 0x00007ff81891e0f5 __26-[NSCell _sendActionFrom:]_block_invoke + 131 20 AppKit 0x00007ff81891dffe -[NSCell _sendActionFrom:] + 171 21 AppKit 0x00007ff81891df46 -[NSButtonCell _sendActionFrom:] + 96 22 AppKit 0x00007ff81891ae32 NSControlTrackMouse + 1823 23 AppKit 0x00007ff81891a6ef -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 125 24 AppKit 0x00007ff81891a5b6 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 666 25 AppKit 0x00007ff8189199ab -[NSControl mouseDown:] + 666 26 AppKit 0x00007ff818918353 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4582 27 AppKit 0x00007ff818891177 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 313 28 AppKit 0x00007ff818890e23 -[NSWindow(NSEventRouting) sendEvent:] + 345 29 IDEKit 0x0000000116269d6a -[IDEWorkspaceWindow sendEvent:] + 158 30 AppKit 0x00007ff819043470 -[NSApplication(NSEventRouting) sendEvent:] + 1456 31 IDEKit 0x00000001162a8a7f -[IDEApplication sendEvent:] + 308 32 AppKit 0x00007ff818bfe8de -[NSApplication _handleEvent:] + 65 33 AppKit 0x00007ff81872209a -[NSApplication run] + 640 34 IDEKit 0x00000001162a888a -[IDEApplication run] + 54 35 AppKit 0x00007ff8186f5ff3 NSApplicationMain + 816 36 dyld 0x00007ff814c59366 start + 1942 Kernel Triage: VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x7ff814fac14a __pthread_kill + 10 1 libsystem_pthread.dylib 0x7ff814fe4ebd pthread_kill + 262 2 libsystem_c.dylib 0x7ff814f0aa79 abort + 126 3 IDEKit 0x116226509 +[IDEAssertionHandler _handleAssertionWithLogString:assertionSignature:assertionReason:extraBacktrace:] + 1178 4 IDEKit 0x1162278c3 -[IDEAssertionHandler handleUncaughtException:] + 749 5 IDEKit 0x116227c00 IDEHandleUncaughtException + 94 6 IDEKit 0x1162a9370 -[IDEApplication reportException:] + 79 7 AppKit 0x7ff818722129 -[NSApplication run] + 783 8 IDEKit 0x1162a888a -[IDEApplication run] + 54 9 AppKit 0x7ff8186f5ff3 NSApplicationMain + 816 10 dyld 0x7ff814c59366 start + 1942
1
2
529
Jun ’24
Unknown network connection Xcode instruments
Users have reported unusually high data usage with my app. So to investigate I have profiled in instruments. My app as expected in using minimal data. However in instruments I see an "Unknown" process. Which sends around 1mb of data every 2 seconds. Can anyone explain what unknown process is? Sorry my question is vague but I'm at the beginning of understanding the instruments outputs so your help is so very much appreciated.
2
0
618
May ’24
Widgets without timeline on WatchOS
TLDR; Can I have a widget without a Timeline? My previous watch app had a complication. Simply so it can be added to the watch face for a quick launch of the app. However now seeing that method is deprecated in favour of widgets. Can I add a widget without the need for all the Timeline as all I want is a button on the watch face to launch into my app. No data is updated over time so no need for all the extra timeline code.
1
0
853
Mar ’24
Create an Image from PDFPage in SwiftUI
Im trying to duplicate the display of the built in Files app for documents in my app. How do I convert a page in a PDFDocument to an Image to display as an icon like seen here (from Files App) with SwiftUI. SOLVED: Image(uiImage: (document.page(at: 0)?.thumbnail(of: CGSize(width: 100, height: 100), for: .cropBox))!)
0
0
595
Mar ’24
speed up creating multiple instances of @Model Class
@Model class modelData { var property1 : String = "" init(property1: string){ ... } } for item in arrayOfManyStrings { let instanceOfModelData = modelData(property1: item) } Trying to create multiple instances of my modelData. I expect the loop to run and create instanceOfModelData 30k times. However it is far too slow. 30-90 seconds depending on device. If I remove the @Model macro, the same loop take < 5 seconds. I obviously need the @Model for swiftData. How to speed up creating instances of instanceOfModelData when using @Model
0
0
524
Mar ’24
Show keyboard on button action
How to show the keyboard for textfield on ToolbarItem(placement: .keyboard)? I have a button and it's action I want is to show the keyboard. On top of which is ToolbarItem(placement: .keyboard) { HStack{ Button(...) TextField("", text: $bindingText) .textFieldStyle(RoundedBorderTextFieldStyle()) .keyboardType(.numberPad) .multilineTextAlignment(.trailing) } } I know keyboard shows with a textfield focused. How though to show the keyboard for ToolbarItem(placement: .keyboard) Textfield if can't show it without showing the keyboard?
2
0
619
Mar ’24
Is swiftData just not useable with large data?
Is SwiftData not designed for large datasets? How to create many instances of my Data Model? I have a loop where I iterate over a CSV file of 30k+ lines. Totalling around 230k elements. I intend to save this data into SwiftData. However it takes around 90 seconds. In previous versions of my app I was using coreData. Then it took just 3 seconds. So after much investigation I have concluded the delay comes from creating instances of the Data Model. To Test this I have : Removed any saves into SwiftData. So only creation of the Model Object occurs. Created an exact copy of the SwiftData Model class but admitted the @Model macro set isAutosaveEnabled to false When I run my loop with the copy class it takes 3 seconds. So It must be creating the SwiftData model instances that causes the *30 delay. The code using swiftData @Model. This loop takes 90+ seconds to complete class TimetableData { var arrivalTime : Int = 0 var departureTime: Int = 0 var departureRoute : Int = 0 var directionOfTravel : Int = 0 var dutyNumber : Int = 0 var facilityIdentifier : String = "" var locationType : String = "" var mode : String = "" var nonStopStatus : Int = 0 var recordIdentifier : String = "" var timetableIdentifier : Int = 0 var trainNumber : String = "" var tripNumber : Int = 0 var tripStartSite : String = "" var uniqueLocationCode : String = "" init(arrivalTime: Int = 0, departureTime: Int = 0, departureRoute: Int = 0, directionOfTravel: Int = 0, dutyNumber: Int = 0, facilityIdentifier: String = "", locationType: String = "", mode: String = "", nonStopStatus: Int = 0, recordIdentifier: String = "", timetableIdentifier: Int = 0, trainNumber: String = "", tripNumber: Int = 0, tripStartSite: String = "", uniqueLocationCode: String = "") { self.name = name self.arrivalTime = arrivalTime self.departureTime = departureTime self.departureRoute = departureRoute self.directionOfTravel = directionOfTravel self.dutyNumber = dutyNumber self.facilityIdentifier = facilityIdentifier self.locationType = locationType self.mode = mode self.nonStopStatus = nonStopStatus self.recordIdentifier = recordIdentifier self.timetableIdentifier = timetableIdentifier self.trainNumber = trainNumber self.tripNumber = tripNumber self.tripStartSite = tripStartSite self.uniqueLocationCode = uniqueLocationCode } } for line in CSVFile { var columnValue = line.components(separatedBy: ",") let timeTableDataEntry = TimetableData ( arrivalTime: Int(columnValue[0])!, departureTime: Int(columnValue[1])!, departureRoute: Int(columnValue[2])!, directionOfTravel: Int(columnValue[3])!, dutyNumber: Int(columnValue[4])!, facilityIdentifier: columnValue[5], locationType: columnValue[6], mode: columnValue[7], nonStopStatus: Int(columnValue[8])!, recordIdentifier: columnValue[9], timetableIdentifier: Int(columnValue[10])!, trainNumber: columnValue[11], tripNumber: Int(columnValue[12])!, tripStartSite: columnValue[13], uniqueLocationCode:columnValue[14] ) } Then The exact same code but omitting the @Model takes around just 3 second. class TimetableDataForTesting { var arrivalTime : Int = 0 var departureTime: Int = 0 var departureRoute : Int = 0 var directionOfTravel : Int = 0 var dutyNumber : Int = 0 var facilityIdentifier : String = "" var locationType : String = "" var mode : String = "" var nonStopStatus : Int = 0 var recordIdentifier : String = "" var timetableIdentifier : Int = 0 var trainNumber : String = "" var tripNumber : Int = 0 var tripStartSite : String = "" var uniqueLocationCode : String = "" init(arrivalTime: Int = 0, departureTime: Int = 0, departureRoute: Int = 0, directionOfTravel: Int = 0, dutyNumber: Int = 0, facilityIdentifier: String = "", locationType: String = "", mode: String = "", nonStopStatus: Int = 0, recordIdentifier: String = "", timetableIdentifier: Int = 0, trainNumber: String = "", tripNumber: Int = 0, tripStartSite: String = "", uniqueLocationCode: String = "") { self.name = name self.arrivalTime = arrivalTime self.departureTime = departureTime self.departureRoute = departureRoute self.directionOfTravel = directionOfTravel self.dutyNumber = dutyNumber self.facilityIdentifier = facilityIdentifier self.locationType = locationType self.mode = mode self.nonStopStatus = nonStopStatus self.recordIdentifier = recordIdentifier self.timetableIdentifier = timetableIdentifier self.trainNumber = trainNumber self.tripNumber = tripNumber self.tripStartSite = tripStartSite self.uniqueLocationCode = uniqueLocationCode } } for line in CSVFile { var columnValue = line.components(separatedBy: ",") let timeTableDataEntry = TimetableDataForTesting ( arrivalTime: Int(columnValue[0])!, departureTime: Int(columnValue[1])!, departureRoute: Int(columnValue[2])!, directionOfTravel: Int(columnValue[3])!, dutyNumber: Int(columnValue[4])!, facilityIdentifier: columnValue[5], locationType: columnValue[6], mode: columnValue[7], nonStopStatus: Int(columnValue[8])!, recordIdentifier: columnValue[9], timetableIdentifier: Int(columnValue[10])!, trainNumber: columnValue[11], tripNumber: Int(columnValue[12])!, tripStartSite: columnValue[13], uniqueLocationCode:columnValue[14] ) }
2
1
1.2k
Nov ’23