Adding Juce to iOS Project (for Dummys)


#1

Hello Juce fans,

Seems like in certain cases, folks might want to add Juce to an existing iOS Project.

For example if one wanted to do some GUI stuff Apple's way, and use Juce under the hood.

I read everything I could here and elsewhere about how to do it, and none of it was written for someone as dumb as me: 

Here's the steps I took to get it to work, please let me know if there's a better way.

• Create a new project with the introjuicer.

• In Config -> Modules "Set copy-mode for all modules" to YES to make local copies of all the files.

• Drag a copy of the 'JuceLibraryCode' folder you just made from your new blank project to your iOS project

• Open up your iOS project and File->Add Files To... select that 'JuceLibraryCode' Folder

• 'Create Groups' ON 'Add to targets' OFF

• At the top level of each module will be a .mm file, for example juce_core/juce_core.mm

• in XCode in your project manager, go find those and under 'Target Membership' turn them back on.

• Then what happens is you would get a lot of ARC related errors. So go to Build Phases->Compile Sources find those same .mm files and add the compiler flag: "-fno-objc-arc". This apparently stops the compiler from freaking out about all that non-ARC code.

• So now let's say you want to use a juce String in your obj-c file: Change the file extension from .m to .mm

• Add to the top: #import "JuceLibraryCode/JuceHeader.h"

• Leave the .h file alone, for Juce/C++ things you would put in a .h file instead put them in another @interface at the top of your .mm file, such as:

@interface objCThing () {
    String *juceString;
}

• Apparently those parenthesis are important.

• Then in your @implementation you would use 'new', like so:

juceString = new String("I am a Juce String");

printf("%s\n",juceString->toRawUTF8());

--------------------------------------------------------

References:

http://www.juce.com/forum/topic/adding-juce-existing-ios-project

http://philjordan.eu/article/mixing-objective-c-c++-and-objective-c++

http://www.juce.com/forum/topic/adding-juce-ios-project

http://www.juce.com/forum/topic/recommended-way-add-modularized-juce-existent-project


#2

Helpful stuff, thanks for sharing!