Post

Replies

Boosts

Views

Activity

UINavigationController's interactivePopGestureRecognizer sometimes causes the popped view controller to never be released (memory leak)
I notice if I pop a view controller off a UINavigationController's navigation stack using the interactivePopGestureRecognizer, every so often the view controller being popped off is not being released from memory. Haven't been able to come up with a workaround or determine anything that seems to make the issue reproduce reliably. I simply log out dealloc in the view controller that is going to be popped. Push and pop a few times and notice that dealloc doesn't log out after it is being popped off. Not sure if something in the UI (other animation) that is interrupting the pop gesture's _UINavigationInteractiveTransition ... I haven't been able to track down what is retaining my view controller. When the issue happens I can see it is still in memory (I have it listen to UISceneWillEnterForegroundNotification and I put the scene in the background then move it to the foreground and hit a breakpoint). But...I can't seem to figure out what is strongly retaining the view controller. From he debugger I start setting view controller properties to nil to see if I can break a potential retain cycle I created) but no luck. I'm only able to reproduce the memory leak when I dismiss the view controller with the interactive pop gesture (not the back button). I know that's not a lot to go on but am wondering if someone has experience anything similar and has a potential workaround?
Topic: UI Frameworks SubTopic: UIKit Tags:
4
0
1k
Jun ’22
Run CloudKit App Using the Production Environment From Xcode?
I'm getting ready to release a new app that uses CloudKit. I just deployed my Development schema to Production in CloudKit dashboard. Is there a way to run my app from Xcode using the CloudKit Production environment for testing? Details of how to test in the production environment are described here: https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitQuickStart/TestingYourApp/TestingYourApp.html But would be faster (and easier for debugging potential issues) if I could select tell Xcode to use the production environment when running from the debugger. Is this supported? Thanks
5
0
2.2k
Jun ’22
Testing Sign Out Events with CloudKit?
I'd like to test how my app behaves when the user signs out of iCloud and my app is in memory. In the iOS Simulator, the "Sign Out" button for iCloud is grayed out so I can't use the simulator to test. I'm hesitant to use a real device tied to my Apple ID because signing out of iCloud System wide has side effects with many apps and I don't want to potentially lose any data. However, I did test on a real device by going the Settings app -> iCloud and disabled iCloud only for my app. When I do this, the system terminates my app and does not post a CKAccountChangedNotification. I only tested turning off the iCloud switch for my app. Does the system simply terminate apps when the user logs out of iCloud system wide too? In what cases is the CKAccountChangedNotification posted? Detecting sign out by listening for CKAccountChangedNotification would seem to be pointless if apps are terminated when the user signs out of iCloud.
0
0
373
Jun ’22
My Mac App Crashing on ARM-64 Devices After Calling NSURL -getResourceValue:forKey: with
I'm getting some Crash Reports for an app of mine that's on the Mac App Store. A few details: -All the crash reports are on ARM-64 Macs. -The call stack shows my app calling NSURL's -getResourceValue:forKey: method with NSURLLocalizedNameKey, which is the last call made by my app before the crash. After that crash logs look like this: **Thread 0 Crashed: 0   libobjc.A.dylib               0x00000001a623c4b0 objc_retain + 16 1   LaunchServices                0x00000001a6954f68 -[FSNode(PathAndName) nameWithError:] + 72 2   LaunchServices                0x00000001a6a36278 +[_LSDisplayNameConstructor(ConstructForAnyFile) displayNameConstructorWithContextIfNeeded:bundle:bundleClass:node:preferredLocalizations:error:] + 2732 3   LaunchServices                0x00000001a6a357ac +[_LSDisplayNameConstructor(ConstructForAnyFile) displayNameConstructorWithContextIfNeeded:node:error:] + 44 4   LaunchServices                0x00000001a6ae5b20 LaunchServices::URLPropertyProvider::getDisplayNameConstructor(LaunchServices::Database::Context&, FSNode*, LaunchServices::URLPropertyProvider::State*, NSError* __autoreleasing*) + 88 5   LaunchServices                0x00000001a6ae1930 LaunchServices::URLPropertyProvider::prepareLocalizedNameValue(LaunchServices::Database::Context&, FSNode*, __FileCache*, __CFString const*, LaunchServices::URLPropertyProvider::State*, NSError* __autoreleasing*) + 328 6   LaunchServices                0x00000001a6953d6c LaunchServices::URLPropertyProvider::prepareValues(__CFURL const*, __FileCache*, __CFString const* const*, void const**, long, void const*, __CFError**) + 456 7   CoreServicesInternal          0x00000001a8def6f0 prepareValuesForBitmap(__CFURL const*, __FileCache*, _FilePropertyBitmap*, __CFError**) + 452 8   CoreServicesInternal          0x00000001a8dec5ec _FSURLCopyResourcePropertyForKeyInternal(__CFURL const*, __CFString const*, void*, void*, __CFError**, unsigned char) + 236 9   CoreFoundation                0x00000001a64546b0 CFURLCopyResourcePropertyForKey + 144 10  CoreFoundation                0x00000001a646b944 -[NSURL getResourceValue:forKey:error:] + 120** -- I haven't been able to reproduce the issue on my ARM-64 Mac. Not sure what's going with _LSDisplayNameConstructor or if there is a way I can workaround/resolve. Some of the crashes have the following lines included: Kernel Triage: VM - Compressor failed a blocking pager_get VM - Compressor failed a blocking pager_get VM - Compressor failed a blocking pager_get VM - Compressor failed a blocking pager_get VM - Compressor failed a blocking pager_get
1
0
799
Jun ’22
Are in-app purchase receipts included in the App Store receipt on initial install on a new device?
I'm working on an app that uses Auto renewable subscriptions. The app uses StoreKit (not StoreKit2). It is pre-release. I was under the assumption that if the user subscribes via in app purchase on Device 1, and then installs the same app on Device 2 (logged in with the same Apple ID) that the receipt on Device 2 would include the in app purchase receipt on initial install, and therefore by inspecting the receipt locally I could determine that showing onboarding UI on Device 2 is not necessary (and all this could be done locally). Is this not true? I just watched the WWDC 2022 session 110404 "Implement proactive in-app purchase restore" which seems to indicate that this is not the case?
4
0
3.2k
Jul ’22
Both ios-x86_64-simulator and ios-arm64-simulator represent two equivalent library definitions. XCFramework for iOS simulator on M1 & Intel Mac? How?
I now have an M1 Mac and an Intel Mac. I have an XCFramework that targets the iOS simulator and devices. My XCFramework works fine but I'd like to be able to run my app (which uses the XCFramework) on the iOS simulator on both my Macs (m1 & intel). Now my M1 Mac complains about the x86_64 architecture when I try to run it on the simulator. So I rebuilt the XCFramework (recompiling the simulator version on the M1 Mac). I'm compiling the source code from Terminal (building OpenSSL). There is no .xcarchive here. Anyway now the app runs on the simulator on the M1 Mac but on the Intel Mac it won't build (basically the same problem in reverse). So... I made three versions of the library now (for iOS devices, iOS simulator on m1 Mac, and for the iOS simulator on Intel Macs). When I try to make an XCFramework to wrap all three static libraries I get the following error: Both "ios-x86_64-simulator" and "ios-arm64-simulator" represent two equivalent library definitions. I found another thread where the accepted answer was to lipo the x86_64 and arm simulators together, then build the xcframework. I've seen posts from Apple engineers that say using lipo is not supported (reference: https://developer.apple.com/forums/thread/709812?answerId=719667022#719667022 ) So where am I going wrong? I try to make the xcframework like so: xcodebuild -create-xcframework -library build/sim/openssl-1.1.1q/libcrypto.a -headers build/sim/openssl-1.1.1q/crypto -library build/phones/openssl-1.1.1q/libcrypto.a -headers build/phones/openssl-1.1.1q/crypto -library build/intelsim/openssl-1.1.1q/libcrypto.a -headers build/intelsim/openssl-1.1.1q/crypto -output build/Crypto.xcframework
3
1
6.8k
Aug ’22
UIActivityViewController closes automatically: SLRemoteComposeViewController: (this may be harmless) viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
Simple UIActivityViewController configured like this:NSArray *activityItems = @[linkURL]; //<--linkURL is an NSURL. UIActivityViewController *activityViewController = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];Then I present it:[self presentViewController:activityViewController animated:YES completion:nil];If I select the Mail or Messages activity the activity works as expected. But if I select the "Reminders" or "Notes" activity the view controller for those activities present briefly before automatically dismissing and logging out:: SLRemoteComposeViewController: (this may be harmless) viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}Anyone know the potential cause / workaround? The completionWithItemsHandler block does not return me an error.
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
2.3k
Aug ’22
Is UIBackgroundModes audio required for WKWebView to play audio/airplay etc in the background?
I know WKWebview is in another process from the main app. My question is is the UIBackgroundModes audio entry in Info.plist required on the main app for WKWebview to play audio/video/airplay in the background? Or is simply setting WKWebViewConfiguration allowsAirPlayForMediaPlayback and allowsPictureInPictureMediaPlayback enough? I recall having issues with background audio from WKWebView on older versions of iOS a couple years ago so I added the audio entry to the Info.plist.... but I just removed the key from the Info.plist and background audio from WKWebview seems to be working fine...maybe audio background mode is not required? Or does it only seem to be working because my app is attached to the debugger? Or is this a bug?
1
1
1.5k
Aug ’22
Find & Replace: All properties on UITextSearchOptions are readonly? How am I supposed to use it with UIFindSession?
I'm trying to figure out how I'm suppose to work with this API on UIFindSession: - (void)performSearchWithQuery:(NSString *)query options:(nullable UITextSearchOptions *)options; I want to provide a UITextSearchOptions object, but the properties are readonly so I'm not sure what purpose it serves exposing it in the public API? @interface UITextSearchOptions : NSObject /// See UITextSearchMatchMethod above. @property (nonatomic, readonly) UITextSearchMatchMethod wordMatchMethod; /// Comparison options to use when searching for strings. @property (nonatomic, readonly) NSStringCompareOptions stringCompareOptions; @end So I can't simply invoke a search like this...which would've really been nice...        UIFindSession *session = findInterfaction.activeFindSession;    UITextSearchOptions *searchOptions = [[UITextSearchOptions alloc]init];  searchOptions.stringCompareOptions = NSCaseInsensitiveSearch; //readonly can't...   [session performSearchWithQuery:searchString options:searchOptions]; There is this API: /// available in @c UITextSearchOptions, which can be either modified, augmented, or omitted. @property (nonatomic, readwrite, copy, nullable) UIMenu *_Nullable (^optionsMenuProvider)(NSArray<UIMenuElement *> *defaultOptions); So I can remove menu items that edit the UITextSearchOptions but how exactly do I "override" them for my needs?
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
468
Sep ’22
Missing or invalid signature. The bundle 'com.firebase.Firebase-nanopb' at bundle path is not signed using an Apple submission certificate
After upgrading to Xcode 14 I cannot submit an update to one of my apps that uses the GoogleMobileAdsSDK. I'm getting the following error when I try to submit to the App Store: Missing or invalid signature. The bundle 'com.firebase.Firebase-nanopb' at bundle path 'Payload/PATH_HERE/nanopb.framework' is not signed using an Apple submission certificate. Anyone else getting this and know of a solution?
1
0
1.1k
Sep ’22
Resize UITargetedPreview as part of custom animation?
I'd like to resize a UITargetedPreview as part of a custom animation. I tried doing this by using the animator provided in: - (void)tableView:(UITableView *)tableView willDisplayContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration animator:(nullable id<UIContextMenuInteractionCommitAnimating>)animator But resizing the source view for the target preview does not cause the container view to resize with it (leaving a large gap after my custom animation completes). So my preview is wrapped in a visual effects view that doesn't downsize with UITargetedPreview's view I provided. I also tried wrapping a snapshot view in a UIViewController and using previewProvider block instead of using a UITargetPreview. I am able to resize the previewViewController by setting the preferredContentSize property and resizing works, but it still doesn't look right because the default animation for the preview view controller breaks with the custom animation I'm trying to implement. Anyone know if this is possible?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
399
Sep ’22
presentedViewController Not set to nil on iOS 16 after dismissal. Calls to -presentViewController:animated:completion: then fail.
Testing my app, I noticed a button in my UI which presents a UIAlertController appeared to do nothing all of a sudden, after a few days. So hooking up the console app I see UIKit spit out the following log when I press the button: "Warning: Attempt to present UIAlertController on MyViewController which is already presenting SomeOtherViewController. No view controller appears to be presented. SomeOtherViewController is not currently in the UI but for some reason after it was dismissed the presentedViewController property wasn't set to nil (haven't been able to reproduce the issue yet). So SomeOtherViewController I know is a "Detail View Controller" which only get pushed on the UINavigationController stack (I never present it modally). The only time it gets presented modally is when it is a "preview view controller" used in UIContextMenuConfiguration, but otherwise it doesn't get presented. Has anyone run into this sort of situation before and know of a potential cause/solution? The presentedViewController does not appear on screen but for some reason UIKit is holding a strong reference to it in the presentedViewController property which prevents subsequent calls to -presentViewController:animated:completion: As a workaround I could try using the code below but I'd really like to find the root cause of the issue: -(void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {     UIViewController *currentPresentedVC = self.presentedViewController;     if ([currentPresentedVC isKindOfClass:[SomeOtherViewController class]])     {        //this is unexpected.         [currentPresentedVC dismissViewControllerAnimated:NO completion:^{             [super presentViewController:viewControllerToPresent animated:flag completion:completion];         }];     }     else     {         [super presentViewController:viewControllerToPresent animated:flag completion:completion];     } }
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
1.5k
Sep ’22
iPhone 14 Pro in Landscape Mode: UIView to UIImage using UIGraphicsBeginImageContextWithOptions generates clipped image. Image is Fine on iPhone 13 Pro Max
Testing on the iPhone 14 Pro simulator I notice if the device is in the landscape orientation, snapshot images my app takes are clipped (the x origin is off). I take a snapshot of a view like this: -(UIImage*)getSnapshotForView:(UIView*)snapShotView {  UIGraphicsBeginImageContextWithOptions(snapShotView.bounds.size, NO, 0.0f); [snapShotView drawViewHierarchyInRect:snapShotView.bounds afterScreenUpdates:YES]; UIImage *snapShotImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return snapShotImage; } So I have an iPhone SE 3rd gen and all is working fine. But I figured I'd test in the iPhone 14 Pro simulator. When the simulator is in landscape mode the generated image is inset like 100 points on the x origin and the content is clipped off on the right side. So I looked at the view I was snapshotting and I thought I wasn't accounting for safe area insets properly (right and left) but I was. The subviews of the view I'm snapshotting all have the expected CGRect value for their frames. Looks like iPhone 14 Pro is rendering snapshots location on the x axis when the device is in landscape mode (at least that appears to be the case in the simulator at least). Any ideas if I'm doing something wrong?
2
0
1.4k
Sep ’22
iOS 16 -viewWillTransitionToSize:withTransitionCoordinator: bizarre value in the size parameter ((CGSize) size = (width = 414, height = 394)) on iPhone 14 Pro Max?
I noticed a bug on rotation change in my app on iPhone 14 Pro Max simulator. Basically a view in my view hierarchy is hidden when it shouldn't be. In landscape mode there isn't enough room for this view so I hide it on the iPhone (not essential). But when tilting back to portrait mode I unhide it. -(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {     [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];     BOOL isIPhone = UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone;    BOOL isIPhoneAndGoingLandscapeMode = (isIPhone                                           && size.width > size.height); if (isIPhoneAndGoingLandscapeMode) { self.someView.hidden = YES; } else { self.someView.hidden = NO; } } So this view controller is presented modally (form sheet style). On iPhone 14 Pro Max on orientation -viewWillTransitionToSize:withTransitionCoordinator: is called twice and the size parameter is always: (CGSize) size = (width = 414, height = 394) This is the sized passed to my app when rotating to portrait and landscape so my isIPhoneAndGoingLandscapeMode flag always is YES because 414 > 394. The 414 x 394 size appears to be false. My view controller's view in landscape on iPhone 14 pro max logs out to: (origin = (x = 0, y = 0), size = (width = 932, height = 430)) And 932 x 430 is the size I expected to be passed to me in -viewWillTransitionToSize:withTransitionCoordinator: Unless I'm missing something can this behavior be explained?
3
0
2.0k
Sep ’22