AudioUnit new project template for Xcode 5/6/7

AudioUnit new project template for Xcode 5/6/7

template_UI

I finally got around to this: When apple updated past the first version of Xcode 4, they pulled the AudioUnit new project templates and never replaced them. This led to much pain and gnashing of teeth on the part of developers and would-be developers looking into AudioUnits for the first time. So with much pain and annoyance, I spent the weekend updating their ‘most recent’ AudioUnit effect template to make them compatible with the most recent Xcode versions (as well as making a few personal changes).

SETUP:
I included those instructions in a readme file with the archive, but let me explain here in greater detail. This should build a working project right out of the box after these three steps:

1) Download the template: http://www.solamors.com/ACK_Audio_Unit_Effect_Cocoa_UI.zip

2) Drop this template in either ‘home/Library/Developer/Xcode/Templates’ or ‘/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates’

3) Make sure to have Apple’s Core Audio Utility classes’ “CoreAudio” folder in the top level of your developer directory — the default now is in the Xcode.app: /Applications/Xcode.app/Contents/Developer/… . (You can alternatively change the path to the source files in the *.xctemplate if you prefer a different location).

template_install

Now you are good to go! Here is the result:

template_built

USING THIS TEMPLATE:
Make a new project:

template_new

Select our new template:

template_template

and set our options:

template_options

“Product Name:” will be both our project and product name.
“Organization Name:” is either your name or your company.
“Organization Identifier:” is your 4-char manufacturer code from Apple (just make it up if you don’t have one, just make sure that it is 4 letters.
“Subtype:” is the unique 4-char identifier for you plugin. Make sure it is UNIQUE to each plugin.

You will be presented with a window something like this:

template_build

You can see that it is a very simple structure, with all the relevant files in the main directory. I tried not to obscure anything important or convolute the code with too many options. I added localized project strings and version plists to the template directory for convenience, but I did not include them in the default build. Those can be added to the project to *.xctemplate plist if you wish.

MISC OPTIONS:
Since I left MOST of the options at the Apple default values, you may want to change them to suit you. If left as-is, it will build with the most recent SDK in 64-bit mode only, and without ARC. I modified the template to provide legacy support for 32-bit and the carbon component manager resource, just because I like supporting older gear where possible. However, I did not try any of the PowerPC SDKs because I don’t have a machine to test them on… sorry.

The default build location is the DerivedData folder. If you wish, you can add a script build phase to move the build to your plunges folder. This is the script that I use:

rm -rf $HOME/Library/Audio/Plug-Ins/Components/$PRODUCT_NAME.component
cp -r “$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.component” “$HOME/Library/Audio/Plug-Ins/Components/$PRODUCT_NAME.component”

Simply click the + to add a script phase:

template_addphase

Then past the script:

template_script

In the near future, I will write a blog on customizing the template, but for now… Happy coding!

-Alex

 

(UPDATE 12/2015: confirmed working in Xcode 7.2)

Advertisements

About alexkenis

Guitarist, philosopher, tinkerer

5 comments

  1. Hey, I downloaded the template and every time I try to run a blank template it gives me this error.
    /Applications/Xcode.app/Contents/Developer/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r:74: ### /Applications/Xcode.app/Contents/Developer/usr/bin/Rez – Undefined variable (RES_ID) not allowed in expression.
    /Applications/Xcode.app/Contents/Developer/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r:74: ### /Applications/Xcode.app/Contents/Developer/usr/bin/Rez – Expected number, but got ‘,’
    /Applications/Xcode.app/Contents/Developer/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r:78: ### /Applications/Xcode.app/Contents/Developer/usr/bin/Rez – Undefined variable (RES_ID) not allowed in expression.
    /Applications/Xcode.app/Contents/Developer/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r:78: ### /Applications/Xcode.app/Contents/Developer/usr/bin/Rez – Expected number, but got ‘,’
    /Applications/Xcode.app/Contents/Developer/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r:82: ### /Applications/Xcode.app/Contents/Developer/usr/bin/Rez – Undefined variable (RES_ID) not allowed in expression.
    /Applications/Xcode.app/Contents/Developer/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r:82: ### /Applications/Xcode.app/Contents/Developer/usr/bin/Rez – Expected number, but got ‘)’
    /Applications/Xcode.app/Contents/Developer/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r:88: ### /Applications/Xcode.app/Contents/Developer/usr/bin/Rez – Undefined variable (RES_ID) not allowed in expression.
    /Applications/Xcode.app/Contents/Developer/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r:88: ### /Applications/Xcode.app/Contents/Developer/usr/bin/Rez – Expected number, but got ‘,’
    /Applications/Xcode.app/Contents/Developer/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r: ### /Applications/Xcode.app/Contents/Developer/usr/bin/Rez – Since errors occurred, /Users/JoshuaGonzales/Library/Developer/Xcode/DerivedData/okay-crqydipwmhigxkgyxvlgrpiaakzq/Build/Intermediates/okay.build/Debug/okay.build/ResourceManagerResources/Objects/AUResources.rsrc’s resource fork was not written.
    Command /Applications/Xcode.app/Contents/Developer/usr/bin/Rez failed with exit code 2

    do you know how to fix it? I tried everything.

  2. I tried the template again with the new Xcode 7.3, and it works fine for me. MAYBE the rez bundle identifier is malformed? I would check to be sure it is 4-characters long, and includes only uppercase and lowercase letters, and then try again.

  3. geekomancer

    How to get the CoreAudio SDK? I can’t find it anywhere?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: