Mac Catalyst

RSS for tag

Start building a native Mac app from your current iPad app using Mac Catalyst.

Mac Catalyst Documentation

Posts under Mac Catalyst tag

113 Posts
Sort by:
Post not yet marked as solved
3 Replies
860 Views
Shortly after presenting a UIDocumentPickerViewController on Mac Catalyst the system throws this exception and I keep hitting my exception breakpoint: NSView: valueForUndefinedKey this class is not key value coding-compliant for the key cell. Appears to be related to the system using Touch Bar APIs (my app isn't currently using Touch Bar APIs directly but the NSOpenPanel created by UIDocumentPickerViewController is). #2 0x0000000198de2828 in -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] () #3 0x000000019884ef3c in -[NSObject(NSKeyValueCoding) valueForKey:] () #4 0x0000000200b75a68 in -[NSObject(UIAccessibilitySafeCategory) __axValueForKey:] () #5 0x0000000200b75960 in __57-[NSObject(UIAccessibilitySafeCategory) safeValueForKey:]_block_invoke () #6 0x0000000200b75f9c in -[NSObject(UIAccessibilitySafeCategory) _accessibilityPerformSafeValueKeyBlock:withKey:onClass:] () #7 0x0000000200b754d0 in -[NSObject(UIAccessibilitySafeCategory) safeValueForKey:] () #8 0x0000000222206b60 in -[NSTouchBarItemAccessibility__UIKit__AppKit _accessibilityPopulateAccessibiltiyInfoFromUIKit] () #9 0x0000000222206b1c in -[NSTouchBarItemAccessibility__UIKit__AppKit _itemViewMinSize:maxSize:preferredSize:stretchesContent:] () #10 0x000000019b3f70bc in -[NSCompressionGroupLayout item:minSize:maxSize:preferredSize:] () #11 0x000000019aff24f4 in -[NSTouchBarItemContainerView _updateMeasuredSizes] () #12 0x000000019aff2358 in -[NSTouchBarItemContainerView minSize] () #13 0x000000019accae98 in -[NSTouchBarLayout _aggregateWidthOfItems:sharesLeftEdge:sharesRightEdge:widthMeasurement:] () #14 0x000000019accb22c in -[NSTouchBarLayout _attributesOfItems:centerItems:givenSize:sharesLeftEdge:sharesRightEdge:xOrigin:] () #15 0x000000019acca930 in -[NSTouchBarLayout attributesOfItems:centerItems:givenSize:] () #16 0x000000019b52bbb0 in -[NSTouchBarView _positionSubviews] () #17 0x000000019b52ba6c in -[NSTouchBarView layout] () -- The exception does get caught (my app doesn't crash) but I hit the exception breakpoint over and over again while the NSOpenPanel is on screen which is annoying.
Post not yet marked as solved
4 Replies
1.2k Views
Hi, I have an iPad app that has menus, like:  CommandGroup(replacing: .help) {                 Button("Help") { showHelp = true }                     .keyboardShortcut("/")  } They works fine in iPad and also if compiled to Mac Catalyst, but will crash on Apple Silicon Mac when selected the menu items with errors like: [General] -[_UIEditMenuInteractionMenuController propertyList]: unrecognized selector sent to instance 0x600000190540 I did not use storyboard and only use SwiftUI. Any suggestions? Note: of course the best solution is to compile to Mac Catalyst, but the app has some other issues when run in Mac Catalyst. So I can only release it as iPad app.
Posted
by
Post not yet marked as solved
4 Replies
1.9k Views
CoreUI is sending warning messages to the Xcode console when creating a UIImage from an image file with Mac idiom from the asset catalog, while running on Catalyst. My target is set to support running on Mac Catalyst with Optimize for Mac enabled (the latter seems to be the most important part). Loading the image into a UIImage with the designated initializer and presenting it in a UIImageView produces the following console messages: 2023-02-15 10:53:18.014394+0100 CatalystImageConsoleMessage[64253:8834791] [framework] CoreUI: _Bool CUIValidateIdiomSubtypes(NSInteger, NSUInteger *) got a device subtype '32401' that it match with idiom '7':mac. Assuming subtype should be 0 instead. 2023-02-15 10:53:18.014446+0100 CatalystImageConsoleMessage[64253:8834791] [framework] CoreUI: _Bool CUIValidateIdiomSubtypes(NSInteger, NSUInteger *) got a device subtype '32401' that it match with idiom '7':mac. Assuming subtype should be 0 instead. 2023-02-15 10:53:18.014503+0100 CatalystImageConsoleMessage[64253:8834791] [framework] CoreUI: _Bool CUIValidateIdiomSubtypes(NSInteger, NSUInteger *) got a device subtype '32401' that it match with idiom '7':mac. Assuming subtype should be 0 instead. 2023-02-15 10:53:18.014533+0100 CatalystImageConsoleMessage[64253:8834791] [framework] CoreUI: _Bool CUIValidateIdiomSubtypes(NSInteger, NSUInteger *) got a device subtype '32401' that it match with idiom '7':mac. Assuming subtype should be 0 instead. Working with more than a handful of images from the catalog makes the Xcode console output borderline unreadable because of these messages. The console doesn't have an option to filter out messages (and in general we consider it bad practice to ignore messages on the console). Tested on Xcode 14.2 with macOS 13.2. You can find a sample project at https://github.com/tamasjager/CatalystImageConsoleMessage.
Posted
by
Post not yet marked as solved
4 Replies
1.3k Views
Hello. There is a "Highlight" context menu option that shows up when a user right-clicks some selected text in a PDF. There is no way to get rid of this menu item and clicking it does nothing. How do I get rid of it? I tried overriding buildMenu(with builder: UIMenuBuilder) to remove it but that doesn't work. Help!
Posted
by
Post marked as solved
4 Replies
998 Views
I'm trying to enable the web inspector on WKWebView in a Mac Catalyst app. I'm only doing this for debugging purposes. In the released the web inspector will not be enabled. Doing this under Mac Catalyst does not work:  WKPreferences *prefs = [[WKPreferences alloc]init];   [prefs _setDeveloperExtrasEnabled:YES]; //Assign the WKPreferences to a WKWebViewConfiguration and create the web view.. Is there any way to do this? Thanks in advance.
Post not yet marked as solved
4 Replies
823 Views
Setting elementFullscreenEnabled property to YES on WKPreferences is not honored on Mac Catalyst.  WKWebViewConfiguration *webViewConfig = [[WKWebViewConfiguration alloc]init];  WKPreferences *prefs = [[WKPreferences alloc]init]; prefs.elementFullscreenEnabled = YES;   webViewConfig.preferences = prefs; //then create the WKWebView.. I load a Youtube url in the WKWebView. Youtube complains that the browser doesn't support full screen. Is there a workaround? Full screen does work in an AppKit app though using the exact same API...though it causes an Autolayout crash (I will be making another thread about that separate issue shortly).
Post not yet marked as solved
5 Replies
867 Views
The test field was originally centered. However, as I tap on it, it was brought to the left. This UI issue occurs on macOS 13.2, built on My Mac(Designed for iPad), while running on iPad is totally fine. Xcode 14.2 and 14.1 has the same behaviour. import UIKit class ViewController: UIViewController { let textField: UITextField = { let textField = UITextField() textField.translatesAutoresizingMaskIntoConstraints = false textField.backgroundColor = .green textField.textAlignment = .center textField.text = "Hello, World" return textField }() override func viewDidLoad() { super.viewDidLoad() view.addSubview(textField) NSLayoutConstraint.activate([ textField.widthAnchor.constraint(equalToConstant: 200), textField.heightAnchor.constraint(equalToConstant: 50), textField.centerXAnchor.constraint(equalTo: view.centerXAnchor), textField.centerYAnchor.constraint(equalTo: view.centerYAnchor) ]) } } How can I fix this?
Posted
by
Post not yet marked as solved
3 Replies
1.2k Views
DemoCode: import SwiftUI import UIKit import PencilKit class PencilKitViewController: UIViewController, PKCanvasViewDelegate, PKToolPickerObserver {       lazy var canvasView: PKCanvasView = {     let canvasView = PKCanvasView()      canvasView.drawingPolicy = .anyInput      canvasView.translatesAutoresizingMaskIntoConstraints = false      return canvasView    }()       lazy var toolPicker: PKToolPicker = {     let toolPicker = PKToolPicker()     toolPicker.showsDrawingPolicyControls = true     toolPicker.addObserver(self)     return toolPicker   }()       let drawing = PKDrawing()       override func viewDidLoad() {     super.viewDidLoad()     canvasView.drawing = drawing     canvasView.delegate = self     view.addSubview(canvasView)   }       override func viewDidLayoutSubviews() {     super.viewDidLayoutSubviews()     canvasView.frame = view.bounds   }       override func viewDidAppear(_ animated: Bool) {     super.viewDidAppear(animated)     toolPicker.setVisible(true, forFirstResponder: canvasView)     toolPicker.addObserver(canvasView)     canvasView.becomeFirstResponder()   }       // canvas   func canvasViewDrawingDidChange(_ canvasView: PKCanvasView) {     print("drawing")   }       func canvasViewDidFinishRendering(_ canvasView: PKCanvasView) {         }       func canvasViewDidEndUsingTool(_ canvasView: PKCanvasView) {         }       func canvasViewDidBeginUsingTool(_ canvasView: PKCanvasView) {         } } // UIRepresentable for SwiftUI struct PencilKitView: UIViewControllerRepresentable {       class Coordinator {     var parentObserver: NSKeyValueObservation?   }       var onSubmit: ((UIImage?, Error?) -> Void)? = .none       func makeUIViewController(context: Context) -> PencilKitViewController {     let pencilKitViewController = PencilKitViewController()     context.coordinator.parentObserver = pencilKitViewController.observe(\.parent, changeHandler: { vc, _ in      })     return pencilKitViewController   }       func updateUIViewController(_ uiViewController: PencilKitViewController, context: Context) {   }       func makeCoordinator() -> Self.Coordinator { Coordinator() } } struct ContentView: View {       var onSubmit: ((UIImage?, Error?) -> Void)? = .none       var body: some View {       PencilKitView()   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } iOS: macCatalyst:
Posted
by
Post not yet marked as solved
7 Replies
1k Views
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.
Post not yet marked as solved
1 Replies
579 Views
I have looked high and low all and cannot find an answer or solution. I have an app that is primarily used by Mac users. I am looking to implement promo codes in the coming weeks. The presentCodeRedemptionSheet call does not work for Mac Catalyst apps saying "This function doesn’t affect Mac apps built with Mac Catalyst" in the documentation. AppStore.presentOfferCodeRedeemSheet also does not work for Mac Catalyst. If it is the case that you can't redeem in-app, that is fine if I can direct users to the Mac App Store to redeem promo codes, but I cannot find a way to do that either. I can only find a route to redeem gift cards. I have also tried clicking on a specific promo code link (something like https://apps.apple.com/redeem?ctx=offercodes&id=00000000&code=PROMOCODE) and that just redirects to the Gift Card redemption screen in the Mac App Store. So is there any way for a Mac only user (a user that does not have an iPhone or iPad) to use app promo codes? Thanks!
Posted
by
Post not yet marked as solved
1 Replies
781 Views
Updated version of this post My HomePod mini is now on version 16.4, so the the temperature and humidity sensors are enabled. The data properly shows up in the Home app on my various devices. In my HomeKit iPad app running on Mac Catalyst, however, the data does not show up. I would expect the HomePod mini to show up in HMHome.accessories with a service of type HMServiceTypeTempatureSensor. I see all of my other HomeKit accessories, just not the HomePod mini. I have tried with the latest Xcode (14.3) and highest available iOS Target and Minimum Deployment (16.4), macOS version 13.3. I have not, as of this writing, upgraded my HomeKit architecture, however. Note that I haven't tried the app on an actual iPad (and the iOS simulator doesn't expose my HomeKit environment.)
Posted
by
Post marked as solved
1 Replies
617 Views
Hi, I am giving Mac Catalyst a try and Apple has provided a tutorial for that but it seems a bit buggy. In the tutorial https://developer.apple.com/tutorials/mac-catalyst/updating-the-app-icon there is the completed Catalyst xcode project (in the Complete folder). I downloaded and ran the completed project in Xcode Version 14.2, using my Mac to run it in simulation. The toolbar at the top of the window has the icons for edit and favorite but they appear to be greyed out and don't do anything when clicked. The selectors are set properly for their actions in the ToolBarDelegate file but nothing happens when I select a recipe, which it appears you have to do in order for those buttons to work, then try to click either one of those items Those buttons never appear to be enabled at all even though I have selected a recipe and the coding seems correct. I am confused as to why this doesn't work. The NSSharingServicePickerToolbarItem is enabled and seems to work. I didn't post any code since the project can be readily downloaded and viewed/run. Any help is much appreciated
Posted
by
Post not yet marked as solved
1 Replies
559 Views
0 I am developing a Mac Catalyst app using UIKit. I have set the "Mac Catalyst Interface" of the target to "Optimize for Mac". All UISliders in my app update their UI "one interaction late": When I click on the slider track, the value of the slider changes accordingly, but the knob does not move to the appropriate position. Only when I click the second time, the knob moves to that position. But when I click on a different position on the track instead, the knob will move to the location corresponding to the previous click. What I tried: Changing "isContinuous", it has no effect. Listen for the "valueChanged" event and in the handler call "setNeedsLayout()" on the slider. Listen for the "valueChanged" event and in the handler call "setNeedsDisplay()" on the slider. When I change the target's "Mac Catalyst Interface" to "Scaled to match iPad", UISlider behaves as expected. But I need it to be "Optimize for Mac". FWIW, here is my code to add a UISlider in a UIViewController, it is super basic stuff: import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let slider = UISlider() view.addSubview(slider) slider.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ slider.heightAnchor.constraint(equalToConstant: 50), slider.widthAnchor.constraint(equalToConstant: 300), slider.centerXAnchor.constraint(equalTo: view.centerXAnchor), slider.centerYAnchor.constraint(equalTo: view.centerYAnchor) ]) slider.addTarget(self, action: #selector(onSlider(_:)), for: .valueChanged) } @objc func onSlider(_ slider: UISlider) { // slider.setNeedsLayout() // slider.setNeedsDisplay() print("on slider: \(slider.value)") } }
Posted
by
Post not yet marked as solved
9 Replies
1.4k Views
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.
Post not yet marked as solved
6 Replies
919 Views
Hi, I'm building an app for iPhone, iPad and Mac (Mac Catalyst). Unfortunately when I'm adding Family Controls capability to project I'm unable to run Mac Catalyst version of app. Everything is compiling, it fails when run and shows "Could not launch App" Launch Service error IDELaunchErrorDomain: code 20 RBSRequestErrorDomain: code 5 NSPOSIXErrorDomain: code 153 iOS version work without any problems and Screen Time releated Api too. My minimum deployment target is iOS 15. Our permission for Family Controls to distribute in AppStore is currently processing but I guess it shouldn't has influence as I'm running debug. Best, Marcin
Posted
by
Post not yet marked as solved
1 Replies
884 Views
I'm trying to handle a mouse scroll wheel in one of my views (to invoke my zoomIn/zoomOut methods) using a UIPanGestureRecognizer with: UIPanGestureRecognizer* panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:myView action:@selector(handlePanGesture:)]; panRecognizer.allowedScrollTypesMask = UIScrollTypeMaskDiscrete; [myView addGestureRecognizer:panRecognizer]; My handlePanGesture method is successfully called twice (once for UIGestureRecognizerStateBegan and UIGestureRecognizerStateEnded), but... then what do I do? The passed UIPanGestureRecognizer* has numberOfTouches = nil, and I can't get any further info about the scroll wheel UIEvent from UIGestureRecognizer or its superclass. How to I tell if it was a scroll up, or a scroll down? See: wwdc20-10094
Posted
by
Post not yet marked as solved
1 Replies
590 Views
I have submitted FB12157356 for an issue where Mac Catalyst does not play nicely with NSToolBar. Supposedly clickable items in the toolbar do not enable when they should. This is from the Mac Catalyst tutorial at https://developer.apple.com/tutorials/mac-catalyst/updating-the-app-icon Here is what I wrote: In the tutorial https://developer.apple.com/tutorials/mac-catalyst/updating-the-app-icon there is the completed Catalyst xcode project (in the Complete folder). I downloaded and ran the completed project in Xcode Version 14.2, using my Mac OS 12.6.5 to run it. The NSToolBar at the top of the window has the toolbar items for edit and favorite, but they remain greyed out and don't do anything when a recipe is selected. The selectors seem to be set properly for their actions in the ToolBarDelegate file but nothing happens when I select a recipe and the DetailViewController displays the recipe, which it appears you have to do in order for those toolbar items to work. Those buttons never appear to be enabled at all even though I have selected a recipe and the sample coding seems correct. Steps to Reproduce: Download and open the Xcode project in the "Complete" folder from the link provided above. Run the project with Mac as the the simulator target. Select a recipe The toolbar edit icon should be enabled and should display the RecipeEditorViewController when clicked. The favorite (heart) icon should be filled if the recipe is a favorite, and allow you to favorite a recipe if it isn't already a favorite. Interestingly, if you enable the Touch Bar when running the app from Xcode, the Touch Bar displays the edit and favorite icons correctly and the react properly to touches. If anyone has time to look at the tutorial and any suggestion for a workaround so that the toolbar items work correctly I'd love to hear it. Catalyst has lots of potential but this apparent bug isn't helping.
Posted
by
Post not yet marked as solved
0 Replies
465 Views
While dropping a file from Finder into our app works as expected – dropping from Mail behaves differently on the Mac (works fine on iPad): [session hasItemsConformingToTypeIdentifiers:…] is false for the type identifier of the dragged file. The session only contains an item for "public.url" and that is also the only thing I can ever get from the item provider. [itemProvider loadItemForTypeIdentifier:@"public.url" options:nil completionHandler:^(NSData* item, NSError* error) { is described to do a coercion: "The contents of the URL is read and returned as NSData" but the data returned is just the NSData encoding of the URL. The URL is also not accessible –  not even when invoking startAccessingSecurityScopedResource first. The console reports: Failed to get a sandbox extension I tried adding the com.apple.security.files.bookmarks.document-scope and com.apple.security.files.bookmarks.app-scope entitlement, but that did not help either.
Posted
by
Post not yet marked as solved
0 Replies
495 Views
We have a Mac Catalyst app that is installed and works with a custom Safari extension. The Safari is working as expected and is able to pass messages (using sendNativeMessage) to the Mac Catalyst app as expected. Now we want to port the extension to Chrome and other browsers on the desktop and retain the ability to pass messages back and forth. My questions: Is it possible ? Can we pass messages form the Chrome extension and the Mac Catalyst app? How do we distribute/install the Chrome extension? Can we have the extension running in parallel across multiple browsers and still communicate the Mac Catalyst app ?
Posted
by
Post not yet marked as solved
0 Replies
401 Views
Hi, we prepared Mac Catalyst version for our iOS app. We used same bundle id, so that according to documentation, all in app purchases and subscriptions should work. It works when we testing it agains testing in app subscription server. However, when we sent app to review, we got feedback, that inapp subscriptions doesn't work and from the screenshots from reviewer it looks like they are not available at all (the app even didn't show prices for inapp purchases). Is there anything I have to do to have existing subscriptions available for Mac Catalyst app? I didn't see any settings, so I thought it will work automatically, but it doesn't. Thanks,
Posted
by