Building a JUCE Plugin for "Any Mac"?

Hello JUCE Developers!

I’m trying to build a universal version of a plugin using xcodebuild and Projucer 7.0.9. The output when I run xcode build is:

/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project Builds/MacOSX/Perspective.xcodeproj -scheme “Perspective - All” -c— xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:x86_64, id:8BD34136-9ED7-5930-A2D6-A78A5ADCA922, name:My Mac }
{ platform:macOS, name:Any Mac }

… and the build ends up being whatever architecture is active when the build is started. If I build on an M1 with a terminal running in native mode, I get an arm64 build. If I build running in Rosetta mode, I get x86_64 at the build.

I have tried a variety of settings in Projucer, xcode and xcodebuild with no luck. My build script runs projucer to set the version before calling xcodebuild with the following parameters:

–set-version $version $jucer_file

and my xcodebuild command line is:

xcodebuild -project Builds/MacOSX/plugin.xcodeproj -scheme “Plugin - All” -configuration Release ONLY_ACTIVE_ARCHS=NO -destination ‘name=Any Mac/platform=macOS’

Whats the secret formula to get a universal build?

Since Xcode 15.3 you can override architecture built in Scheme.
The default option is Match Run Destination which override the fact that you have set universal binary

After much hassle with this myself, I have adopted a strategy of using VM’s for any older MacOS versions I want to target, and maintain a small suite of these for the purpose. Its the only way to be sure you don’t get backlogged, just because Apple have decided to apply an antipattern designed to make people upgrade their hardware …

1 Like

Is there some way to set this in the Projucer so that it builds all architectures? I’m building a plugin via Github Actions and creating the XCode project from the Projucer so it isn’t easy for me to select ‘Any Mac’ just before building.

I discovered this by sending my (supposedly) universal binary to someone who couldn’t run it, built from a project that previously produced universal binaries. I expect others will have this same issue.

If multiple architectures builds are important to you, you must emmigrate away from the Projucer and convert to a CMake-based project, instead. The investment made in doing this is worth far more than the ‘comfort’ in staying on Projucer-based projects. Projucer is great for getting started - for production, CMake is far, far superior.

This is the most effective way to handle cross-platform, multi-architecture build strategies - and then, when you get it working, to save yourself immense pain as time moves on, move the CMake project into VM’s for each OS target.

1 Like

Thank you. I have no doubt that you are correct and have been meaning to move to CMake for this for a while.

I think given it looks like a single setting to change it’d be good for the Projucer to have the option though.

In CMake just add:

if (APPLE)
   set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE INTERNAL "")
endif()
3 Likes

As an answer to the original post, the following flag for xcodebuild worked for me to get all architectures specified in the Projucer to be built…

-destination "generic/platform=macOS"

2 Likes

Thanks! That command line did the trick!

That is correct.

Totally nitpicking comment, but there’s no need for if(APPLE) there.

This would just do nothing on Windows/Linux. Same with any CMAKE_OSX_ flags or CMAKE_MSVC_ (that would only work on Windows).

1 Like

Hey, I’m running into a similar issue. Everything works fine when I build it on my Mac, but when I try to build it for any Mac (for distribution), mbedtls throws an error because I don’t have the ARM version installed on my computer. Is there any way to compile the ARM version on my machine or get it compiled?

I have not encountered such problem in my project (-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" is enough for me).

You may use the Github Runner Image (macOS 14 arm64) to build your plugin. Here is a good starting point:

@zsilu98 Did you manage to get it running on ARM?
Also, do I even need to compile it manually for that? Or is there a prebuilt version I can use somehow?

Thanks in advance

Did you manage to get it running on ARM?

I use GitHub actions to compile universal binaries. It works fine.

Also, do I even need to compile it manually for that?

The release binaries are compiled on GitHub runner images.