macOS is the operating system for Mac.

Posts under macOS tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

iPad app on Mac - Fix window aspect ratio
I'm developing an app that works on iOS and iPadOS in Portrait mode only. I'd like it to be able to run on Apple Silicon Macs as well, but when I try running it on my Mac, the application screen it resizable to any size and any aspect ratio. (Oddly, it works fine in visionOS, where the window can be made bigger or smaller but always maintains a portrait aspect ration.) Is there some way I can have the aspect ration fixed when the app runs on macOS? Thanks!
1
0
351
Apr ’24
System Extension deactivationRequest fails with error "The operation couldn’t be completed. (OSSystemExtensionErrorDomain error 13.)"
We have a main app that handles UI and interaction with the user. And we also have daemon contained inside of it. Daemon has all the business logic and FDA and root permissions. Now we want to add a network extension. First we added the Network Extension to Main app and it was working fine (to test the waters). But then we decided to move it to Daemon since it has all the business logic and NE mostly contains business logic and no UI. It needs to be there. Now NE activationRequest(forExtensionWithIdentifier is working fine. But deactivationRequest(forExtensionWithIdentifier: during uninstall always fails with this error System Extension deactivationRequest fails with error he operation couldn’t be completed. (OSSystemExtensionErrorDomain error 13.) OSSystemExtensionError Code 13 says "An error code that indicates the system was unable to obtain the proper authorization." What does this actually mean. Also if there is an error why is it throwing it during uninstall rather than install? To make it more clear this is our app structure is Main.app -> Contents -> Mac OS -> Daemon.app -> Contents -> Library -> SystemExtensions -> System Extension Bundle Apple doc says @discussion This method creates a new request to activate/deactivate a System Extension. Extensions are discovered from the `Contents/Library/SystemExtensions` directory of the main application bundle. Our System Extension is present on the main app bundle and has Contents/Library/SystemExtensions structure but one extra layer deep. Is this supported app structure?. If not is there any way to succesfully uninstall NE from code. Right now systemextensionsctl uninstall won't work without System Integrity Protection disabled. Keeping NE on the main app will break our project structure and require major rewrite of the app. Also whenever I run systemextensionsctl with SIP on I get this message At this time, this tool cannot be used if System Integrity Protection is enabled. This limitation will be removed in the near future. Please remember to re-enable System Integrity Protection! Apple introduced System Extensions in 2019. It is still not there yet. Does anybody have any idea when will Apple make it work? if at all?
2
0
563
Apr ’24
How do you configure a document-based SwiftUI multi-platform app to be able to import .log files?
In a new document-based UIKit app, specifying in the Info.plist an import type identifier of public.log that conforms to public.content, public.data, public.item accomplishes this. In a new document-based SwiftUI multi-platform app, doing the same crashed at the DocumentGroup initializer with the error _SwiftData_SwiftUI/Documents.swift:91: Fatal error: The document type is public.log which does not conform to com.apple.package. This initializer expects the document type to be a package.
1
0
378
Mar ’24
SwiftUI fileImporter vs dropDestination logic
If I drag something into my SwiftUI Mac app the .dropDestination gets an array of URLs that I can do with what I want. If I use .fileImporter to get an identical array of URLs I should wrap start/stop securityScopedResource() calls around each URL before I do anything with it. Can anyone explain the logic behind that? Is there some reason I'm not seeing? It is especially annoying in that the requirement for security scoping also doesn't exist if I use an NSOpenPanel instead of .fileImporter.
4
0
614
Apr ’24
WebRTC application gets no STUN replies on non-localhost interface
We have a local environment for testing our cloud WebRTC products. The media application runs locally on a MacBook along with a node.js server application. We connect using a web page which establishes connections. Our media application can be configured to use the localhost interface by default but also supports any non-localhost interface. On my MacBook (M1, macOS 14.3.1) I can no longer use the non-localhost interface. Wireshark captures show that STUN messages from the web application fail to get responded to on the non-localhost interface. Others who use a similar setup and the same software versions do not experience this issue. This used to work for me as well. What are my options for debugging this issue? Thanks, Bob
0
0
234
Mar ’24
XCode 15 linker ld_prime causing new dependencies that don't work
With XCode 14 and below, our macOS application is building and running fine. The application depends on some third-party .dylibs and also a couple of .frameworks that we make in-house, all of which are happily in the .app bundle and working. When compiled under XCode 15, the application crashes because one of our .frameworks now tries to load these dylibs which cannot be found if run on a machine that didn't build it. Note that previously, this framework never depended on these dylibs before, but the application does. The rpaths for these dylibs are pointing to the build dependencies folder, which would only exist on a build machine. Also, the dependencies are now looking for versioned dylib filenames, while the application itself depends on the un-versioned dylib filenames. So to recap, that's 3 new problems when building with the new linker: The framework is now dependent on dylibs that normally only the application depends on The new dependency is on versioned dylibs, where the original application dependency is on un-versioned dylibs The framework's rpaths now include intermediate build folders Running otool -L on the framework binary shows a clear difference between ld_prime and ld_classic. The dependencies on the third-party dylibs are only showing up when the framework is built with the new linker. We have a couple of workarounds: Using ld_classic to build our application with the old linker Using post-build commands (install_name_tool) to change the dependencies and remove the build folders from the rpaths Though ultimately, workaround 1) could only be temporary and 2) is hacky. We'd like to understand why the linker is exhibiting this new behaviour, so we can make the proper adjustments to fix this the correct way. Any insight would be greatly appreciated. Thanks in advance. Note: this is a cross-platform product, and CMake is used to generate the .xcodeproj project file.
1
0
495
Apr ’24
Persisting SwiftData After App Deletion
Hello, I've encountered an issue where SwiftData remains in the /Users/(username)/Library/Containers/MyApp directory even after my MacOS app has been deleted. This behavior is not what I expected. Has anyone else faced this issue? Also, I'm wondering if there is a delay in the deletion process that might account for this. is there a known time lag before everything is cleared out? Thanks.
1
0
403
Apr ’24
Make my app quit and reopen when updating it with .pkg
Context: Our app has a network system extension. After updating it via MDM sometimes the app and the extension have different versions until you restart the app. I suspect that it is because the app is not quit before installing. As a fix I am trying to create a .pkg with preinstall and postinstall script, that would close the app before installation and open it after installation. My code: FileUtils.mkdir_p("install_scripts") File.open('install_scripts/preinstall', 'w') do |file| file.puts "#!/bin/bash\nosascript -e 'quit app \"#{options[:app_name]}\"'\nexit 0" end File.open('install_scripts/postinstall', 'w') do |file| file.puts "#!/bin/bash\nopen -a '#{options[:app_name]}'\nexit 0'" end sh "chmod a+x install_scripts/preinstall" sh "chmod a+x install_scripts/postinstall" sh( "pkgbuild", "--scripts", "install_scripts", "--identifier", ***_identifier(options), "--component", "../#{options[:build_path]}/#{options[:app_name]}.app", "--install-location", "/Applications/#{options[:app_name]}.app", "Distribution.pkg" ) sh( "productbuild", "--synthesize", "--package", "Distribution.pkg", "Distribution.xml" ) sh( "productbuild", "--distribution", "Distribution.xml", "--sign", "Developer ID Installer: *** Inc. (#{ENV["APPLE_TEAM_ID"]})", "--package-path", ".", "../artifacts/#{options[:app_name]}.pkg" ) Issue: I haven't got it to actually install the app or to close or open the running app. I've tried several changes. The code above fails with this error. Do you see an issue in my code, or could you point me to alternative implementation? installd[1101]: PackageKit: Install Failed: Error Domain=NSCocoaErrorDomain Code=516 ""Myapp Dev.app" couldn't be moved to "Applications" because an item with the same name already exists." UserInfo={NSSourceFilePathErrorKey=/Library/InstallerSandboxes/.PKInstallSandboxManager/8E84CB81-4724-4D4E-BE76-3A24DECC60A6.activeSandbox/Root/Applications/Myapp Dev.app/Myapp Dev.app, NSUserStringVariant=( Move ), NSDestinationFilePath=/Library/InstallerSandboxes/.PKInstallSandboxManager/8E84CB81-4724-4D4E-BE76-3A24DECC60A6.activeSandbox/Root/Applications/Myapp Dev.app, NSFilePath=/Library/InstallerSandboxes/.PKInstallSandboxManager/8E84CB81-4724-4D4E-BE76-3A24DECC60A6.activeSandbox/Root/Applications/Myapp Dev.app/Myapp Dev.app, NSUnderlyingError=0x117e304b0 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}} { NSDestinationFilePath = "/Library/InstallerSandboxes/.PKInstallSandboxManager/8E84CB81-4724-4D4E-BE76-3A24DECC60A6.activeSandbox/Root/Applications/Myapp Dev.app"; NSFilePath = "/Library/InstallerSandboxes/.PKInstallSandboxManager/8E84CB81-4724-4D4E-BE76-3A24DECC60A6.activeSandbox/Root/Applications/Myapp Dev.app/Myapp Dev.app"; NSSourceFilePathErrorKey = "/Library/InstallerSandboxes/.PKInstallSandboxManager/8E84CB81-4724-4D4E-BE76-3A24DECC60A6.activeSandbox/Root/Applications/Myapp Dev.app/Myapp Dev.app"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=17 "File exists""; NSUserStringVariant = ( Move ); }
2
0
481
Mar ’24
NSMenuItem's custom view property returns wrong locationInWindow value on NSResponder's mouseExited method
After popping up a NSMenu a few times, NSResponder's mouseExited event is called even when the cursor is inside the tracking area, returning the main app window's max X value, which makes the mouseEntered/Exited methods unusable for tracking whether or not cursor is currently inside the view's frame. Steps Create a NSMenuItem with a custom view inside Add a tracking area to the views frame Add a background color that changes on mouseEntered/Exited Open and close NSMenu a few times until the color starts flickering when moving the cursor inside the view's frame If possible, print out NSEvent's locationInWindow on both mouseEntered and Exited and see that the location for exited method is not being reported correctly, while the flickering from the bg color being set is happening. Expected Result mouseExited should only be called the cursor leaves the tracking area. locationInWindow values should not exceed the NSPopUpWindow's frame. Tested on macOS Sonoma 14.3.1 and 14.4.1; Xcode 15.2; Feedback ID https://feedbackassistant.apple.com/feedback/13698735
0
1
447
Mar ’24
Trying to drag from app to finder and getting this error: Sandbox extension data required immediately for flavor public.file-url, but failed to obtain.
I'm trying to make a macOS app using SwiftUI that supports dragging arbitrary files from the app into finder. However, I'm getting this error: "Sandbox extension data required immediately for flavor public.file-url, but failed to obtain." I'm looking through the entitlements and not finding anything obvious here. I've tried various forms of NSItemProvider(): Try 1: let itemProvider = NSItemProvider(item: image.data as NSSecureCoding, typeIdentifier: image.uniformType.identifier) // Tried presenting as data itemProvider.registerDataRepresentation(for: .fileURL, visibility: .all) { completion in ... } // Tried presenting as file itemProvider.registerFileRepresentation(for: .fileURL, visibility: .all) { completion in ... } Try 2: let itemProvider1 = NSItemProvider(contentsOf: tempFileUrl, contentType: .fileURL) Tried using this form as well. In the completion handler for register*Representation(), i'm typically creating a temporary file and returning that.. (either the URL to the file or the data directly, depending on the API): let tempFileUrl = URL.temporaryDirectory.appending(path: "testfile.png") _ = tempFileUrl.startAccessingSecurityScopedResource() defer { tempFileUrl.stopAccessingSecurityScopedResource() } completion(tempFileUrl as data, nil) // option 1 completion(data, nil) // option 2 Disabling App Sandbox in the entitlements file does not work, but the error message goes away. So it seems like I have two problems: some sort of entitlement error and I must be using NSItemProvider() incorrectly. Anyone have any suggestions? I don't see to many examples out there for supporting exporting files (e.g. images) from an app into Finder. Thanks!
0
0
347
Mar ’24
SwiftUI - List multi selection move / reorder (works on Mac but not on iOS)
How can I enable multi-select and then move / reorder selected items in a List with ForEach (in SwiftUI)? I tried the following code. On Mac it works fine - it allows me to select multiple items, and then drag them all together to another place in the list. On iOS it allows me to move individual items with drag-and-drop, and allows me to enter Edit mode to select multiple items but when I try to move the selected items with drag-and-drop, they can be dragged but they can't be dropped elsewhere in the list: struct ExampleListView: View { @State var items = ["Dave", "Tom", "Jeremy", "Luke", "Phil"] @State var selectedItems: Set<String> = .init() var body: some View { NavigationView { List(selection: $selectedItems) { ForEach(items, id: \.self) { item in Text(item).tag(item) }.onMove(perform: move) } .navigationBarItems(trailing: EditButton()) } } func move(from source: IndexSet, to destination: Int) { items.move(fromOffsets: source, toOffset: destination) } } This code has the same behavior: struct ExampleListView: View { @State var items = ["Dave", "Tom", "Jeremy", "Luke", "Phil"] @State var selectedItems: Set<String> = .init() var body: some View { NavigationView { List($items, id: \.self, editActions: .all, selection: $selectedItems) { $item in Text(item).tag(item) } .navigationBarItems(trailing: EditButton()) } } func move(from source: IndexSet, to destination: Int) { items.move(fromOffsets: source, toOffset: destination) } }
1
0
561
Mar ’24
Changing the title in the toolbar of a SwiftData/UI document app?
I just started a little macOS app using SwiftUI and SwiftData. It seems to insist on placing the name of the file (along with the extension) in the title bar. I would prefer to put the name of the selection there instead (i.e. instead of "Untitled.paper", "New Article").. Along with that, I'd like to control the appearance of "Edited" as well. I have the suspicion that this simply isn't possible.
0
0
292
Mar ’24
iCloud Deleted my files from my computer!
It doesn't make sense. I spent a huge amount of money and bought a Macbook Pro with 4 TB storage, so my files became acceptable to me. Now Apple has removed my files from my computer without my permission! And if I need my files, I have to download them ( My files are not 1-2 megabytes. Some of my files are 600 MB., and I have to wait to be downloaded! ) It is a big pain. It is a very bad experience. And I don't want this to happen again and again like before. I need help to solve this issue.
0
0
335
Mar ’24
Problems post factory reset of Mac ( Xcode )
Hi I have had severe malware issues recently and need to factory reset my Mac. I may have to reinstall the OS as well in case it has a root-kit. This means I cannot use any standard backups ( Time Machine etc.) and will manually recreate my user setup on the Mac. Will reinstalling Xcode and downloaded signing certificates from my developer account work ? Are there other things to consider ? I will recreate my user ( assuming the uid will be the same as well ) Has anyone tried this before? What is your experience with it?
3
0
646
Apr ’24
NSMenu's submenu won't call willHighlight method for items using custom views
On a submenu (NSMenu), items that use custom views as part of their layout, do not call NSMenu's delegate willHighlight method. The method is called correctly when placing the same items with custom views inside the root/parent NSMenu. Steps Create a NSMenu with at least two NSMenuItem; One with a custom view and another without it. Add a submenu to the item without a custom view; make sure to set the submenu's delegate Add multiple items to the submenu; Make sure some of the items are using custom views Using one of NSMenu's delegate method, willHighlight, check if it will return an item when hovering over the custom view items inside the submenu Notice it will only return when hovering over items that do not use a custom view. Expected Result NSMenu's willHighlight method should be called and inform with item with custom view should be highlighted inside the submenu. Tests done on macOS 14.3.1 and 14.4.1. Xcode 15.2 and 15.3.
1
1
370
Mar ’24
App crashes on M1 Macbook
Hello, I was using this iphone/ipad app con my M1 Mac for couple years now with now problem but all of a sudden today I got this error right when I try to open the app: Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001984434dc Termination Reason: SIGNAL 5 Trace/BPT trap: 5 Terminating Process: exc handler [6785] Triggered by Thread: 17 Any idea how to fix this? I used other iphone/ipad apps and they are working perfectly but not this one. I want to clarify that I was using it with no problem before it was all of a sudden!
1
0
313
Mar ’24