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

110 Posts
Sort by:
Post not yet marked as solved
1 Replies
1k Views
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.
Posted Last updated
.
Post not yet marked as solved
1 Replies
404 Views
I have a button in my iOS app that opens the Settings app to my app's Notification permissions section. I use UIApplicationOpenSettingsURLString for this (or UIApplicationOpenNotificationSettingsURLString on iOS 15.4 and later). On Catalyst, both of these simply open the settings screen that is auto-generated from the Settings bundle. How do I get it to open to the appropriate place in System Settings?
Posted Last updated
.
Post not yet marked as solved
1 Replies
398 Views
List items do not appear to be moveable when they are contained within a popover on Mac Catalyst running on macOS Sonoma. Dragging and dropping a list item simply returns it to its original location, and onMove(preform:) is not called. The same happens using the drag handles with an EditButton() or .environment(\.editMode, .constant(.active)). Below is a reproducible sample which, to my knowledge, worked as expected on Ventura. It also currently works as expected on iPad. Changing the popover to a sheet makes it work on Mac Catalyst, but then, the view takes up a lot of unnecessary space. Does anyone have any good workarounds for this issue? struct ContentView: View { @State private var isShowingPopover = false @State private var items = ["one", "two", "three"] var body: some View { Button("Show Popover") { isShowingPopover = true } .popover(isPresented: $isShowingPopover) { List { ForEach(items, id: \.self) { item in Text(item) } .onMove { fromOffsets, toOffset in items.move(fromOffsets: fromOffsets, toOffset: toOffset) } } .frame(minWidth: 300, minHeight: 270) } } }
Posted
by caleb_ras.
Last updated
.
Post not yet marked as solved
0 Replies
306 Views
With Mac Catalyst, in Big Sur and Monterey, you could use UICommandTagShare as the property list for a UICommand in combination with activityItemsConfiguration and itemProvidersForActivityItemsConfiguration to allow a "Share" submenu to appear in a menu in your app (for instance, under the File menu like many other apps). Starting in Ventura, this submenu no longer appears with that same code, and instead the UICommandTagShare command in the menu now just displays "Share" with no submenu, which triggers a UIActivityViewController to appear in the main window. Is there any way to still allow a Share submenu to work in Ventura and beyond with Mac Catalyst? Thanks so much for any help!
Posted
by Triglyph.
Last updated
.
Post marked as solved
2 Replies
694 Views
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?
Posted Last updated
.
Post not yet marked as solved
2 Replies
529 Views
Hello, is there a recommended way to render Menu items, e.g in a SwiftUI ContextMenu with icon (SFSymbols)? Let's say I have the following setup: Both buttons render fine on native macOS (e.g Sonoma) but Catalyst refuses to render the symbol at all. I tried every possible combination I could think off. The only way I found was to directly copy and paste a symbol from the SF symbols app and inline it with the label string as unicode. Unfortunately I have a couple custom SF symbols so this isn't really an option for me. I feel like this is a perfectly valid usecase, as it makes the menu visually a lot easier scannable. With UIKit and Ventura this at least worked for Menubar items but now also seems broken on Sonoma. I would greatly appreciate any hints. Thanks!
Posted Last updated
.
Post not yet marked as solved
1 Replies
495 Views
Can not select anything within WkWebView editor view of my MacCatalyst app when running on macOS 14 Sonoma. Any selection gesture or command key fails to select anything in content editable WKWebView, so none of the Editor tools can be activated. My application uses the nnhubbard / ZSSRichTextEditor WKWebView-based Rich Text Editor: https://github.com/nnhubbard/ZSSRichTextEditor. The app is built with Xcode 15.0 or 15.0.1. The app is a Catalyst app that implements an editor view with a ZSSRichTextEditor WKWebView. The problem does not occur if the the app is run in iOS or macOS 11, 12, or 13 (Catalina, Monterey, or Ventura.) The issue only occurs in macOS 14 Sonoma.
Posted Last updated
.
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.
Posted Last updated
.
Post not yet marked as solved
1 Replies
565 Views
Is anyone else running into an issue with navigation bar titles in Catalyst app being shown higher up than normal when presented as a modal sheet under Sonoma (see screenshot)? I tried adjusting the titlePositionAdjustment for the appearance, but this only affects the title and not any buttons that may be in the navigation bar, making them uneven. Any suggestions would be helpful as I'm at my wits end on this one.
Posted
by Enderlyn.
Last updated
.
Post not yet marked as solved
1 Replies
376 Views
It appears that we are not able to reorder rows in our tables when running our iOS/iPadOS app under Mac Catalyst. It appears that all the delegate methods are returning true indicating the row can be moved and edited. The reordering handles appear in editing move and the row can be moved around (also using drag and drop) but the user interface is not indicating that the row can be dropped to be reordered. It's as if the proposed destination path is being rejected. I tried setting up that delegate method (thinking that maybe the default for that is messed up on Mac Catalyst) but it had no effect. Every table in our system performs this way. Here is a link to an example video that shows the table view not working: https://onsongapp.s3.amazonaws.com/Reordering%20Example.mp4 Please advise if there is something else that needs to be implemented or changed for Mac Catalyst to properly handle table cell reordering.
Posted
by jkichline.
Last updated
.
Post marked as solved
5 Replies
1.4k Views
I get the following message when I try to run this app in Xcode. Could not launch AppName. Runningboard has returned error 5. Please check the system logs for the underlying cause of the error. Interestingly, the destination Mac (Mac Catalyst) destination does launch. The funny thing is there is a companion app almost exactly like this one that launches fine. Any help with this would be greatly appreciated. Xcode helped me to file a feedback. The number is FB13206919.
Posted
by SpaceMan.
Last updated
.
Post marked as solved
4 Replies
575 Views
I have a Mac Catalyst App that I switched over to the SwiftUI lifecycle. I am trying to add MenuBarExtra to the app : if #available(macOS 13.0, *) { MenuBarExtra("....", systemImage: ......) { .......... } } However, I get an error : 'init(_:systemImage:content:)' is unavailable in iOS 'MenuBarExtra' is unavailable in iOS How do I add MenuBarExtra to the app?
Posted
by girishw.
Last updated
.
Post not yet marked as solved
4 Replies
511 Views
I have a WKWebView that sets the UIDelegate: self.webView.UIDelegate = self; The following methods are never called when I right click in the WKWebView to being up a context menu: -(void)webView:(WKWebView*)webView contextMenuForElement:(WKContextMenuElementInfo*)elementInfo willCommitWithAnimator:(id <UIContextMenuInteractionCommitAnimating>)animator -(void)webView:(WKWebView*)webView contextMenuConfigurationForElement:(WKContextMenuElementInfo*)elementInfo completionHandler:(void (^)(UIContextMenuConfiguration * _Nullable configuration))completionHandler - (void)webView:(WKWebView *)webView contextMenuDidEndForElement:(WKContextMenuElementInfo *)elementInfo; This is from a Mac Catalyst app (I'm on macOS 14.0 23A344)
Posted Last updated
.
Post not yet marked as solved
1 Replies
591 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 kjkjkjkjk.
Last updated
.
Post not yet marked as solved
0 Replies
435 Views
I have a Swift Package Build Tool Plugin to generate localizations and design tokens, which looks like this currently. // Copyright © 2023 MEGA Limited. All rights reserved. import PackagePlugin @main struct GenerateTokenBuildTool: BuildToolPlugin { func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] { guard let target = target as? SourceModuleTarget else { return [] } return try target.sourceFiles(withSuffix: "xcassets").map { assetCatalog in let base = assetCatalog.path.stem let input = assetCatalog.path let output = context.pluginWorkDirectory.appending(["\(base).swift"]) // Use this when archiving for MacCatalyst let tool = try context.tool(named: "AssetTokenGenerator").path let toolName = tool.lastComponent let path = tool.removingLastComponent() let macPath = path.removingLastComponent().appending(subpath: path.lastComponent + "-maccatalyst") let executable = macPath.appending(subpath: toolName) // // Use this when archiving for iOS/iPadOS // let executable = try context.tool(named: "AssetTokenGenerator").path return .buildCommand( displayName: "Generating tokens for \(base).xcassets", executable: executable, arguments: [input.string, output.string], inputFiles: [input], outputFiles: [output] ) } } } If you notice, I need to do a bit of manual bug fixing when determining the path of my executable. When building for Mac Catalyst, context.tool(named:).path is pointing to an incorrect folder, thus failing the build for my project with this error: Command PhaseScriptExecution failed with a nonzero exit code sandbox-exec: execvp() of '//Users/mega-jfe/Library/Developer/Xcode/DerivedData/MEGAVPN-efdcwfcaosxfvneqjuvhrvdmbkax/Build/Products/Debug/AssetTokenGenerator' failed: No such file or directory It's suppposed to be using the Debug-maccatalyst folder, but Xcode is pointing the path to Debug. I feel like this is a bug, or else please let me know how I can handle this so that I can build for both without manually changing the code when building for Catalyst. Thanks!
Posted
by mega_jfe.
Last updated
.
Post not yet marked as solved
5 Replies
625 Views
Hello! New to swift development. I've created a very basic iOS app that uses the network extension to block web domains. Now, I am trying to make it work on a macOS using Mac Catalyst. However, when I build the project, I get this error: 2023-09-08 23:31:32.540010+0600 controlShift[69583:2468143] [Metadata] unable to get a dev_t for store 1795162192. 2023-09-08 23:31:33.986014+0600 controlShift[69583:2467453] [] -[NEFilterManager saveToPreferencesWithCompletionHandler:]_block_invoke_3: failed to save the new configuration: (null) The app launches and the UI works correctly. However, it fails to save the preference as stated in the error, so it does not block anything. Here is the relevant part of the code in the root file: var body: some Scene { WindowGroup { ContentView() .environment(\.managedObjectContext, persistenceController.container.viewContext) .onAppear { NEFilterManager.shared().loadFromPreferences { error in if let loadError = error { print("Failed to load the filter configuration: \(loadError)") return } } DispatchQueue.main.asyncAfter(deadline: .now()+1.5) { if NEFilterManager.shared().providerConfiguration == nil { let newConfiguration = NEFilterProviderConfiguration() newConfiguration.username = "UserName" newConfiguration.organization = "myApp " newConfiguration.filterBrowsers = true newConfiguration.filterSockets = true newConfiguration.serverAddress = "http://192.168.100.48:3000" NEFilterManager.shared().providerConfiguration = newConfiguration } NEFilterManager.shared().isEnabled = true NEFilterManager.shared().saveToPreferences { error in if let saveError = error { print("Failed to save the filter configuration: \(saveError)") } } } } } I'm at a loss for what is wrong. Lmk if you need additional details. Thanks! btw, I am very new to swift and iOS/macOS development in general so if there's a better way to write or structure the logic inside the "onAppear" method (of which I'm sure there is), lmk as well. ^_^
Posted
by stilakid.
Last updated
.
Post not yet marked as solved
0 Replies
553 Views
This is verified to be a framework bug (occurs on Mac Catalyst but not iOS or iPadOS), and it seems the culprit is AVVideoCompositionCoreAnimationTool? /// Exports a video with the target animating. func exportVideo() { let destinationURL = createExportFileURL(from: Date()) guard let videoURL = Bundle.main.url(forResource: "black_video", withExtension: "mp4") else { delegate?.exporterDidFailExporting(exporter: self) print("Can't find video") return } // Initialize the video asset let asset = AVURLAsset(url: videoURL, options: [AVURLAssetPreferPreciseDurationAndTimingKey: true]) guard let assetVideoTrack: AVAssetTrack = asset.tracks(withMediaType: AVMediaType.video).first, let assetAudioTrack: AVAssetTrack = asset.tracks(withMediaType: AVMediaType.audio).first else { return } let composition = AVMutableComposition() guard let videoCompTrack = composition.addMutableTrack(withMediaType: AVMediaType.video, preferredTrackID: Int32(kCMPersistentTrackID_Invalid)), let audioCompTrack = composition.addMutableTrack(withMediaType: AVMediaType.audio, preferredTrackID: Int32(kCMPersistentTrackID_Invalid)) else { return } videoCompTrack.preferredTransform = assetVideoTrack.preferredTransform // Get the duration let videoDuration = asset.duration.seconds // Get the video rect let videoSize = assetVideoTrack.naturalSize.applying(assetVideoTrack.preferredTransform) let videoRect = CGRect(origin: .zero, size: videoSize) // Initialize the target layers and animations animationLayers = TargetView.initTargetViewAndAnimations(atPoint: CGPoint(x: videoRect.midX, y: videoRect.midY), atSecondsIntoVideo: 2, videoRect: videoRect) // Set the playback speed let duration = CMTime(seconds: videoDuration, preferredTimescale: CMTimeScale(600)) let appliedRange = CMTimeRange(start: .zero, end: duration) videoCompTrack.scaleTimeRange(appliedRange, toDuration: duration) audioCompTrack.scaleTimeRange(appliedRange, toDuration: duration) // Create the video layer. let videolayer = CALayer() videolayer.frame = CGRect(origin: .zero, size: videoSize) // Create the parent layer. let parentlayer = CALayer() parentlayer.frame = CGRect(origin: .zero, size: videoSize) parentlayer.addSublayer(videolayer) let times = timesForEvent(startTime: 0.1, endTime: duration.seconds - 0.01) let timeRangeForCurrentSlice = times.timeRange // Insert the relevant video track segment do { try videoCompTrack.insertTimeRange(timeRangeForCurrentSlice, of: assetVideoTrack, at: .zero) try audioCompTrack.insertTimeRange(timeRangeForCurrentSlice, of: assetAudioTrack, at: .zero) } catch let compError { print("TrimVideo: error during composition: \(compError)") delegate?.exporterDidFailExporting(exporter: self) return } // Add all the non-nil animation layers to be exported. for layer in animationLayers.compactMap({ $0 }) { parentlayer.addSublayer(layer) } // Configure the layer composition. let layerComposition = AVMutableVideoComposition() layerComposition.frameDuration = CMTimeMake(value: 1, timescale: 30) layerComposition.renderSize = videoSize layerComposition.animationTool = AVVideoCompositionCoreAnimationTool( postProcessingAsVideoLayer: videolayer, in: parentlayer) let instructions = initVideoCompositionInstructions( videoCompositionTrack: videoCompTrack, assetVideoTrack: assetVideoTrack) layerComposition.instructions = instructions // Creates the export session and exports the video asynchronously. guard let exportSession = initExportSession( composition: composition, destinationURL: destinationURL, layerComposition: layerComposition) else { delegate?.exporterDidFailExporting(exporter: self) return } // Execute the exporting exportSession.exportAsynchronously(completionHandler: { if let error = exportSession.error { print("Export error: \(error), \(error.localizedDescription)") } self.delegate?.exporterDidFinishExporting(exporter: self, with: destinationURL) }) } Not sure how to implement a custom compositor that performs the same animations as this reproducible case: class AnimationCreator: NSObject { // MARK: - Target Animations /// Creates the target animations. static func addAnimationsToTargetView(_ targetView: TargetView, startTime: Double) { // Add the appearance animation AnimationCreator.addAppearanceAnimation(on: targetView, defaultBeginTime: AVCoreAnimationBeginTimeAtZero, startTime: startTime) // Add the pulse animation. AnimationCreator.addTargetPulseAnimation(on: targetView, defaultBeginTime: AVCoreAnimationBeginTimeAtZero, startTime: startTime) } /// Adds the appearance animation to the target private static func addAppearanceAnimation(on targetView: TargetView, defaultBeginTime: Double = 0, startTime: Double = 0) { // Starts the target transparent and then turns it opaque at the specified time targetView.targetImageView.layer.opacity = 0 let appear = CABasicAnimation(keyPath: "opacity") appear.duration = .greatestFiniteMagnitude // stay on screen forever appear.fromValue = 1.0 // Opaque appear.toValue = 1.0 // Opaque appear.beginTime = defaultBeginTime + startTime targetView.targetImageView.layer.add(appear, forKey: "appear") } /// Adds a pulsing animation to the target. private static func addTargetPulseAnimation(on targetView: TargetView, defaultBeginTime: Double = 0, startTime: Double = 0) { let targetPulse = CABasicAnimation(keyPath: "transform.scale") targetPulse.fromValue = 1 // Regular size targetPulse.toValue = 1.1 // Slightly larger size targetPulse.duration = 0.4 targetPulse.beginTime = defaultBeginTime + startTime targetPulse.autoreverses = true targetPulse.repeatCount = .greatestFiniteMagnitude targetView.targetImageView.layer.add(targetPulse, forKey: "pulse_animation") } }
Posted Last updated
.
Post not yet marked as solved
2 Replies
570 Views
Prior to macOS 14, a Catalyst app could present a UIAlertController as a popover, just as you can on the iPad. While this still works on the iPad, the presentation on macOS now uses the same style as the iPhone. The UIAlertController's popoverPresentationController property is always nil, no matter how it is configured. Doe anyone know of a way to restore the prior behavior under Sonoma?
Posted
by Enderlyn.
Last updated
.
Post not yet marked as solved
4 Replies
834 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).
Posted Last updated
.