Post

Replies

Boosts

Views

Activity

How can I test my native macOS app on an Intel-based hardware when I developed it on an Apple Silicon (M2 chip)?
I've written a native app for macOS on my MacBook Air (with the Apple M2 chip.) Now I need to test it for an Intel-based CPU. When I build my app in Xcode, it is supposed to cover both ARM64 and x86-64 architectures in a single Mach-O binary, but when I send it to my customer he tells me that the app works on the Apple silicon but it crashes on his Intel-based Mac. So I'm looking for ways to test-run my app on an Intel-based platform and see what is wrong there. (But I obviously don't want to buy a separate Mac just for that.) I know that one can use Azure to spin up a Windows, or a Linux VM and open it via a web browser. But it doesn't seem to support macOS. How can I run an Intel-based macOS in a virtual environment? Or, do you have any other suggestions?
3
0
1.1k
Jul ’23
How to display NSOpenPanel from a GUI macOS app running as root
I use the NSOpenPanel to open a file picker dialog (default from macOS) to let user select a file to open. I use the following code: let panel = NSOpenPanel() panel.message = "Select file to open" panel.allowsMultipleSelection = false panel.canChooseDirectories = false panel.canChooseFiles = true let resp = panel.runModal() if(resp == .OK) { let strFilePath = panel.url?.path(); //do the work... } else if(resp != .cancel) { //Error } This works. But if I run my GUI app as root (which I need for the purpose of setting up my launch daemon), the panel.runModal() returns 0, or .cancel without showing the dialog. Any idea how do I make it work under root?
0
0
347
Mar ’23
Can I use these CoreGraphics functions from a launch daemon?
From my launch daemon for macOS (written in C++) I need to be able to count the number of monitors currently attached to the system and get some basic specs from the screen(s). For that I am using the following functions: CGGetActiveDisplayList or CGGetOnlineDisplayList CGDisplayIsActive CGDisplayBounds CGMainDisplayID Are they safe to call from a launch daemon? And if not, what shall I use instead?
0
0
337
Dec ’22
Where is isA_CFDictionary declared?
I'm trying to compile this C++ code in Xcode. And it can't seem to find the isA_CFDictionary. I'm getting: Use of undeclared identifier 'isA_CFDictionary'; did you mean '__CFDictionary'? I have included: #include <CoreFoundation/CoreFoundation.h> I have also included "CoreFoundation.framework" in the Frameworks and Libraries in XCode. But it didn't help. What library is it defined in?
0
0
362
Nov ’22
Get notifications of a lid close/open events on a MacBook
I need this for a MacBook with the M1/M2 chips. I write a launch daemon (in C++) that needs to know when a laptop lid is closed (and opened.) And also have an ability to disable the OS to process the lid opening/closing events. But I'm having a hard time finding any information on how to do it in macOS. So far I found out that if run the following in Terminal: ioreg -r -k AppleClamshellState -d 4 It gives me the information that I need in the AppleClamshellState and AppleClamshellCausesSleep parameters. I guess I can run that as a separate process and grep that info out of its output. But I was hoping to see what does ioreg use internally (or which lower level function does it call) to get that info, as I think this is terribly inefficient to invoke a whole separate process for that. So this is my first question. The second one is how to get a notification when someone closes or opens the lid? PS. I did some research and found the IOPMrootDomain class (?) or interface, that seems to prove the IOPMrootDomain::sendClientClamshellNotification method (source here.) But I don't really know how to use it in my C++ daemon. PS2. I am relatively new to programming under Mac. But I have an extensive experiencing programming under Windows. So I apologize in advance if I'm asking something trivial.
0
0
533
Nov ’22
Can I code a macOS daemon+UI for M1, M2 chips on an older Intel Mac?
Hi everyone: I've been asked to write a macOS daemon along with the UI to configure it to run on the latest macOS Air and Pro laptops with the M1 and M2 chips. I have an older MacBook Pro with an Intel CPU. It runs macOS v.10.12.6 (Sierra) and I was able to download XCode v.9.2. I can't upgrade it to anything newer than that. Can I code that daemon+UI in Xcode in Swift using my laptop? I was thinking to write the source code on it, compile and debug it for the Intel CPU, and then re-compile the ready product for the M1/M2 ARM chips. Is such possible?
6
0
715
Oct ’22