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

112 Posts
Sort by:
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
1k 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
841 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
3 Replies
1.3k 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
1.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
598 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
803 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
635 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
567 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
949 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 marked as solved
3 Replies
875 Views
While working on the Mac Catalyst version of my iOS app, I noticed something interesting. I have a UITextView with the allowsEditingTextAttributes property enabled. When running the app on a Mac, the context menu that appears when right-clicking inside the UITextField includes the menu item "Import from iPhone or iPad". That brings up a menu with 3 options each for my iPhone and iPad that I happen to connected to my Mac recently. There options include "Take Photo", "Scan Documents", and "Add Sketch". I created a brand new iOS app project and simply added a UITextView to the main view controller. After setting allowsEditingTextAttributes to true, it shows the same behavior. Some questions: Is this documented anywhere? I'm guessing this is related to Continuity Camera in some way. But there's no mention of this anywhere that I've seen so far. How can I prevent this menu from appearing? Nothing related to these menus comes through the canPerformAction(_:withSender:) method. And nothing related to these menus is part of the menu item array sent to the UITextViewDelegate textView(_:editMenuForTextIn:suggestedActions:) method. I need to remove this menu in my app because while I support some text attributes (bold, italic, underline), I do not want to allow pictures to be added. Does anything else in iOS under Mac Catalyst automatically get similar support? If so, what?
Posted
by
Post marked as solved
2 Replies
902 Views
I'm experimenting with getting my AUv3 plugins working correctly on iOS and MacOS using Catalyst. I'm having trouble getting the plugin windows to look right in Logic Pro X on MacOS. My plugin is designed to look right in Garageband's minimal 'letterbox' layout (1024x335, or ~1:3 aspect ratio) I have implemented supportedViewConfigurations to help the host choose the best display dimensions On iOS this works, although Logic Pro iPad doesn't seem to call supportedViewConfigurations at all, only Garageband does. On MacOS, Logic Pro does call supportedViewConfigurations but only provides oversized screen sizes, making the plugins look awkward. I can also remove the supportedViewConfigurations method on MacOS, but this introduces other issues: I guess my question boils down to this: how do I tell Logic Pro X on MacOS what the optimal window size of my plugin is, using Mac Catalyst?
Posted
by
Post not yet marked as solved
0 Replies
820 Views
Hello, I have my largely iOS app running using Mac Catalyst, but I need to limit what Macs will be able to install it from the Mac App Store based on the GPU Family like MTLGPUFamily.mac2. Is that possible? Or I could limit it to Apple Silicon using the Designed for iPad target, but I would prefer to use Mac Catalyst instead of Designed for iPad. Is it possible to limit Mac Catalyst installs to Apple Silicon Macs? Side question: what capabilities are supported by MTLGPUFamily.mac2? I can't find it. My main interest is in CoreML inference acceleration. Thank you.
Posted
by
Post not yet marked as solved
0 Replies
852 Views
Hi according to the documentation we can have Message extensions in Mac Catalyst 14+, and that the MSStickerBrowserView is supported from Mac Catalyst 13.1+. But it doesn't seem possible to actually build an extension app, or Sticker extension, embedded in a Mac Catalyst app and have it appear in macOS messages. Error: iMessage Applications are not available when building for Mac Catalyst. and error: iMessage / Sticker Pack extensions are not available when building for Mac Catalyst. With the announcement for macOS Sonoma that the Stickers will be available in Mac Messages, is this finally going to be possible? If this isn't possible, why is there support for Mac Catalyst?
Posted
by
Post not yet marked as solved
0 Replies
657 Views
I am new in the MAC Catalyst development. I have one application that is developed by using electronjs. This app is having the functionality of SIP/VoIP. Audio/Video calling works well. But I want to implement the screen sharing functionality. I have tried to implement it but I was not able to do it. I have tried the below stuff: navigator.mediaDevices.getUserMedia(options) : It was giving error "Uncaught (in promise) DOMException: Not supported". desktopCapturer.getSources : Not able to get streams. I have written the logic to get streams in the preload.js file. I am not able to get streams and suppose in case, I have got the streams, How can I load that on the video element that is not rendered yet? Because the preload file is executed before the loading of the window. So It's giving the error 'Cant read property 'srcObject' of undefined''. ipcRenderer & ipcMain : Giving the same result as above. AVFoundation : Only working for the mobile apps. So my question is, Is there any way to share the screen in the MAC Catalyst apps by using electronjs or by using any other way? If so, Please refer.
Posted
by
Post not yet marked as solved
0 Replies
734 Views
I have electronjs app for the MAC Catalyst. I have implemented audio/video calling functionalities. Those works well. I have also implemented functionality to share the screen by using below code. navigator.mediaDevices.getDisplayMedia(options).then((streams) => { var peer_connection = session.sessionDescriptionHandler.peerConnection; var video_track = streams.getVideoTracks()[0]; var sender_kind = peer_connection.getSenders().find((sender) => { return sender.track.kind == video_track.kind; }); sender_kind.replaceTrack(video_track); video_track.onended = () => { }; }, () => { console.log("Error occurred while sharing screen"); } ); But when I hit the button to share the screen by using above code, I am getting below error. Uncaught (in promise) DOMException: Not supported I have also tried navigator.getUserMedia(options,success,error). It's supported by the Mac Catalyst desktop apps. But it's only giving the streams of the webcam. I have also checked online if navigator.mediaDevices.getDisplayMedia(options) is supported in the Mac Catalyst or not. It's supports in the Mac Catalyst. But still I am facing this issue. I have also tried with the desktopCapturer API of the electronjs. But I don't know how can I get the streams from it. //CODE OF 'main.js' ipcMain.on("ask_permission", () => { desktopCapturer .getSources({ types: ["window", "screen"] }) .then(async (sources) => { for (const source of sources) { // console.log(source); if (source.name === "Entire screen") { win.webContents.send("SET_SOURCE", source.id); return; } } }); }); I have tried to get streams by using the below code in the preload.js. But I was getting the error Cannot read property 'srcObject' of undefined. window.addEventListener("DOMContentLoaded", (event) => { ipcRenderer.on("SET_SOURCE", async (event, sourceId) => { try { const stream = await navigator.mediaDevices.getUserMedia({ audio: false, video: { mandatory: { chromeMediaSource: "desktop", chromeMediaSourceId: sourceId, minWidth: 1280, maxWidth: 1280, minHeight: 720, maxHeight: 720, }, }, }); handleStream(stream); } catch (e) { handleError(e); } }); let btn = document.getElementById("btnStartShareOutgoingScreens"); btn.addEventListener("click", () => { if (isSharing == false) { ipcRenderer.send("ask_permission"); } else { console.error("USer is already sharing the screen.............."); } }); }); function handleStream(stream) { const video = document.createElement("video"); video.srcObject = stream; video.muted = true; video.id = "screenShareVideo"; video.style.display = "none"; const box = document.getElementById("app"); box.appendChild(video); isSharing = true; } How can I resolve it. If this is not supported in the MAC Catalyst, Is there is any other way to share the screen from the MAC Catalyst app by using WebRTC.
Posted
by
Post marked as solved
1 Replies
909 Views
I have a brand new macOS app (built with Mac Catalyst and based on a long existing iOS app) I've submitted to App Store Connect for review. It was rejected due to my Contacts purpose string not being deemed sufficient (despite being the same one the iOS version of the app has been using for years). Anyway, I made a change to the privacy string and submitted a new build. The new build was rejected and a screenshot showed the About screen with the new build number as well as the privacy string from the original build, not the new build. So I verified that my archive did in fact have an Info.plist with the updated privacy string. So I resubmitted that build again for review and it was rejected again for the same reason. Despite the reviewer claiming, at my request, that a fresh install of the latest build was used. So I changed the privacy string again and submitted a 3rd new build, again verifying the archive that I was sending through the Xcode Organizer did have the updated (now 3rd) privacy string. And again the app has been rejected. Despite 2 new builds, the reviewers are still seeing the original privacy string. Does anyone have any ideas on how to get this resolved?
Posted
by