Post

Replies

Boosts

Views

Activity

Mac Catalyst Menu Bar/Toolbar Actions Not Validating Properly After Changing Active Windows
I have a multiple window Mac Catalyst app. I'm using a NSToolbar and the menu bar via UIMenuBuilder. I noticed after changing windows the menu bar isn't always validating properly. For example my app implements "Undo" and "redo". So I can reproduce the issue using these steps: Perform an action that can be undone. Open a new window. This new window has its own undo manager. In the Menu bar select Edit -> Undo Undo validates even though the current window has nothing on its local undo stack. If invoked undo is performed on the inactive window which definitely seems wrong. The same thing sometimes happens in reverse (that is, undo doesn't validate when it should after switching windows). This also happens with other actions after switching windows. Sometimes I can get the actions to validate by hitting the Tab key to move focus then shift tabbing back, which seems to force proper lookup in the responder chain (but sometimes that doesn't work). It seems that Catalyst is losing track of the real active window/window scene for some reason and is validating actions on the wrong window scene. Anyone experience this and know where I could be going wrong and/or know of a possible workaround? I tried subclassing UIApplication and implementing the methods there (and then forwarding them to the active UIWindowScene). However this doesn't work, the wrong window scene has its activationState set to UISceneActivationStateForegroundActive when the problem occurs.
9
1
2.3k
Nov ’23
SwiftUI Previews: Is There a Way to Have the Preview Take Over the Entire Window and Collapse the Source Code Pane?
In a SwiftUI source file Xcode displays a window with a Split View. The first split is the source code and the second split is the preview. My question is, is there a way for me to have the preview take over the entire window width (I want to collapse the source code pane and just look at the preview)? I can easily collapse the Preview pane by dragging the split to the right to collapse (but it doesn't work in reverse). I also can toggle the preview pane by going to Editor -> Canvas in the Menu bar. Currently I'm using SwiftUI just to get a live preview of UIKit view controllers so I'm not interested in looking at the SwiftUI source code, though I imagine displaying a full window preview in a separate window would be useful for SwiftUI developers too. You could edit the source code on one monitor and have the preview window on an external display. Is this not possible?
1
1
1.7k
Jul ’23
How to set NSCollectionLayoutVisibleItem's name property for use in UICollectionViewCompositionalLayout?
I'm Using UICollectionViewCompositionalLayout with a section provider and I set the NSCollectionLayoutSectionVisibleItemsInvalidationHandler on a particular section. The NSCollectionLayoutSectionVisibleItemsInvalidationHandler hands back an array of objects conforming to the NSCollectionLayoutVisibleItem protocol which has a name property which always appears to be nil. I figured there must be a way to use this name property to make it easier to do look up for the NSCollectionLayoutVisibleItem objects I'm actually looking. Is there a way to make this property nonnil? Does it get set to the UICollectionViewCell's reuse identifier or something (I'm currently using UICollectionViewCellRegistration)? Is there any documentation on the name property? https://developer.apple.com/documentation/uikit/nscollectionlayoutvisibleitem/3199122-name?language=objc
Topic: UI Frameworks SubTopic: UIKit Tags:
0
1
357
Jul ’23
StoreKit Receipt Refresh Error (Mac Catalyst) Error Domain=AMSErrorDomain Code=203 "Bag Load Failed Unable to retrieve app-receipt-create because we failed to load the bag."
Been testing all day and receipt loading has been working (testing in sandbox) on Mac Catalyst. I'm using StoreKit1. All of a sudden I'm getting the following error when refreshing a receipt: ** Error Domain=AMSErrorDomain Code=203 "Bag Load Failed Unable to retrieve app-receipt-create because we failed to load the bag." UserInfo={NSDebugDescription=Bag Load Failed Unable to retrieve app-receipt-create because we failed to load the bag.** Sandbox server down?
1
0
2.1k
Oct ’23
Mac Catalyst: Presenting view controller <UIAlertController:> from detached view controller <MyViewController:> is not supported, and may result in incorrect safe area insets and a corrupt root presentation on Sonoma
Okay so I'm getting this log every time I present a UIAlertController: Mac Catalyst: Presenting view controller <UIAlertController: 0x10f027000> from detached view controller <MyViewController: 0x10d104080> is not supported, and may result in incorrect safe area insets and a corrupt root presentation. Make sure <MyViewController: 0x10d104080> is in the view controller hierarchy before presenting from it. Will become a hard exception in a future release. A few points: MyViewController is not detached and the presentation shows just fine. I specifically check for this before presenting the alert controller like so: BOOL okayToPresentError = (self.isViewLoaded && self.view.window != nil); if (okayToPresentError) { [self presentErrorInAlertController:error]; } else { //Wait until view did appear. self.errorToPresentInViewDidAppear = error; } It spews out every time an error is fed back to my app and I present the alert controller (I can turn off the network connection and I show an alert controller with a "retry" button in it which will loop the error back so I can replay the error alert presentation over and over again) . Every time the alert controller is presented, I get this spewing in the console. Please don't start throwing hard exceptions because the check is faulty.
4
1
2.2k
Feb ’25
WKWebView Unrecognized Selector Sent to Instance: WebAVPlayerLayer - startRedirectingVideoToLayer:forMode:
I'm using WKWebView in a Mac Catalyst app (not sure if using Catalyst makes a difference but it seems WKWebView doesn't get the "full" Mac version AppKit apps do so maybe it does). When a website has a video playing and if I click the button that I guess is a Picture in Picture button next to the "close" button the web kit process gets an unrecognized selector sent to instance exception. -[WebAVPlayerLayer startRedirectingVideoToLayer:forMode: <-- Unrecognized selector. In debugging mode at least my app doesn't crash the video continues to play and the WKWebview is unresponsive to user interaction. I have to force quit my app. -- I'm on Sonoma 14.0
1
1
783
Oct ’23
Use prebuilt dylib built for macOS in macCatalyst?
Is there a way to link a prebuilt dylib that was built for the 'macOS' platform on Mac Catalyst without being warned by Xcode? Generally it would be better to just recompile for Mac Catalyst but this is a third party library and they have a complicated build system with dozens of dependencies that doesn't support Mac Catalyst as of now (although they have iOS and Mac 'regular'). So I would have to spend quite a bit of time trying to sort through their build system to make a Catalyst version myself. The library uses no platform specific UI code and I'm fairly certain that macOS build would work just fine on Mac Catalyst without any changes since it isn't UI related at all. It seems to work fine (apart from Xcode warning me about linking a .dylib built for macOS on Mac Catalyst). I could shim all this away in a NSBundle that is aware of the AppKit world but then I have to make all method calls to the third party framework on Mac Catalyst through the bundle and it would separate my iOS and Catalyst code relying on the same implementation which isn't great. Is there a way I could just replace the 'macOS' platform in the .dylib with macCatalyst to get rid of the warning?
2
1
1.6k
Nov ’23
App Store Promo Codes Not Working for Subscriptions on iOS 18
I tried redeeming a promo code for a subscription on iOS 18. It's a yearly subscription (the promo code is for myself in this case). This always worked before. Now on iOS 18 when I redeem the code in the App Store it just spins an activity indicator in the navigation bar for a few seconds and stops. Promo code doesn't redeem. No error message either. Now when I try to redeem the promo code on the Mac App Store I get the following error: "You must redeem this code on a device that supports App name". This error makes sense because the app is iOS/iPadOS only. But the fact that the Mac App Store displays the App name in the error message indicates that the code is valid and should work on iOS, but it does not.
4
1
854
Oct ’24
StoreKit2: Testing AppTransaction Receipt Verification?
I just boxed up AppTransaction API. In the debug environment it appears to always return a VerificationResult that is .verified Unlike Storekit1 calling AppTransaction.shared does not seem to cause a sandbox receipt to actually get written on the app bundle in Derived data. I was trying to purposefully mess with the receipt in order to get AppTransaction to fail so I can test how my app behaves when errors occur but there is no receipt to mess with. I tried using the old exit(173) API and it does cause a receipt to be fetched but that seems to be completely ignored by AppTransaction, it validates even if you trash or tamper with the receipt given by exit(173). Is there a good way to test receipt validation failure using the high level Storekit2 API?
2
1
205
Sep ’25
macOS Tahoe: NSView -cacheDisplayInRect:toBitmapImageRep: Doesn't Work Unless View is Added to Window
Previously I was able to "snapshot" view that were not part of any window hierarchy using the following: NSImage *buttonImage = [NSImage imageWithSystemSymbolName:@"49.circle.fill" accessibilityDescription:nil]; NSButton *aButton = [NSButton buttonWithImage:buttonImage target:nil action:nil]; [aButton sizeToFit]; NSBitmapImageRep *rep = [aButton bitmapImageRepForCachingDisplayInRect:aButton.bounds]; if (rep == nil) { NSLog(@"Failed to get bitmap image rep."); return; } [aButton cacheDisplayInRect:aButton.bounds toBitmapImageRep:rep]; NSData *tiffData = rep.TIFFRepresentation; NSImage *snapShotOfImage = [[NSImage alloc]initWithData:tiffData]; Now on macOS Tahoe I get a non nil image, but the image is blank. However if I add aButton NSWindow's view hiearchy just before the call to -cacheDisplayInRect:toBitmapImageRep: I do get a proper image. Is this behavior intended or is this considered a bug? Is it documented anywhere that a view must be in a NSWindow for -cacheDisplayInRect:toBitmapImageRep: to work? Thanks
Topic: UI Frameworks SubTopic: AppKit Tags:
2
0
89
3w
Spotlight Shows "Helper Apps" That Are Inside Main App Bundle That Are Not Intended to Be Launched By The User
I have Mac apps that embed “Helper Apps” inside their main bundle. The helper apps do work on behalf of the main application. The helper app doesn’t show a dock icon, it does show minimal UI like an open panel in certain situations (part of NSService implementation). And it does make use of the NSApplication lifecycle and auto quits after it completes all work. Currently the helper app is inside the main app bundle at: /Contents/Applications/HelperApp.app Prior to Tahoe these were never displayed to user in LaunchPad but now the Spotlight based AppLauncher displays them. What’s the recommended way to get these out of the Spotlight App list on macOS Tahoe? Thanks in advance.
4
0
186
Nov ’25
errSecInvalidOwnerEdit returned from SecItemDelete
Have an app I'm working on that stores an item in the keychain. Everything was was working fine. I have a button in the UI that allows the user to clear out the keychain item:NSDictionary *query = @{(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword, (__bridge id)kSecAttrService: service, (__bridge id)kSecAttrAccount: accountKey}; OSStatus status = SecItemDelete((__bridge CFDictionaryRef)(query));Status is -25244 which is errSecInvalidOwnerEdit. This app created the keychain item to begin with. What would be the appropriate way to handle this type of error?
16
0
4.2k
Nov ’23
UITableview content overlaps translucent nav bar when scrolled on iOS 13
So, a UItableview inside a *regular* UIViewController (not using UITableviewcontroller).1) This view controller is embedded in a UINavigationController. The navigation item has "automatic' large title mode.2) The navigation controller's nav bar prefers large title.3) When the table view is scrolled, the big title does *not* shrink to the *regular* title size like in the iOS mail app. Instead, the table view content overlaps the navbar and bleeds through, making a UI glitch.On iOS 12 the scrolled content does not overlap the nav bar. This is new in IOS 13. Anyone get this and have a workaround?
Topic: UI Frameworks SubTopic: UIKit Tags:
7
0
5.4k
May ’22