Mac Catalyst

RSS for tag

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

Posts under Mac Catalyst tag

110 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Sequoia Group Container for Mac Catalyst Apps
Prior to Sequoia, Mac Catalyst Apps worked fine when using group folders that started with group. They now get an alert that the Mac Catalyst app is trying to access data from other applications. This may also impact some SwiftUI developers. According to this the documentation for the App Group Entitlements entitlement, on macOS we should begin use the Team Identifier instead of group. Should Mac Catalyst follow the macOS or iOS rules for com.apple.security.application-groups? If they should need to follow the macOS rules now, that creates several issues for developers. We would now need separate build targets to pick up the different Entitlements files. More distressing is that we would need to do some kind of migration process to get our files to the new location. There wouldn't be a transparent way to do so where the user wasn't warned about the application accessing files that don't belong to it. Any clarification on what Mac Catalyst developers should be doing to prepare for Sequoia would be greatly appreciated.
0
0
65
4d
UIKit MacCatalyst - How to drag a table view item to Finder to create a folder of items
I have a UITableView that displays a Group/Note hierarchy analogous to a Finder Folder/Files hierarchy. I have implemented Drag and Drop such that if I drag a Note to the Finder Desktop an HTML file is created of the Note, and if I drag a Group to the Finder Desktop a Text file is created of the Group's title. Here is the Helper Dragging extension that I've implemented: // // Model+Dragging.swift // /* Abstract: Helper methods for providing and consuming drag-and-drop data. */ import UIKit import MobileCoreServices // Conditionalize Drag and Drop so it is not in iOS target. #if targetEnvironment(macCatalyst) extension Model { /** A helper function that serves as an interface to the data model, called by the implementation of the `tableView(_ canHandle:)` method. */ func canHandle(_ session: UIDropSession) -> Bool { // In order to enable dragging all text type files changed the class // loadable objects from NSString to my custom TEXTClass. return session.canLoadObjects(ofClass: TEXTClass.self) } /** A helper function that serves as an interface to the data model, called by the `tableView(_:itemsForBeginning:at:)` method. */ func dragItems(for indexPath: IndexPath) -> [UIDragItem] { let itemProvider = NSItemProvider() let item = self.getDisplayItem(for: indexPath.row) if item is Note { let note:Note = item as! Note let html = note.noteHTML let data = html?.data(using: .utf8) // Drag to finder creates an html file. itemProvider.suggestedName = note.title + ".html" itemProvider.registerDataRepresentation(forTypeIdentifier: kUTTypeData as String, visibility: .all) { completion in completion(data, nil) return nil } } else { let group:Group = item as! Group let title = group.title let data = title?.data(using: .utf8) // Drag to finder creates a text file. itemProvider.suggestedName = group.title + ".text" itemProvider.registerDataRepresentation(forTypeIdentifier: kUTTypeData as String, visibility: .all) { completion in completion(data, nil) return nil } } return [ UIDragItem(itemProvider: itemProvider) ] } } #endif I would now like to change the result of dragging a Group to the Finder. Instead of creating a Text file from the drag data, I would like to create a Folder containing the Group's Notes. Note: I am unconcerned with the task of assembling the Group/Notes hierarchies as Folder/Files hierarchies because I already have implemented such previously as a menu export command. My concern is where and how I can communicate it to the Finder in the Drag and Drop process. As a first step I thought I would simply create an empty folder from the drag of a Group. So far, none of my experiments have been successful. Every variation of itemProvider.registerDataRepresentation(forTypeIdentifier: or itemProvider.registerFileRepresentation(forTypeIdentifier: or registerItem(forTypeIdentifier:loadHandler: that I have tried has failed to produce anything but empty TEXT files, if they worked at all. It is my understanding that itemProviders may provide directories instead of files, but I have been unable to find any examples of such. My problem may be a lack of understanding of the syntax and usage of the NSItemProvider.LoadHandler completion block. Any Swift examples on point would be greatly appreciated!
0
0
64
4d
Bluetooth audio becomes choppy on iOS with entitlement error but works just fine on MacCatalyst
I am converting some old objective-C code deployed on ios 12 to swift in a WKWebView app. Im also developing the app for Mac via MacCatalyst. the issue im experiencing relates to a programmable learning bot that is programmed via block coding and the app facilitates the read and writes back and forth. the audio works via a A2DP connection the user sets manually in their settings, while the actual movement of the robot is controlled via a BLE connection. Currently the code works as intended on MacCatalyst, while on iPhone, the audio being sent back to the robot is very choppy and sometimes doesn't play at all. I apologize for the length of this, but there is a bit to unpack here. First, I know there has been a few threads posted about this issue, this one that seems similar but went unsolved https://forums.developer.apple.com/forums/thread/740354 as well as this one where apple says it is "log noise" https://forums.developer.apple.com/forums/thread/742739 However I just find it hard to believe that this issue seems to be log noise in this case. Mac Catalyst uses a legacy header file for WebKit, and im wondering if that could be part of the issue here.I have enable everything relating to bluetooth in my info plist file as the developer documents say. In my app sandbox for mac catalyst I have the permissions set for bluetooth as well there. Here are snippets of my read and write function func readFunction(session: String){ // Wait if we are still waiting to hear from the robot if self.serialRxBuf == ""{ self.emptyReadCount += 1 } if (!self.serialRxWaiting){ return } // Make sure we are waiting for the correct session if (Int(session) != self.serialRxSession){ return } self.serialRxWaiting = false self.serialRxSession += 1 let buf = self.serialRxBuf self.serialRxBuf = "" print("sending Read: \(buf)") self.MainWebView.evaluateJavaScript(""" if (serialPort.onRead) { serialPort.onRead("\(buf)"); } serialPort.onRead = null; """ ,completionHandler: nil) } // ----- Write function for javascript bluetooth interface ----- func writeFunction(buf: String) -> Bool { emptyReadCount = 0 if((self.blePeripheral == nil) || (self.bleCharacteristic == nil) || self.blePeripheral?.state != .connected){ print("write result: bad state, peripheral, or connection ") // in case we recieve an error that will freeze react side, safely navigate and clear bluetooth information. if MainWebView.canGoBack{ MainWebView.reload() showDisconnectedAlert() self.centralManager = nil // we will just start over next time self.blePeripheral = nil self.bleCharacteristic = nil self.connectACD2Failed() return false } return false } var data = Data() var byteStr = "" for i in stride(from: 0, to: buf.count, by: 2) { let startIndex = buf.index(buf.startIndex, offsetBy: i) let endIndex = buf.index(startIndex, offsetBy: 2) byteStr = String(buf[startIndex..<endIndex]) let byte = UInt8(byteStr, radix: 16)! data.append(byte) } guard let connectedCharacteristic = self.bleCharacteristic else { print("write result: Failure to assign bleCharacteristic") return false } print("sending bleWrite: \(String(describing: data))") self.blePeripheral.writeValue(data, for: connectedCharacteristic, type: .withoutResponse) print("write result: True") return true } Here is what the log looks like when running on mac catalyst, which works just fine sending bleWrite: 20 bytes write result: True sending Read: sending Read: 55AA55AA0B0040469EE6000000000000000000ED sending bleWrite: 20 bytes write result: True sending Read: sending Read: sending Read: 55AA55AA0B0040469EE6000000000000000000ED sending bleWrite: 20 bytes write result: True sending Read: 55AA55AA0B0040469EE6000000000000000000ED sending bleWrite: 20 bytes write result: True sending Read: 55AA55AA0B0040EDCB09000000000000000000ED sending bleWrite: 20 bytes write result: True sending Read: sending Read: 55AA55AA0B00407A7B96000000000000000000ED sending bleWrite: 20 bytes write result: True Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "(originator doesn't have entitlement com.apple.runningboard.assertions.webkit AND originator doesn't have entitlement com.apple.multitasking.systemappassertions)" UserInfo={NSLocalizedFailureReason=(originator doesn't have entitlement com.apple.runningboard.assertions.webkit AND originator doesn't have entitlement com.apple.multitasking.systemappassertions)}> 0x12c0380e0 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebKit Media Playback' for process with PID=36540, error: Error Domain=RBSServiceErrorDomain Code=1 "(originator doesn't have entitlement com.apple.runningboard.assertions.webkit AND originator doesn't have entitlement com.apple.multitasking.systemappassertions)" UserInfo={NSLocalizedFailureReason=(originator doesn't have entitlement com.apple.runningboard.assertions.webkit AND originator doesn't have entitlement com.apple.multitasking.systemappassertions)} and here is the log from when we are running the code on iPhone (trying to save space here) I apologize for the length of this post, however submitting a test project to apple developer support just isn't possible with the device thats in use. Any help at all is appreciated. i've looked at every permission, entitlement, background processing, and tried every solution that I could find to no avail.
0
0
190
5d
IOSurface vs. IOSurfaceRef on Catalyst
I have an IOSurface and I want to turn that into a CIImage. However, the constructor of CIImage takes a IOSurfaceRef instead of a IOSurface. On most platforms, this is not an issue because the two types are toll-free bridgeable... except for Mac Catalyst, where this fails. I observed the same back in Xcode 13 on macOS. But there I could force-cast the IOSurface to a IOSurfaceRef: let image = CIImage(ioSurface: surface as! IOSurfaceRef) This cast fails at runtime on Catalyst. I found that unsafeBitCast(surface, to: IOSurfaceRef.self) actually works on Catalyst, but it feels very wrong. Am I missing something? Why aren't the types bridgeable on Catalyst? Also, there should ideally be an init for CIImage that takes an IOSurface instead of a ref.
2
1
88
5d
Change in title bar behavior in Catalyst app when building under Xcode 16
I'm running into a change in behavior with the title bar when building our Catalyst app under Xcode 16 versus what we are seeing with the same code built under Xcode 15. The title bar is hidden, as it should be in the Xcode 15 build. However, when building the same project under Xcode 16, the title bar is shown with the center contents of the navigation bar in the right pane being duplicated in the title bar (see screenshot at the end), which is undesirable. The screenshots for both builds were taken in macOS Sequoia Beta Seed 1. The Catalyst Interface setting is configured to "Optimize for Mac" in the project file. The scene's titlebar.titleVisibility property is set to .hidden, titlebar.toolbar is set to nil. UINavigationBar's appearance is configured with a preferredBehaviorStyle of .pad when running under Catalyst 16 or later. Is this a bug or am I missing a flag or something that was introduced to Catalyst/UIKit that I've overlooked? I've also filed a feedback for this issue: FB14000006. Thank you for your time.
0
0
100
1w
Transition MacCatalyst App to "Designed for iPad"
I currently have a universal app that uses MacCatalyst. I want to update the Mac app to use "Designed for iPad". I know Intel Macs won't be able to download the updated version, but will current Intel app users be able to restore the download version they had, (ie. a clean os install)? Will new intel users be able to download the previous catalyst version, or is it removed from the store completely?
0
0
135
1w
Running a Catalyst application via XCTest loads macOS specific frameworks
When trying to test a Catalyst application with XCTest the application crashes at startup with Symbol not found error when certain frameworks are in use. This is caused by XCTest / Xcode adding /Applications/Xcode.app/Contents/SharedFrameworks to DYLD_FRAMEWORK_PATH causing dyld to load the macOS specific framework variant of for example RealityKit instead from /System/iOSSupport/System/Library/Frameworks as defined in the load commands. Which leads to symbol mismatches, for example ARView.Environment.Color is a UIColor on Mac Catalyst but an NSColor on macOS (_$s10RealityKit6ARViewC11EnvironmentV10BackgroundV5coloryAGSo7UIColorCFZ vs. _$s10RealityKit6ARViewC11EnvironmentV10BackgroundV5coloryAGSo7NSColorCFZ) Tried prepending /System/iOSSupport/System/Library/Frameworks to the DYLD_FRAMEWORK_PATH env var of the test target, but via some private frameworks still wrong framework variants were loaded. Any ideas for possible fixes or workarounds?
8
0
312
May ’24
Spelling/grammar check settings persistence in UITextView on Mac Catalyst
In our Mac Catalyst app running on macOS, the Edit > Spelling and Grammar > Check Spelling While Typing, Check Grammar With Spelling, and Correct Spelling Automatically preferences are reset with each opening of a new text view. How can we make those preferences persistent? Ie, when someone changes those settings for our app's text view, other incarnations of our app's text views should respect the latest preferences. We looked at swizzling NSTextView's toggleAutomaticSpellingCorrection:, saving those to NSUserDefaults, and then reading those preferences when we set up our UITextView subclass, and then setting the UITextInputTraits properties accordingly. However, our approach felt heavy handed, and I'm wondering if we are missing some out-of-the-box functionality that will make those preferences intuitively persistent. Does anyone have any suggestions? Thank you.
0
0
266
May ’24
Cannot build app on Catalyst after updating to Xcode 15.4 RC
We are facing an issue on Catalyst when building our app using Xcode 15.4. The issue is related to precompiled frameworks and seems to be widespread as it happens with multiple vendors (like Firebase or Braze). We are using SPM to add these dependencies, for instance: .package(url: "https://github.com/braze-inc/braze-swift-sdk", from: "8.2.1"), When building, we get the following error: clang:1:1: invalid version number in '-target arm64-apple-ios10.15-macabi' Our macOS deployment target is 12.3. Our iOS deployment target is 15.4. I will try to create a reproducer I can share but I wanted to share this in case there's a known workaround. Thanks in advance!
9
6
1.4k
2w
In Mac Catalyst, what would be the simplest way to hide the title bar but retain its double click functionality?
After adopting sidebar / split view controller support in Mac Catalyst, there are several UI side effects that make the default title bar stick out and look inconsistent. If I hide the title bar however, func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } #if targetEnvironment(macCatalyst) if let titlebar = windowScene.titlebar { titlebar.titleVisibility = .hidden titlebar.toolbar = nil } #endif } the ability to double click the top of the window to maximize it is lost. What would be the simplest approach to have both the hidden appearance, but keep the double click behavior?
0
0
271
May ’24
RTC Peer connection error when trying to accept live video call in WKWebView ran in Mac Catalyst
I am developing an WKWebView app that runs on both mobile and mac platforms using a react website. Currently, an admin user can send a call request in which the user gets a pop-up to answer. on iOS it works as intended, the user is asked to grant permission to utilize camera and microphone and the user is immediately connected upon accepting, however I never receive the pop-up when running in Mac Catalyst. I have ensured to enable permissions in sandbox settings as well as adding NSCamera and NSMic permissions in the property list. in the safari debugging console I receive this error upon clicking the accept call ReferenceError: Can't find variable: RTCPeerConnection Ive attempted to use the webview callback requestMediaCapturePermissionFor, and this did not seem to trigger on attempting to answer the call. Is this an error on my development end? or is this an issue I should look to the react code for a fix. I appreciate any feedback possible. Thanks.
0
0
258
May ’24
Unable to load MKMapView from AppKit bundle in Catalyst app
I am trying to load an auxiliary window from an AppKit bundle that loads a NSViewController from a storyboard. This NSViewController displays a MKMapView. I want to avoid supporting multiple windows from my Catalyst app so I do not want to load this window via a SceneDelegate, and that is why I have chosen to go the AppKit bundle route. If I load a similar view controller which contains a single label, then all works as expected. However, if I try to load a view controller with the MKMapView, I get the following error after crashing: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MKMapView nsli_piercingToken]: unrecognized selector sent to instance 0x15410f600' DropBox link to sample app with buttons on a view to select either the "Map View" (crashing) or the "Label View" (working): https://www.dropbox.com/scl/fi/q9daurhzqvil9o2ry6k1t/CatalystMap.zip?rlkey=yjbqfn6uxfrfh1jgsdavagta7&dl=0
2
0
353
May ’24
How can I make NSToolbar on Catalyst check canPerformAction on UISplitViewController's secondary view controller instead of primary?
I have a Catalyst app that I'm adding a sidebar to via UISplitViewController. I have a toolbar on the window with buttons that I want to be enabled or disabled based on the state of the view controller in the split view's secondary column. But it seems to want to check the primary view controller instead. In the Catalyst tutorial Adding a Toolbar, this exact approach is demonstrated. The RecipeDetailViewController has methods for toggleFavorite and editRecipe, and the toolbar items are set up to reference those selectors in the ToolbarDelegate class. In the screenshots in the tutorial, the buttons are shown as enabled based on RecipeDetailViewController.canPerformAction. But when I download and run the complete project on my computer (macOS 14.4.1), the toolbar items are disabled. And if I add the methods to the RecipeListViewController (which is in the primary column of the UISplitViewController, the toolbar items get enabled. Is there a way to make the system ask the correct split view column for canPerformAction? Or is this a bug?
0
0
236
Apr ’24
How can I put an NSToolbarItem on the leading edge of an NSToolbar in Catalyst?
I'm working to make my iOS app available via Catalyst, and I'm adding a leading-edge sidebar via UISplitViewController and putting a toggle button in the window toolbar to control it. I'd like that sidebar toggle button to go on the leading side of the toolbar, before the window title. In the Adding a Toolbar Catalyst tutorial, there are screenshots of this behavior: But when I download the finished project and run it on my machine (macOS 14.4), the toolbar buttons are clustered on the trailing edge: How do I achieve the behavior shown in the tutorial's screenshot, where the toggle sidebar button (or, ideally any custom toolbar item I choose) shows up on the leading edge? Even more ideally, is there a way I can make the sidebar toggle button show up in the header section for the sidebar, like it does in Xcode - right next to the stoplight buttons?
1
0
261
May ’24
AppKit/Mac Catalyst apps are being rejected by App Review for launching default web browser for login
New versions of AppKit/Mac Catalyst apps that use Google's Sign In framework are being rejected by App Store Review for the past two weeks. Reason shared was: The user is taken to the default web browser to sign in or register for an account, which provides a poor user experience. And also citing: Data Collection & Storage guidelines -> https://developer.apple.com/app-store/review/guidelines/#data-collection-and-storage Opening macOS' default web browser has been a native behavior of Mac apps when using SFSafariViewController with ASWebAuthenticationSession, which is required, since iOS 13, for securely/privately logging in users. As far as I could investigate, there hasn't been any updates to the guidelines that would indicate any required changes to developers in regards to how login works for macOS apps. Are there any steps developers need to take to get updates approved while still providing users with Google's Sign in? As reference, there is an on-going discussion on GoogleSignIn repo about this issue affecting multiple developers and apps: https://github.com/google/GoogleSignIn-iOS/issues/388
2
3
511
Apr ’24
drawHierarchy broken - image too bright
extension UIView { func takeSnapshot(rect : CGRect? = CGRect.zero) -&gt; UIImage? { let renderer = UIGraphicsImageRenderer(size: frame.size) var image = renderer.image { _ in drawHierarchy(in: bounds, afterScreenUpdates: true) } if let imageRect = rect, imageRect != CGRect.zero { let screenshotFrame = CGRect(x: imageRect.origin.x * UIScreen.main.scale, y: imageRect.origin.y * UIScreen.main.scale, width: imageRect.size.width * UIScreen.main.scale, height: imageRect.size.height * UIScreen.main.scale) let imageRef = image.cgImage!.cropping(to: screenshotFrame) image = UIImage.init(cgImage: imageRef!, scale: image.scale, orientation: image.imageOrientation) } UIGraphicsEndImageContext() return image } } which was working fine until I updated to macOS 14.4.1 from 14.2.1 and to Xcode 15.3 from 15.0. issue From my Mac Catalyst app, if I try to take screenshot of imageView, the screenshot is brighter. If I try this method it seems working: func takeSnapshotWithoutScale() -&gt; UIImage? { UIGraphicsBeginImageContextWithOptions(self.frame.size, false, 0) if let currentContext = UIGraphicsGetCurrentContext() { self.layer.render(in: currentContext) } let newImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return newImage }
2
0
293
Apr ’24
ITMS-90053 Mac Catalyst Invalid Binary
I am really stuck. I uploaded my Mac Catalyst app. The binary passes validation beforehand. I submit for review. After being in "waiting for review" for a couple of minutes it is rejected with "invalid binary" and comes back with an email saying "ITMS-90053: This bundle is invalid - The bundle identifier is already in use by a different software package." The only app that is using the same bundle is the IOS version where I added the Mac platform.
0
0
326
Apr ’24
CGEventTapCreateForPid fails to get event tap
My app uses CGEventTapCreateForPid to monitor keyboard events of a corresponding process. My app has already enabled the Accessibility permission, and AXIsProcessTrustedWithOptions returns true. However, CGEventTapCreateForPid returns null. What could be the problem? Does anyone know? I tested and found that if CGEventTapCreateForPid returns null, I can reset the Accessibility permission using tccutil reset Accessibility myapp_bundleid without restarting my app. But my app can still get the permission through AXIsProcessTrustedWithOptions
2
0
330
Apr ’24