Last Updated: February 25, 2016
· alexhajdu

How to add static SimpleAudio cocos2d engine to your ARC project

I was developing simple game for my personal iPad project. During development I mixed audio with AVAudioPlayer for background music and AudioServices System Sound for SFX. After couple a days I accidentally realised there are volume issues on iPad. The background music was affected with overall volume and SFX volume depended on volume you have set for iPad sound effects. For example if your Sound Effects volume was at 0, you heard no SFX in the game even the volume was 100%. No way! Probably there are also other ways but I decided to use SimpleAudioPlayer included in cocos2d library cocosDenshion. Ok, here we go.

When you have project using ARC - you have two options if you want to use cocos2D. Making static library from cocos2d or using prepared libraries from Kobold2D. I chose 2nd option.

1) Install Kobold2d. Install is pretty straightforward so let's go directly to the next step.

2) In Xcode - make Workspace (if you are developing from scratch) or just drag Kobold2D-Libraries.xcodeproj to Project Navigator of your existing project. Xcode asks you for creating a workspace. Create one and your screen will looks like this.


NOTE: Be sure Kobold2s is added as sibling not as a child.

3) In Project Navigator choose project where you want to use the static library. In Targets - Build Phases - Link Binary With Libraries select + and then choose library you want to use. In my case it's libcocosdenshion-ios.a


4) Next you will need headers. In project navigator select CocosDenshion and drag it to your project. Your autocomplete now recognises Cocosdenshion headers.


5) Open copied folder CocosDenshion and delete all .m files! This is very important step because when missed you got lot of ARC issues when build. You will end up with this.


6) Add required frameworks: OpenAL, AudioToolbox, AVFoundation

That's it! It looks like very simple steps but it tooks me almost 3 days of investigating, learning, googling and stackoverflowing. Enjoy :)

1 Response
Add your response

Hi Dude,
Thank for you blog post. I have same problem in my game, I did as you mentioned above but I do not know what should I do next. still after adding this library problem exist. Should I replace some lines in my code also? or just adding such this library would solve the problem. I would really appreciate if you can help me through this.

over 1 year ago ·