I would like to use Juce in an exsiting MacOS XCode project.
I tried two ways:
I added all the juce module and code into the project. When I run it, I got
error “No global header file was included!”
In Projucer, I created a static library project. I compile the project, got a *.a file. Then I linked this lib to my existing project and add all the module and headers. When I run it, I got error:
Undefined symbols for architecture arm64:
“_main”, referenced from:
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
Which method is prefered or any other suggestions?
I think your approach 2 should work, although you need to be careful that all your preprocessor definitions match when building the static library and when using headers for symbols contained in the static library. The easiest way to do this is probably to enable the “Use global appconfig header” option in the staticlib’s Projucer project.
I wonder whether the staticlib and main project are built for different architectures. Make sure the architecture settings for both projects match in Xcode’s build settings window.
If that doesn’t help, maybe you could try generating a new project of the correct type with the Projucer, and adding your existing code into that new project, rather than trying to add JUCE to the existing project.
The best-supported way to integrate JUCE with third-party/existing projects is via CMake, but that would require moving your existing project to CMake too.