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

109 Posts
Sort by:
Post marked as solved
5 Replies
3.2k Views
My own iOS app is using AVFoundation to do barcode scanning. Under Mac Catalyst I'm getting an error. Turns out the Apple provided AVCam demo app has the exact same issue.Both the Swift and Objective-C versions of the AVCam demo app fail but the Objective-C version gives a better error so I'll refer to that in the rest of the question.In the AVCamCameraViewController, the configureSession method fails on the line:AVCaptureDeviceInput* videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];The error is:Could not create video device input: Error Domain=AVFoundationErrorDomain Code=-11814 "Cannot Record" UserInfo={NSLocalizedDescription=Cannot Record, NSLocalizedRecoverySuggestion=Try recording again.}It turns out that none of the three attempts to call [AVCaptureDevice defaultDeviceWithDeviceType:... are succeeding.This is the same error I get in my own app though I only attempt to call [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; which is also returning nil.Permission was granted for the app to access the camera.There is nothing related to this issue in the release notes for macOS 10.15. I am running the GM version of 10.15 with Xcode 11.1 on a 2018 15" Macbook Pro.How do we successfully get a video capture device under Mac Catalyst?
Posted
by
Post not yet marked as solved
2 Replies
2.3k Views
In my iPad app running under macOS Catalyst I would like to modify the context menu that appears when you right-click on a UITextViiew but I can't figure out how.I have overridden the buildMenuWithBulder:/buildMenu(with:) method from UIResponder in my view controller and app delegate but none are called when right-clicking on a UITextView.I have been able to disable a couple of the menu options by subclassing UITextView and overriding the canPerformAction:withSender:/canPerformAction(_:withSender:) and targetForAction:withSender:/target(_:withSender:) methods but I can't remove/disable most of the menu.I also overrode the validateCommand:/validate(_:) method in my UITextView subclass and that was only called for a small subset of the menus I wish to remove/disable.The Menus sample app only shows how to modify the app's main menu and how to add a context menu to a view controller but there is no info on how to modify the context menu of a control such as UITextView.Does anyone know how to do this?Specifically I want to remove the Show Fonts and Show Colors menus under Font and I wish to remove the whole Substitutions menu. The allowsEditingTextAttributes property of the text view is enabled which is what makes the Font portion of the menu appear. I want to keep the Bold/Italic/Underline toggles.
Posted
by
Post not yet marked as solved
2 Replies
1.2k Views
Here is a list of things that Mac Catalyst do not appear to be able to do. Does anyone else experience this ?- MultiPeer connectivity on Mac Catalyst will not connect to an ios device. catalyst ask to join , Then accept on ipad I get this message on Ipad and catatlyst stalls out . [MCNearbyServiceBrowser] Browser got invite response with nil connectionData.- Playing Sounds ( AVAudioPlayer ) on Mac Catalyst does not play audio.- Scheduling local notifications on Mac Catalyst does not work.- Selection of a UICollectionView Cell does not select on Mac Catalystlet selectedItems = colVw.indexPathsForSelectedItems // Works fine on ipad but always empty for MacCatalyst
Posted
by
Art
Post not yet marked as solved
6 Replies
2.1k Views
I have recently created a pure (admittedly simple) SwiftUI app for iOS/iPad. Yes there are bugs and limitations I've had to face but eventually with a certain amount of compromise and without resorting to UIViewRepresentable, it works adequately. Great, I thought, how hard can it be to create a macOS version of the same app? Take TextField (swiftUI) views which my app depends on a lot, the issues I have found have been numerous... TextField does not appear to update the Binded variable after each character is typed in. You have to hit the return key for it to register. Totally different functionality. Placeholder text shifts up a few pixels when it gets keyboard focus. The rectangle where the text is typed needs to be taller holding the text, currently it looks squashed. Manually adding a ‘clear text’ button on top of the TextField (at the right) appears not to to be active when the cursor is over it (most of the time) Lots of missing autocapitalisation type functionality is missing. I could go back to a NSViewRepesentable solution of the TextField but that negates the use of 'supported' SwiftUI features. Has this half baked feature been pushed out there as a 'tick in the box' option or is Apple genuinely happy with their solution? Anyhow, I thought let's do a MacCatalyst version of my App instead. But we get a TabView looking like a iPad/iPhone App, there is no option to make it look more mac like AFAIS without abandoning TabView itself! Then there's the complication of making my Core Data App work as a 'Document Based' app with the new DocumentGroup/Scene solution.... how does NSPersistentDocument work in such scenarios? The documentation is vague at best, or simply not supported without a lot of workarounds. Just these few things make me feel we are being hyped with solutions which are far too premature for any real world work on macOS at the moment. What potential SwiftUI/macOS blockers have you encountered?
Posted
by
Post not yet marked as solved
5 Replies
1.6k Views
It says UIRefreshControl is not supported when running Catalyst apps in the Mac idiom. Consider using a Refresh menu item bound to ⌘-R what would I need to do to fix this to make my apps work with Catalyst?
Posted
by
Post not yet marked as solved
1 Replies
694 Views
Hello, in my Mac Catalyst app, I have detail view with sections modeled as DisclosureGroups. The label view has a button, that shall trigger a file import view when pushed. The label view is defined as follows: swift HStack {         Text(LocalizedStringKey("Documents")).font(.title)         Spacer()         Button {           showFileImporter = false           // fix broken picker sheet           DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {             showFileImporter = true           }         } label: {           Image(systemName: "doc.badge.plus")             .padding(.horizontal, 10)         }         .disabled(!expanded)         .fileImporter(                       isPresented: $showFileImporter,               allowedContentTypes: [.data],           allowsMultipleSelection: false) { result in                       // add fileUrl.startAccessingSecurityScopedResource() before accessing file             NSLog("\(result)")           }       } Unfortunately the file import view is not showing, when the button is pushed, although the state changes to true. Does anybody have any hints? BTW the repo is available at https://github.com/thbonk/repti/tree/ui-refactoring The view in question is https://github.com/thbonk/repti/blob/ui-refactoring/Repti/Source/UI/Views/IndividualDetails/DocumentsSubview.swift Thanks & Best regards Thomas
Posted
by
Post not yet marked as solved
4 Replies
1.5k Views
Hi, I have Mac catalyst app, that usually shows one window, but under some circumstances I open another one with different content (so it is multi-windowed app, but not in a way of opening several documents in instances of the same type of window). I did manage to setup SceneDelegate, open scenes etc., but I have still some problems. After app launch, old scenes are automatically recreated. Is there a way to stop it? I want to always start with main scene, and only open the second one from code. Is there a way to set size and position of a window before it is shown? I can do it by acquiring NSWindow from UIWindow and then using AppKit from another bundle. But this can only be done after the window appears on screen. As a result, user sees window "jump". When scene is being created (or maybe just recreated to restore previous session), window gets the same position it had before. Is there any way to control it? How this mechanism exactly works? Where are the previous positions stored and can they be modified? How a newly created scene gets its size and position?
Posted
by
Post not yet marked as solved
3 Replies
2.3k Views
I'm building an app to manage and edit some files. To do that, I want to open the files in place dropping them into a view. I cannot find a way to obtain the file URL after the drop operation. If I constrain the file types to .fileURL, the drop frame doesn't activate. If I use .data, I get the file and not the path, which is what I want. Any way to do this the SwiftUI way? .onDrop(of: [.fileURL], isTargeted: $dragOver) { providers -> Bool in providers.first?.loadDataRepresentation(forTypeIdentifier: "public.file-url", completionHandler: { (data, error) in                             if let data = data {                                 print(data.description)                             }                         })                         return true }
Posted
by
Post not yet marked as solved
1 Replies
1.3k Views
If we click on a simple html dropdown list on a WKWebview and choose an item in the list, after that we will never be able to click it ever again on that same dropdown (it will never open again), unless we click elsewhere on the webpage (removing the focus that was on the dropdown). That only happens on Mac, on iOS it works fine. This is another Mac Catalyst problem on Mac.
Posted
by
Post not yet marked as solved
3 Replies
1.1k Views
Hi, Inside a Mac Catalyst app, I need to display a popover starting from an NSToolbarItem contained inside the app toolbar (like the Apple Maps Mac app does, see below image). In order to do that, when I press the button I need to find the toolbar item view and use it as popover anchor. How can I find the view or frame of an NSToolbarItem on Mac Catalyst? A property that could help me is the NSToolbarItem "view" property (NSView), but that property has been marked has unavailable in Mac Catalyst. Any idea? Thank you
Posted
by
Post marked as solved
3 Replies
5.1k Views
MacOS M1 machines can run iOS applications. We have an iOS application that runs a fullscreen metal game. The game can also run across all desktop platforms via Steam. In additional to Steam, we would like to make it available through the AppStore on MacOS. We'd like to utilise our iOS builds for this so that the Apple payment (micro-transactions) and sign-in processes can be reused. While the app runs on MacOS, it runs in a small iPad shaped window that cannot be resized. We do not want to add iPad multitasking support (portrait orientation is not viable), but would like the window on MacOS to be expandable to full screen. Currently there is an option to make it full screen, but the metal view (MTKView) delegate does not receive a drawableSizeWillChange event for this, meaning the new resolution of the window cannot be received. Is there another method of retrieving a window size change event in this context? What is the recommended way of enabling window resizing on MacOS but not iPad for a single iOS app?
Posted
by
Post not yet marked as solved
11 Replies
3.2k Views
I would like to remove the title bar of the catalyst version of my app, but it does not work on Ventura. It used to work on Monterey. I am using AppDelegate lifecycle. I am following the official documentation: https://developer.apple.com/documentation/uikit/mac_catalyst/removing_the_title_bar_in_your_mac_app_built_with_mac_catalyst The code: 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 }
Posted
by
Post not yet marked as solved
5 Replies
813 Views
Hi, I am trying to create a hard link on MacOS(Mac Catalyst App) between files using [self linkItemAtURL:fromURL toURL:toURL error:&error]; Source Path for MacOS - /var/folders/lf/dt_4nxd945jdry2241phx0_40000gn/T/net.appname.AppName/documents/... Destination Path for MacOS - /Users/username/Library/Group Containers/group.net.appname.AppName.shared/Message/Media/... Although the same code works fine on iOS, but getting following error on MacOS Error Domain=NSCocoaErrorDomain Code=513 couldn’t be linked because you don’t have permission to access, Operation not permitted Source Path for iOS - /Users/user/Library/Developer/CoreSimulator/Devices/B4054540-345F-4D90-A3C5-DA6E6469A3FC/data/Containers/Data/Application/B4AB7D70-491C-49E5-9A3F-27E66EC3423D/tmp/documents/... Destination Path for iOS - /Users/user/Library/Developer/CoreSimulator/Devices/B4054540-345F-4D90-A3C5-DA6E6469A3FC/data/Containers/Shared/AppGroup/842B248E-CCA6-4B5C-82BD-2858EADD3A90/Message/Media/... However, interestingly if I try to copy the file, it works perfectly fine on MacOS as well. I am unable to understand if it is the permission issue, it should not work with copy as well. Does anyone have any reason/solution to this behaviour?
Posted
by
Post not yet marked as solved
3 Replies
539 Views
So experimenting with UISplitViewController on Mac Catalyst. I have a triple split. The primary view controller is a sidebar. I have the default sidebar button showing in the toolbar and that collapsed/expands the sidebar fine. But when I drag to try to collapse the split (as is typical on macOS) the sidebar doesn't collapse. It clamps to the min. size. Is there anyway to enable this? I tried passing 0 to -setMinimumPrimaryColumnWidth: but that didn't work.
Post not yet marked as solved
4 Replies
1.1k Views
I'm not sure what happened but everything I had done to get the new "Editor" and "Browser" style of navigation bars to work for my app on Catalyst has totally broken on the latest beta for Ventura. My app is using a UISplitViewController as the root view controller, and previously if I changed which view controller was representing the content then the buttons represented by its navigation item would update in the toolbar. Now all I see is the buttons from the first view controller's navigation item remain after a view controller changes. I have occasionally seen the buttons update to a different view controller's navigation item, but after that happens the buttons also no longer work. It's like they're being tapped on but nothing happens. Just to reiterate, all of this was working perfectly fine on the last beta and I haven't made any code changes since updating my Mac.
Posted
by
Post not yet marked as solved
8 Replies
3k Views
I have a simple UIKit application that has a UITextView in a UICollectionViewCell. The app is designed for iOS/iPadOS and works just fine on those platforms. However, when run on Mac (Designed for iPad) as soon as I start scrolling the collectionview, the cpu usage spikes to ~85% and stays there indefinitely. The only way to lower the cpu is to click outside of the application window, but once it comes to the foreground again, the cpu usage jumps right back up. I've tried running on Mac in Catalyst mode too, but the same problem occurs with slightly less cpu usage (~45%). Additionally the debugger constantly spits out [API] cannot add handler to 3 from 3 - dropping while scrolling. Does anyone have an explanation or solutions for this? I’m using Xcode Version 14.1 (14B47b) on macOS Ventura 13.0 (22A380). class ViewController: UIViewController { var dataSource: UICollectionViewDiffableDataSource<Section, String>! = nil var collectionView: UICollectionView! = nil var items = Array(0...100).map{"Item \($0)"} enum Section: String { case main } override func viewDidLoad() { super.viewDidLoad() navigationItem.title = "List" configureCollectionView() configureDataSource() applyInitialSnapshot() } private func createLayout() -> UICollectionViewLayout { return UICollectionViewCompositionalLayout { sectionIndex, layoutEnvironment in let size = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(100)) let item = NSCollectionLayoutItem(layoutSize: size) let group = NSCollectionLayoutGroup.horizontal(layoutSize: size, subitems: [item]) return NSCollectionLayoutSection(group: group) } } private func configureCollectionView() { collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: createLayout()) collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight] collectionView.backgroundColor = .systemBackground view.addSubview(collectionView) } private func configureDataSource() { let cellRegistration = UICollectionView.CellRegistration<TestCell, String> { (cell, indexPath, item) in cell.configure(title: item, row: indexPath.item) } dataSource = UICollectionViewDiffableDataSource<Section, String>(collectionView: collectionView) { (collectionView, indexPath, identifier) -> UICollectionViewCell? in return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: identifier) } } private func applyInitialSnapshot() { var snapshot = NSDiffableDataSourceSnapshot<Section, String>() snapshot.appendSections([.main]) snapshot.appendItems(items) dataSource.apply(snapshot, animatingDifferences: false) } } class TestCell: UICollectionViewCell { private let annotationsTextView = UITextView() override init(frame: CGRect) { super.init(frame: frame) addViews() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } func configure(title: String, row: Int) { annotationsTextView.attributedText = .init(string: "Row: \(row) Item: \(title)", attributes: [.font: UIFont.preferredFont(forTextStyle: .title1)]) } private func addViews() { annotationsTextView.isScrollEnabled = false annotationsTextView.isEditable = false annotationsTextView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(annotationsTextView) NSLayoutConstraint.activate([ annotationsTextView.topAnchor.constraint(equalTo: contentView.topAnchor), annotationsTextView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), annotationsTextView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), annotationsTextView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), ]) } }
Posted
by
Post not yet marked as solved
7 Replies
1.2k Views
NSOpenPanel.runModal is returning before the user can select a file. It seemed to get progressively worse as the OS updated. Now with macOS Ventura 13.0 it is completely unusable. Supporting docs https://stackoverflow.com/questions/70050559/nsopenpanel-nssavepanel-runmodal-dismisses-immediately-with-cancel-but-only-on https://stackoverflow.com/questions/28478020/presenting-nsopenpanel-as-sheet-synchronously
Posted
by
Post not yet marked as solved
7 Replies
1.8k Views
Everything was working fine for 4 years. But since Ventura, when the WKWebView is in focus, the keyDown event are not happening. Not only they don't fire inside of web page input box, but they won't register in the app either. As long as a WKWebView is in focus, the keyboard events won't work. The app does not receive the key events, and the web page will not receive the js events keyDown and friends. This is particularly painful with auto complete input box. Test with an empty project with only a WKWebView with this page https://www.toptal.com/developers/keycode/for/d It does work fine on iPhone and iPad. Message to Apple : You force us to use your Safari engine, yet it is always broken. Don't wait for 8 months to fix it this time, we would be tempted to go full web and skip native app with all the store certification problems.
Posted
by