Recommended way of upgrading Cocos2D?

Forums Programming cocos2d support (graphics engine) Recommended way of upgrading Cocos2D?

This topic contains 27 replies, has 9 voices, and was last updated by  hareball 2 years, 7 months ago.

Viewing 25 posts - 1 through 25 (of 28 total)
Author Posts
Author Posts
May 17, 2011 at 1:08 pm #231390

limtc
@limtc

How do you upgrade a project from 0.99.5 to 1.0? I tried a few ways and all have issues. Any suggestions welcome!

May 17, 2011 at 1:16 pm #329983

ruben301
@ruben301

Create a new project and then drag all of your classes and resources into the new project, make sure to modify the appDelegate, build settings and info.plist.

May 17, 2011 at 2:26 pm #329984

limtc
@limtc

Thanks!

I tried to create a new project, and found that the folder structure is all changed! Like if I create a project called “Doodle War HD”, then I will have a folder called “Doodle War HD”, which contains yet another folder “Doodle War HD” and the xproj file. At this point, I am pretty lost… is this the correct folder structure?

Where do I drag my files into? I assume we don’t care about folder structure and just drag everything into Xcode 4?

May 17, 2011 at 2:29 pm #329985

ruben301
@ruben301

into xcode 4 :D

May 17, 2011 at 2:48 pm #329986

Karl
@karl

In your project, delete the references to cocos2d, denshion, fontlabel, touchjson, etc (all the stuff in libs). Go into finder and delete their folders completely.

Now copy from the new cocos2d into the same place in your project folder. Then drag those folders into your actual project in Xcode (but don’t select “copy into project”).

Now recompile and fix any API calls that have changed since 0.99.5.

May 17, 2011 at 3:56 pm #329987

Questor
Participant
@questor

@limtc,

Did you happen to upgrade to XCode 4 at the same time as upgrading cocos2d?

If so, I would suggest doing one or the other first, rather than both at the same time. Also, it is worth noting that XCode 4.0 has alot of known issues. However, there have been a few minor updates since the major version release, though I have read many problem/issues continue.

May 20, 2011 at 9:53 am #329988

limtc
@limtc

Thanks all! I will try Karl method and see whether it works.

Questor, I upgrade to Xcode 4 first, then trying to upgrade my app. Xcode 4 is a wonderful IDE compared to 3.x (especially on how it is done to upload apps to iTunes Connect)!

May 20, 2011 at 10:16 am #329989

limtc
@limtc

Karl,

1) Deleted everything in the libs folder.

2) Drag the whole cocos2d folder? I tried linking in Xcode (not copy into project) to cocos2d-iphone-1.0.0-rc2 folder inside my game folder, and when it compiled, it got a lot of errors. Just want to confirm, is it the whole cocos2d-iphone-1.0.0-rc2 folder? As it is in my game folder, or same level as the game folder? These 2 files crashes with 36 errors and 86 warning: b2BroadPhase.cpp and b2CollideCircle.cpp.

3) Just copy the 5 folders (same with what’s in libs folder before deletion) over: TouchJSON, FontLabel, cocoslive, CocosDenshion, cocos2d – and compiled: better! Now wit 7 warnings and 1 error:

ld: library not found for -lcocos2d libraries

collect2: ld returned 1 exit status

Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1

Any help appreciated!

May 20, 2011 at 10:32 am #329990

limtc
@limtc

ruber301,

I faced a lot of problems as it seems that the structure has changed a lot. Copy files over, the resources are just thrown everywhere in a single folder in the new Xcode 4 template. Copy classes over, and it got duplicated files. Tried for about an hour trying to get things right, and gave up in the end frustrated.

Hope Karl method works… I just wanted to upgrade Cocos2d from a pretty recent 0.99.5 (which works fine in Xcode 4), and it seems that everything has changed!

May 20, 2011 at 11:51 am #329991

ruben301
@ruben301

Not all of your classes, just your own (that you created).

May 20, 2011 at 3:10 pm #329992

Karl
@karl

The basic idea is to replace any existing cocos2d code with the new versions. So if you have box2d in your project, you replace it with the new version. Same for TouchJSON, FontLabel, etc.

The best way to copy over is using Finder:

  1. Delete the old folders (cocos2d, TouchJSON, etc) in your project folder (using Finder).
  2. Copy the new replacement folders (subfolders, not the big cocos2d-xx folder) in from your freshly extracted cocos2d archive (using Finder).
  3. Go into xcode and delete the references (in Xcode, not Finder) to that stuff from your project (remove references only, don’t select to delete the files as well).
  4. Drag the folders from Finder into your Xcode project (Don’t “copy into destination”, and make sure you set the same target as the original files had).

So if your original files had their target set to “cocos2d libraries”, you need to set the new files you drag in to have the same target.

Beyond that it’s a matter of updating your code wherever it was using deprecated APIs or older class names.

May 20, 2011 at 3:20 pm #329993

limtc
@limtc

Thanks Karl, I think I have done 1), 2), 3) right. I am not sure about the target thing in 4), but I have “copy” (not into destination) them to Xcode. What do you mean by setting the target for Cocos2d? I have read through the Targets->Cocos2d, and don’t know what to do in Xcode 4?

I have copied the 5 folders (same with what’s in libs folder before deletion) over: TouchJSON, FontLabel, cocoslive, CocosDenshion, cocos2d – and compiled: better! Now ONLY 1 error!

ld: library not found for -lcocos2d libraries

collect2: ld returned 1 exit status

Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1

This is for simulator. The error is similar when compiled to iPad.

May 20, 2011 at 3:41 pm #329994

Karl
@karl

@limtc: Your project was set to build cocos2d as a library before. You need to re-add your new cocos2d stuff to the library target. I’ve made some screenshots to make it easier to follow:

First, find the target membership of your cocos2d files (usually it’s either “cocos2d libraries” or just part of your main target) by opening the right pane view and selecting a cocos2d .m file in the left pane. Target membership is shown on the right:

Now you can do the following:

  1. Delete the old folders (cocos2d, TouchJSON, etc) in your project folder (using Finder).

  2. Copy the new replacement folders (subfolders, not the big cocos2d-xx folder) in from your freshly extracted cocos2d archive (using Finder) into the same place you deleted the old ones from.

  3. Go into xcode and delete the references (in Xcode, not Finder) to that stuff from your project (remove references only, don’t select to delete the files as well).

  4. Locate the folders you previously copied into your project’s folder. Drag them from Finder into your Xcode project (Don’t “copy into destination”, and make sure you set the same target in “add to targets” as the original files had).

  5. Imgur gallery in case the img links don’t work: http://imgur.com/9UXcw

May 21, 2011 at 1:23 am #329995

limtc
@limtc

Thanks! This is very helpful! I really appreciate it and thank you from my heart.

I have done 2 things wrong – I didn’t copy them into the libs folder (I originally copied them to the main folder), and when I “copy” back I didn’t choose the cocos2d libraries as target. Now I have done both, and check a .m file in cocos2d folder that it is indeed the cocos2d target.

However, when I clean and compiled to simulator, I still got the same error message – this seem more like an architecture problem. Cocos2d seems to set to MacOS X as target! Any idea to fix this?

Ld “/Users/limtc/Library/Developer/Xcode/DerivedData/Doodle_War_HD-bnaixswjitmveuhesjiqsvmqrqwr/Build/Products/Debug-iphonesimulator/Doodle War HD.app/Doodle War HD” normal i386

cd “/Users/limtc/Documents/Projects/Doodle War HD”

setenv MACOSX_DEPLOYMENT_TARGET 10.6

setenv PATH “/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin”

/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/limtc/Library/Developer/Xcode/DerivedData/Doodle_War_HD-bnaixswjitmveuhesjiqsvmqrqwr/Build/Products/Debug-iphonesimulator -F/Users/limtc/Library/Developer/Xcode/DerivedData/Doodle_War_HD-bnaixswjitmveuhesjiqsvmqrqwr/Build/Products/Debug-iphonesimulator -filelist “/Users/limtc/Library/Developer/Xcode/DerivedData/Doodle_War_HD-bnaixswjitmveuhesjiqsvmqrqwr/Build/Intermediates/Doodle War HD.build/Debug-iphonesimulator/Doodle War HD.build/Objects-normal/i386/Doodle War HD.LinkFileList” -mmacosx-version-min=10.6 -all_load -ObjC -Xlinker -objc_abi_version -Xlinker 2 -framework CoreGraphics -framework Foundation -framework OpenGLES -framework QuartzCore -framework UIKit -framework AudioToolbox -framework OpenAL -lz -framework AVFoundation “-lcocos2d libraries” -o “/Users/limtc/Library/Developer/Xcode/DerivedData/Doodle_War_HD-bnaixswjitmveuhesjiqsvmqrqwr/Build/Products/Debug-iphonesimulator/Doodle War HD.app/Doodle War HD”

ld: duplicate symbol _main in /Users/limtc/Library/Developer/Xcode/DerivedData/Doodle_War_HD-bnaixswjitmveuhesjiqsvmqrqwr/Build/Products/Debug-iphonesimulator/libcocos2d libraries.a(main-57529A9CD5C31750.o) and /Users/limtc/Library/Developer/Xcode/DerivedData/Doodle_War_HD-bnaixswjitmveuhesjiqsvmqrqwr/Build/Intermediates/Doodle War HD.build/Debug-iphonesimulator/Doodle War HD.build/Objects-normal/i386/main.o for architecture i386

collect2: ld returned 1 exit status

Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1

May 22, 2011 at 1:43 pm #329996

limtc
@limtc

Still waiting for help… I have checked the project – “2 targets, iOS SDK 4.3″. The iOS deployment target is iOS 4.2, the cocos2d targeted family is iPhone/iPad. The project works fine on iPad using cocos2d 0.99.5.

I tried my best to follow exactly what’s mentioned above, and the result seems encouraging (only 1 error rather than many), except that it seems that it is using Mac OS X as target after upgrading! My guess is probably I need to do one more setting somewhere and I have checked around…

Please help!

May 25, 2011 at 9:38 am #329997

kakburk
@kakburk

I just did this upgrade myself and got the same error you have.

The reason is that you can only have one entry point to your project so you can’t having multiple mains (error: duplicate symbol _main).

Some of the folders you added contains tests that has main methods in them so I just removed them from the project.

Not sure I remember all but I did a search for “int main” and then removed tremor, libpng (from external) and TestsAndDemos (from denshion)

After doing this my project compiles fine.

GL!

May 26, 2011 at 10:56 pm #329998

limtc
@limtc

Thank You! So it wasn’t just me!

I will try it out!

Upgrade should not be so difficult…

May 26, 2011 at 11:38 pm #329999

limtc
@limtc

I think the direction is correct! I did a search and only found main in TestsAndDemos – I removed the whole folder (since we probably don’t need the demo code). I didn’t find tremor or libpng as I probably didn’t copy them to the project. I make sure that Xcode 4 only found 1 instance of “int main”.

I still got an error, and it is close – one more duplicated main! Any idea?

ld: duplicate symbol _main in /Users/limtc/Library/Developer/Xcode/DerivedData/Doodle_War_HD-bnaixswjitmveuhesjiqsvmqrqwr/Build/Products/Debug-iphonesimulator/libcocos2d libraries.a(main-57529A9CD5C31750.o) and /Users/limtc/Library/Developer/Xcode/DerivedData/Doodle_War_HD-bnaixswjitmveuhesjiqsvmqrqwr/Build/Intermediates/Doodle War HD.build/Debug-iphonesimulator/Doodle War HD.build/Objects-normal/i386/main.o for architecture i386

collect2: ld returned 1 exit status

Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1

May 27, 2011 at 12:45 am #330000

kastrum
@kastrum

Hi Everyone! You all have posted some useful instructions. However, my concern is whether these same methods apply when you have your code under source version control. I have my code managed by Subversion via XCode. I have a local working copy on my macbook pro, and I have my Subversion repository hosted online. I find that when I make major changes, it can sometimes be a pain to commit, especially when you are deleting files from the repository.

I have been waiting for Cocos2D version 1.0 stable to come out before I upgrade to XCode 4, because I hate having up constantly update my code once I get everything working.

However, my question is, does anyone here have experience updating Cocos2D + Xcode4 when your code project is source controlled by Subversion? If you do, do the same methods listed above apply? Or do we do things a bit differently?

May 27, 2011 at 6:10 am #330001

kakburk
@kakburk

limtc, it seems you still have a main left in the cocoslib, have you cleaned and rebuilt after removing the one you found?

I guess there could also be a main with different return type like void, try a search for only “main”

May 27, 2011 at 9:09 am #330002

limtc
@limtc

Yes, works now! The final issue is that I have the wrong target after the removing of those files. Once done, I clean and compiled – yes it now run!

Hurray!

What you suggest is essential! Someone should collect the instructions in this thread and make an official FAQ!

May 27, 2011 at 9:42 am #330003

limtc
@limtc

Special thanks to everybody especially Karl for the excellent mini tutorial, and Kakburk for the crucial last step!

THANK YOU!

July 6, 2011 at 10:21 am #330004

Jamorn
Participant
@souleaterjh

I had the same questions regarding updating cocos2d and this post really helped me! Thanks Karl.

I’ve compiled this topic into a blog post, of course with credit to Karl, for easy reference. You can find the post here:

http://jamornh.posterous.com/upgrading-your-cocos2d-version-from-a-lower-v

Hope this helps other people going through the same problem.

July 15, 2011 at 2:10 am #330005

limtc
@limtc

Very well done! Thanks all!

I just follow the article and upgraded to 1.0!

July 15, 2011 at 2:59 am #330006

limtc
@limtc

I tried to upgrade my Mac game to 1.0 following the instruction.

Seems the same, except that there seems to be only 2 folders: cocos2d and CocosDenshion. Follow the process, compiled fine, build, and run the app in Debug, started, then crash.

Is the Mac using the same cocos2d and CocosDension? Or do I need some other files? Anybody got good success story on upgrading the Mac build and how?

Viewing 25 posts - 1 through 25 (of 28 total)

You must be logged in to reply to this topic.