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?
Post
Replies
Boosts
Views
Activity
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?
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?
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?
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.
I'm new to macOS development (I mostly develop for Windows.) I need to develop a macOS launch daemon that would track power events and lid state of the MacBook.
Can someone let me know which programming language is it better to develop it in?
Will Swift work, or do I need something else for that?
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?