12

I am using Xcode 4.2 and building a game for iphone (from iOS 3.0 - 5.0). Does cocos2d support ARC? What modifications needs to be made to convert code written in previous versions?

If I use the strong and weak keywords for variables and set compiler to LLVM GCC 4.2, what will be the results? Is it a necessity to change compiler to 3.0 to support ARC?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Vishal Avalani
  • 381
  • 3
  • 14

3 Answers3

10

Cocos2d v1.1 and v2.0 are compatible with ARC. However, the cocos2d code itself does not use ARC and there are no templates provided by cocos2d that you can use to start programming with ARC. You are required to add a seperate static library target for the cocos2d files yourself.

As Ankit pointed out, Tiny Tim Games made the necessary changes to a forked version of cocos2d-iphone to make it ARC compatible. These changes have been integrated into the development version and should be available in the cocos2d v2.x branch. I've since written a tutorial to enable ARC in a cocos2d (2.0) project.

It was said that cocos2d itself will be converted to use ARC internally in v2.1 or v2.2.

It's important to note that there are no plans to officially support ARC in the cocos2d v1.x branch because the v1.x line is supposed to remain backwards compatible with 1st generation devices and iOS 3.x. But general ARC compatibility has been added to v1.1.


Kobold2D fully supports ARC and has it enabled in all 15 template projects for almost two months now. Kobold2D uses the latest stable versions of cocos2d-iphone 1.x and 2.x. Just start a new Kobold2D project and you're set to work with cocos2d and ARC.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • @LearnCocos2D Why don't you integrate some of the Kobold2d features (E.g. scripting with lua) with Cocos2d? In this way you will not have to split the developers base in Cocos2d vs Kobold2d people and we will have better quality products overall as more developers will contribute to the same project and deliver overall better quality products in less time (as well as not having to dismiss the books we bought - e.g. Learn Cocos2d for iPhone and iPad game development) – mm24 Jun 18 '12 at 12:30
  • 1
    Hmmm the short answer is the general difference in direction. Lua vs. Javascript. Usability vs. performance. All-in-one solution vs. wanting to remain "pure". What's important to users vs what's important to Zynga. Getting code updates released timely vs waiting many weeks for a pull request to be accepted and then waiting several more weeks for the next official release. – CodeSmile Jul 23 '12 at 12:42
2

Even though Cocos2d does not support arc but there is way in which you can use both of them together, and that is by cross project referencing. You can learn how to do it by refering this.. cocos2d and ARC

Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115
1

Even easier, just get my cocos2d-ARC template here: https://github.com/Elland/Cocos2d-iphone-ARC-template hassle free, just rename the project to your desired name and you're set :)

Elland
  • 207
  • 3
  • 7