Can I export a headless JUCE App and use it as a static lib on iOS and Android?

I am currently trying to combine a real-time audio engine written in JUCE with UIs entirely built using native iOS and Android widgets. (Hoping to get the best from both worlds. :slightly_smiling_face:)

Is it possible to export a headless JUCE app as a static library and call it in a separate iOS/Android project?

Any hint or help would be greatly appreciated!

See Juce wrapper for SwiftUI project
and GitHub - adamski/audioengine-demo: An example of a multi-platform library using JUCE - there seems to be an issue building it on the latest Xcode, I’ve not had time to figure that out yet.

1 Like

Hi Adam, thank you for the reply! I will look into it and let you know if I manage to fix the building issue. :+1:

1 Like

Great thanks - please submit a PR if you figure something out!

I will need to get it working soon as well for an app update, so I will be taking a look at it over the next few weeks but can’t promise when.

Update:

I haven’t been able to fix the build error, but I got the sample code working as a static lib (which is probably what you want to do anyway since Apple doesn’t allow dynamic libraries in production.)

Here is what I did.

  1. Create a static lib project in Projucer
  2. Structure the project just like what Adam did in his sample project.
  3. Compile the lib using the Xcode project generated by Projucer.
  4. Create another separate iOS project in Xcode.
  5. Reference the static lib in the new iOS project.

Here are the all build settings that you may need to change in the new Xcode project in order for this to work:

  • Header search path. This needs to point to the header of your static lib
  • Objective-C Bridging Header path. This needs to point to the bridging file in your new Xcode project.
  • Library Search Path. This needs to point to the static lib.
  • Other linker flags. You might also need to include “-lstdc++” in the other linker flags.
  • Add your own static lib and any iOS framework used by JUCE (AudioToolBox, CoreMIDI, AVFoundation…) to “Link Binary With Libraries” under your project’s “Build Phases” window.
1 Like

Thanks for writing this up!

I have generally been switching between static for iOS and dynamic for Android.
This would be easier using CMake

1 Like