Post

Replies

Boosts

Views

Activity

Mac Catalyst NSToolbar / Title Bar Doesn't Honor overrideUserInterfaceStyle value of the UIWindow
It is normal to have a preference like: “Always use Dark Mode” in an app to allow the user to opt in to Dark mode in the current app without turning it on System wide. On iOS you can manage this by detecting the change in the app preference and when it is turned on you set the overrideUserInterfaceStyle property on the UIWindow to UIUserInterfaceStyleDark. On Mac Catalyst however this does not work. If you set the overrideUserInterfaceStyle property to UIUserInterfaceStyleDark the NSWindow underneath doesn’t update to reflect dark mode. The titlebar doesn’t update for dark mode either. And neither does the NSToolbar. Only UIViewControllers inside the UIWindow reflect the overrideUserInterfaceStyle Ideally it would be great if there was a overrideUserInterfaceStyle property on UIApplication but there is not. Is there a way to force the NSWindow/NSToolbar created by Mac Catalyst to use a particular appearance (without an Appkit bundle)?
0
1
610
Jan ’23
Uploading App Preview Video for Mac App Fails with Error "Your app preview contains unsupported or corrupted audio" even though the video contains no audio.
Uploading an App Preview Video for a Mac App Fails with Error "Your app preview contains unsupported or corrupted audio" even though the video contains no audio. Anyone run into this and know of a workaround? I filed FB12151982
2
3
2.7k
Jun ’23
UIDeferredMenuElement With Uncached Provider Not Working on Mac Catalyst. Uncached provider block never called and menu displays as "Loading"
I'm trying to create a dynamic menu on Mac Catalyst. Using a UIBarButtonitem like so to make a "pull down" button: UIDeferredMenuElement *deferredmenuElement; deferredmenuElement = [UIDeferredMenuElement elementWithUncachedProvider:^(void (^ _Nonnull completion)(NSArray<UIMenuElement *> * _Nonnull)) { UIAction *actionOne = [UIAction actionWithTitle:@"Action One" image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) { NSLog(@"action one fired."); }]; UIAction *actionTwo = [UIAction actionWithTitle:@"Action Two" image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) { NSLog(@"action two fired."); }]; UIAction *actionThree = [UIAction actionWithTitle:@"Action Three" image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) { NSLog(@"action three fired."); }]; completion(@[actionOne,actionTwo,actionThree]); }]; UIMenu *wrappedMenu = [UIMenu menuWithChildren:@[deferredmenuElement]]; UIBarButtonItem *uiBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:nil menu:wrappedMenu]; uiBarButtonItem.image = [UIImage systemImageNamed:@"rectangle.and.pencil.and.ellipsis"]; self.navigationItem.rightBarButtonItems = @[uiBarButtonItem]; The button appears in the toolbar but when I click it to expose the menu I get a menu with on element in it that says "Loading...". The the uncached provider block is never called. Running Ventura 13.2.1 and Xcode 14.2.
8
2
2k
Jul ’24
NSLayoutConstraint 'UIView-Encapsulated-Layout-Height' on UICollectionViewListCell Breaking Self Sizing Content View Constraint
I'm using compositional layout with UICollectionView. In a particular section I configure the compositional layout to use an estimated height because I want self sizing items determined by Autolayout Constraints. Now I have a custom content configuration with autolayout constraints. At runtime I hit this log about conflicting constraints: [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) [...] <NSLayoutConstraint:0x6000024af160 UIImageView:0x120745520.height == 130 (active)> <NSLayoutConstraint:0x6000024af2a0 MyCustomContentView :0x120748d60.height >= 1.04839*UIImageView:0x120745520.height (active)> <NSLayoutConstraint:0x6000024b08c0 'UIView-Encapsulated-Layout-Height' UICollectionViewListCell:0x1214392f0.height == 44 (active)> Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000024af160 UIImageView:0x120745520.height == 130 (active)> The "UIView-Encapsulated-Layout-Height" on UICollectionViewListCell with a value of 44.0 appears to be a constraint created by the system. I'm not sure why a hard coded height of 44.0 is being used when the compositional layout is returning a section that only uses estimated heights (created via NSCollectionLayoutDimension estimatedDimension). Any ideas how I can avoid this? I'm not using custom UICollectionView cells but I am using a custom content configuration and a custom content view and setting my content configuration on a UICollectionViewListCell.
Topic: UI Frameworks SubTopic: UIKit Tags:
1
2
1.5k
Aug ’23
Live Preview Not Working for UIKit Unless I raise Deployment Target to iOS 17
In Xcode 15 Live Previews are available for UIKit view controllers and views. However I noticed they do not work if the deployment target is < 17.0. If I try to make a live preview for a view controller like so: #Preview { let someVC = ViewController() return someVC } It doesn't load. The error is described below: == PREVIEW UPDATE ERROR: CompileDylibError: Failed to build ASwiftViewController.swift Compiling failed: module 'SwiftUI' has no member named 'VStack' If I raise the deployment target to iOS 17 it starts working.
3
2
3.0k
Oct ’23
Xcode 11.1 "Unable to Download Xcode"
So I tried installing this update three times. Each time all 7.6 GB "downloads" and begins the "Installing..." shortly after Xcode starts "Installing" I get a notification in the Notification Center "Unable to Download App" "Xcode could not be installed please try again later."...Anyone else?
52
0
89k
Aug ’21
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 &amp; 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.7k
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.4k
Aug ’22
UIDocumentPickerViewController -initForOpeningContentTypes: gives URL to app without permission to read it in Release mode only
I'm using UIDocumentPickerViewController to open a url. Works fine in debug mode but version on the App Store is failing. Code to create the document picker is like: NSArray *theTypes = [UTType typesWithTag:@"docxtensionhere" tagClass:UTTagClassFilenameExtension conformingToType:nil]; UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc]initForOpeningContentTypes:theTypes]; documentPicker.delegate = self;   [self presentViewController:documentPicker animated:YES completion:nil]; So in debug mode this is all gravy. -documentPicker:didPickDocumentsAtURLs: passes back a URL and I can read the file. In release mode I get a URL but my app is denied access to read the file. After inspecting some logging it appears the sandbox is not granting my app permission. error Domain=NSCocoaErrorDomain Code=257 "The file “Filename.fileextensionhere” couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/private/var/mobile/Library/Mobile Documents/comappleCloudDocs/Filename.fileextensionhere, NSUnderlyingError=0x2834c9da0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} -- If I'm doing something wrong with UIDocumentPickerViewController it is a real shame that permission is not being denied in Debug mode, as devs are more likely to catch in prior to release. Anyone know where I'm going wrong and if not have a workaround? Thanks in advance.
9
0
2.2k
Sep ’25
Window's title bar separator draws way out of place on Mac Catalyst, not even close to title bar location
So I built my app with Mac Catalyst. I see this little line appear and disappear periodically in the window. Then all of a sudden it disappears when the window's activation state changes sometimes. It looks like a weird little glitch. Turns out this is the title bar's separator which is UITitlebarSeparatorStyleAutomatic (I believe the system hides/shows the separator in this mode based on current window states. I change the separator style to shadow and sure enough it draws like a shadow and never disappears. It's not even close to where the separator is supposed to be (nowhere near the title bar). The only workaround I have is to use UITitlebarSeparatorStyleNone which I'll do if I have to but was wondering if someone else has run into this and has a better workaround.
5
2
1.1k
Oct ’22
Determine selected text color to use in Mac Catalyst for UITableView Cells When Row is Selected But Table View Doesn't Have Active Focus?
So when a row is selected in UITableView and the table view / cells within it have focus, and the window is active.... the rows are selected with the system Accent color (in my case blue). I have a view inside the table view cell that does custom drawing. When the cell is selected I draw text white (when unselected I draw the text using UIColor.labelColor). So when the window is not active but the table view row is selected, the selected background color changes to light gray. In this case I draw the text black (because it looks better against the light gray selection color on an inactive window). However when the row is selected but another view in the window has focus (say the sidebar) the selected row turns back to the light gray color. In this case my text is incorrectly drawing white instead of black on the light gray background. How do I check for this state from UIKit? In AppKit I think I'd be using: NSColor.unemphasizedSelectedTextColor https://developer.apple.com/documentation/appkit/nscolor/2998834-unemphasizedselectedtextcolor?language=objc I have to update text color manually because I'm doing custom drawing in these table view cells (I have a view that overrides drawRect:) I can't just use the dynamic colors like UIColor.labelColor. I have to set the colors on state change manually and call setNeedsDisplay on my view. How do I check for the unemphasized state? I did inspect whether or not my table view cell is in the active focusItem's environment, and if it is not I assume the light gray selected color is being used. This worked most of the time but there still seems to be some states where the unemphasized selection color (light gray)is being used on selected cells when the the table view cell is in the active focus environment and my text incorrectly draws white.
1
1
1.5k
Oct ’22
How come Crash Reports Don't Include the NSException name and reason when a crash is caused by a raised exception?
When running into a hard to reproduce crash that only occurs in a production build it would be helpful to get more detailed information about the thrown exception. As far as I can tell, Crash reports don't include the NSException's name, reason, or userInfo. Is there any reason why this isn't included in Crash reports provided to developers? Someone else asking something similar here: https://stackoverflow.com/questions/73327915/how-do-you-add-diagnostic-information-to-ios-crash-reports
1
1
785
Jan ’23