Post

Replies

Boosts

Views

Activity

Core Data migration then run old app version
I'm sorta baffled right now. I am trying to wonder how I might detect a updated SQL Store in an older app. have a baseline app, and create a SQL-based repository in an updated app, change the model and verify that you can see the updated model version. Using lightweight migration re-run the older app (which will inherit the newer SQL repository). YIKES - no error when creating the NSPersistenStoreCoordinator! Nothing in the metadata to imply the store is newer than the model: [_persistentStoreCoordinator metadataForPersistentStore:store] My question: is there any way to detect this condition? David
0
0
396
Feb ’24
Did autorelease pools become no-ops? Look at this memory usage graph!
Have an app in the store - 10K users. Using the same algorithm for years to download objects, convert them to ManagedObjects, then save them in a context. Been using the exact same Objective-C code for over 5 years - no changes. We build the app with Xcode 15.1, release it a few weeks ago, then slowly start getting reports of the app won't boot. Run the app in 15.1, look at memory usage, and it's a flat line up. But the code is littered with autorelease statements. For this download, max memory was 2.3G! No wonder so many users crashing! [Worked two weekends straight to get this fixed, but why did it happen???] The last developer told me he added those to reduce memory pressure, and that they worked for him. (Unfortunately no old memory usage graphs). But look at the attached image - memory usage increments in a straight line - no saw tooth where memory would get released. Oh, and this is in one runloop on the main thread (don't blame me, I didn't write the original code!):
2
0
444
Feb ’24
What should happen if a Core Data app finds the Model is newer than its?
Have an app that has a half dozen models. We created a new app version with a new model that has an additional property on one entity. The options for the persistent store: do { let options = [ NSMigratePersistentStoresAutomaticallyOption: NSNumber(value: true), NSInferMappingModelAutomaticallyOption: NSNumber(value: true) ] let _ = try persistentStoreCoordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: storeURL, options: options) } catch { try? FileManager.default.removeItem(at: storeURL) //Erase old sqlite // Make new persistent store for future saves let _ = try? persistentStoreCoordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: storeURL, options: nil) } Launch this with data from a previous version. A breakpoint in the catch block never triggers so the migration must have worked. Since I'm in development, what happens if I run a different branch that doesn't have the new model? I assume the catch block is going to trigger—but it doesn't! Why doesn't it trigger? Does Core Data essentially ignore the new entity property, so all is well? I was just surprised ...
0
0
384
Jan ’24
Does UIGraphicsEndPDFContext flush and close the context file?
I'm getting infrequent crashes when I try to show a newly created PDF. The PDF is file based, and shortly after UIGraphicsEndPDFContext its shown. The crash reports make it appear that the file itself is being mutated after its displayed. So my question: is the file (self.filePath) absolutely flushed and closed when UIGraphicsEndPDFContext returns? If not, is there some way to detect when it has finished? Thanks! David `func addPageNumbers() { let url = URL(fileURLWithPath: filePath) guard let document = CGPDFDocument(url as CFURL) else { return } // You have to change the file path otherwise it can cause blank white pages to be drawn. self.filePath = "\(filePath)-final.pdf" UIGraphicsBeginPDFContextToFile(filePath, .zero, nil) let pageCount = document.numberOfPages for i in 1...pageCount { ... } } UIGraphicsEndPDFContext() }
1
0
586
Jan ’24
App is at 1% deployment, gets updated, what happens then?
Some confusion in my company on this scenario: current users are on 1.0.0 - have been for months Apple approves our latest build, say 1.1.0, and we release to the App Store with "Slow Rollout" a few days later, one of the first 1% reports a serious bug the dev team immediately fixes the bug, QA approves it, and we upload a new 1.1.1 release the same day we ask Apple for expedited approval, and that happens in 3 hours we select "Release 1.1.1 on Slow Rollout" on the App Store. So what then? My understanding is that once 1.1.1 is released, since 1.1.0 is the "Official Release", that anyone with auto update turned on will update quickly to 1.1.0, and that then some of those users will be put into the "1.1.1 slow roll out candidate pool)". Others have opined that I'm wrong - that most users will stay at 1.0.0, and the new 1.1.1 candidate pool will be users on both 1.0.0 and 1.1.0. Would love to hear someone reply who knows what Apple will really do.
4
0
502
Oct ’23
Storyboards not setting the proper custom font in Xcode 15.0 for iOS
Have an app with Storyboards that use a few customer fonts (Poppins and FontAwesome). No issues at all in Xcode 14. Updated to Xcode 15, and can build clean and run no issues reported. But many of the buttons and labels have the incorrect custom Font assigned - instead of FontAwesome, the get assigned Poppin. In a few cases FontAwesome is used, but the incorrect weight (I log the button font in awakeFromNib. I've looked at the Storyboard XML, it looks fine, and if I set the font to some system font all works fine. Setting it to a system font, then back to FontAwesome does not fix anything, and the XML looks identical to what it was before. I'm at a total loss as to what to do next. Any suggestions most appreciated. PS: in awakeFromNib, I can set the font to the correct FontAwsome font, and the control shows as it should. So the font works from code, not from the Storyboard.
2
0
1.4k
Oct ’23
iPad SearchBar suddenly moved from centered low to the right of rightBarButtons
App build with latest Xcode latest MacOS, deployment is iOS 14. It seems that in one App update, the search bar moved from centered low near the bottom of the NavigationBar to the right of the rightBarButtons. Previously we saw this: Now we get this with the exact same code: I dug around the UINavigationItem documentation, and there is a new property that lets you set the preferred placement: if (@available(iOS 16.0, *)) { navigationItem.preferredSearchBarPlacement = UINavigationItemSearchBarPlacementStacked; } That restore what our users use to see. But it will only work if the user is on iOS 16 - is there someway to get the old behavior on iOS 14+? We directly set the navItem's searchBar: navigationItem.searchController = searchController David PS: I have to believe something changed in the iOS frameworks that caused this - our code hasn't changed in this area for years.
1
0
989
Feb ’23
How can I break on this error in Xcode?
I'm getting this error in the console: *** -[__NSCFString substringWithRange:]: Range {18446744073709551615, 1} out of bounds; string length 43. This will become an exception for apps linked after 10.10 and iOS 8. Warning shown once per app execution. Great! So I created a category on NSString for _substringWithRange and _***_stringByReplacingCharactersInRange that call the original method (note undescore), then changed every usage in my app to use my own method, in which I test for location == NSNotFound. Nothing. So I swizzled both methods, and again tested for NSNotFound, and again nothing. What can I do to break when this error happens? Thanks David
1
0
1.2k
Jun ’22
Would ExternalAccesory support allow TCP traffic over the Lightning interface?
Some camera vendors support a FAT interface over a Lightning to camera/usb port. This would let an iOS app read files off the camera using a document browser (and it works just fine). The files are huge videos, and in some cases take over 50% of the record time to transfer over WiFi. One vendor unfortunately does not support this. They run PTP over their USB-C to Lightning cable, which means that Photos (or maybe Files, unsure now, I did verify it a while ago) on iOS can see and transfer the files. But my app is SOL - there is no apparent way to do this per Quinn. However - suppose the vendor would get certified with Apple as an ExternalAccessory - my app could then access the camera through some method they would support. This is going to be a tough sell, and just wondering what the minimal amount of technical work would be required on the vendors part to allow file retrieval.
0
0
686
Feb ’22
Working code that uses "rtsp" seems to have broken recently
We had working code a few years ago, for a seldom used feature (streaming the camera image from a VIRB 360 camera). Trying to get it working again, but when I use a URLSession Data task to try and connect to this URL: rtsp://192.168.0.1/livePreviewStream?maxResolutionVertical=0 I get an error: Code=-1002 "unsupported URL" I vaguely remember trying to add permissions in the Info.plist for the local network, but it turned out for "http" we didn't need .t (so it got removed). But now I can't find a reference to it. Does the above error code look like its related to permissions? If not what? Thanks for any pointers! David
2
0
1.3k
Nov ’21
Bonjour stopped responding in iOS15
My company's app uses the following code to look for services advertised by a Garmin VIRB 360 camera (now discontinued and unsupported). In the past this code has worked fine. However, on my iPhone 12 Pro Max running iOS 15.0.2 it returns no services. let serviceBrowser = NetServiceBrowser() serviceBrowser.searchForServices(ofType: "_garmin-virb._tcp.", inDomain: "local.") Did something change in iOS 15? Do I need some entitlement? Is the format of the strings incorrect? My recollection is that the strings are from Garmin document (but its years old). Any help greatly appreciated!
3
0
969
Oct ’21
Is this crash related to UIView.animate...?
I'm getting occasional crashes with the following on a background thread: 0 __exceptionPreprocess + 224 1 objc_exception_throw + 52 2 _AssertAutolayoutOnAllowedThreadsOnly + 416 3 -[NSISEngine withBehaviors:performModifications:] + 28 4 -[UIView(UIConstraintBasedLayout) _resetLayoutEngineHostConstraints] + 72 5 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1948 6 -[CALayer layoutSublayers] + 280 7 CA::Layer::layout_if_needed(CA::Transaction*) + 464 8 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 136 9 CA::Context::commit_transaction(CA::Transaction*, double) + 292 10 CA::Transaction::commit() + 672 11 CA::Transaction::release_thread(void*) + 224 12 _pthread_tsd_cleanup + 576 13 _pthread_exit + 76 14 _pthread_wqthread_exit + 92 15 _pthread_wqthread + 412 16 start_wqthread + 4 Of course no idea what actual class was doing what. I'm trying to focus on where this could be, and it would seem "CA::Transaction::commit()" points to some kind of animation block. But, if the view uses constraint based layout, could it be anything?
0
0
1k
Sep ’20