How To Enable ARC in a Cocos2D 2.X Project
8 posts
• Page 1 of 1
How To Enable ARC in a Cocos2D 2.X Project
This is the official thread to discuss the following blog post: How To Enable ARC in a Cocos2D 2.X Project
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

rwenderlich - Site Admin
- Posts: 1776
- Joined: Thu Dec 23, 2010 4:14 pm
- Has thanked: 26 times
- Been thanked: 186 times
Re: How To Enable ARC in a Cocos2D 2.X Project
Thank you so much for posting this! I almost gave up doing some of the Cocos2D tutorials, silly me. Other methods to make Cocos2D arc compatible were blowing up my computer.
Where would newbies be without this site?
Where would newbies be without this site?
- Romyilano
- n00b
- Posts: 3
- Joined: Fri Sep 07, 2012 9:00 pm
- Has thanked: 0 time
- Been thanked: 0 time
Re: How To Enable ARC in a Cocos2D 2.X Project
great tutorial. This is exactly what I needed to get back to cocos2D. I stopped developing for cocos2d in the 0.9.8 era and when i started again after all this time it left me confused. Thanks for this tutorial.
Re: How To Enable ARC in a Cocos2D 2.X Project
I disagree flagging on a per-source-file basis with -fno-objc-arc. It is a way to do it, but it will be pretty hard to maintain your code when you update Cocos2d! Instead take a look at another approach : http://www.learn-cocos2d.com/2012/04/enabling-arc-cocos2d-project-howto-stepbystep-tutorialguide/
Here's a quote from Steffen in that tut:
Here's a quote from Steffen in that tut:
Warning: Some recommend to use the -fno-objc-arc Compiler Flag to disable ARC on a per-source-file basis. This is only helpful if you have very few source code files which require this flag where an extra static library target would be overkill. Since you’ll have to add the flag to each cocos2d source code file individually – one-by-one – and there being anywhere between 100 and 150 source files, I strongly discourage going down this road. Plus it will be a maintenance nightmare whenever you upgrade cocos2d.
-

World of A - Hacker
- Posts: 22
- Joined: Thu Apr 05, 2012 3:05 pm
- Has thanked: 3 times
- Been thanked: 5 times
Re: How To Enable ARC in a Cocos2D 2.X Project
@World of A: Heh, and I disagree with that :]
That is actually untrue - if you select the files and hit "Enter" in Xcode you can set all of them at once.
So upgrading to a new version of Cocos2D is no problem, since setting that flag on the files only takes < 10 seconds. :]
I'm not saying the library approach is bad - there are some nice things about doing it that way - but this way has the advantage of being nice and easy.
- Code: Select all
Since you’ll have to add the flag to each cocos2d source code file individually – one-by-one – and there being anywhere between 100 and 150 source files, I strongly discourage going down this road.
That is actually untrue - if you select the files and hit "Enter" in Xcode you can set all of them at once.
So upgrading to a new version of Cocos2D is no problem, since setting that flag on the files only takes < 10 seconds. :]
I'm not saying the library approach is bad - there are some nice things about doing it that way - but this way has the advantage of being nice and easy.
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

rwenderlich - Site Admin
- Posts: 1776
- Joined: Thu Dec 23, 2010 4:14 pm
- Has thanked: 26 times
- Been thanked: 186 times
Re: How To Enable ARC in a Cocos2D 2.X Project
I just updated cocos to latest version cocos2d-iphone-2.1-rc0a, followed all the steps, seems working fine but there is a warning in appDelegate.m which worries me.
inside the method:
the warning says:
sending 'UINAvigationController *_strong to parameter of incompatible type 'id<CCDirectorDelagete>'
Is this something I should ignore, or should I do anything else.
inside the method:
- Code: Select all
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[director_ setDelegate:navController_];
}
the warning says:
sending 'UINAvigationController *_strong to parameter of incompatible type 'id<CCDirectorDelagete>'
Is this something I should ignore, or should I do anything else.
- Pianisimo
- n00b
- Posts: 2
- Joined: Tue Feb 19, 2013 2:19 pm
- Has thanked: 0 time
- Been thanked: 0 time
Re: How To Enable ARC in a Cocos2D 2.X Project
I tried the static library approach... ran into errors. this method worked for me, so yes this is easier 
Mark W - A causal Flash designer now learning cocos2d (let the fun begin ^_^)
-

sir_seagill - Hacker
- Posts: 15
- Joined: Sat Dec 25, 2010 10:57 am
- Has thanked: 1 time
- Been thanked: 0 time
Re: How To Enable ARC in a Cocos2D 2.X Project
I've followed all the steps you've suggested, but when I build I get an error message: 'Expected ';' at end of declaration list' for this line in the AppDelegate.h file:
CCDirectorIOS *_unsafe_unretained director_; // weak ref
which seems strange, since the ';' is there. I'm using Xcode 4.5.2.
CCDirectorIOS *_unsafe_unretained director_; // weak ref
which seems strange, since the ';' is there. I'm using Xcode 4.5.2.
- RHerrema
- n00b
- Posts: 2
- Joined: Wed Feb 06, 2013 2:52 pm
- Has thanked: 0 time
- Been thanked: 0 time
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: Google [Bot] and 4 guests
