I've had heaps of trouble importing OALSimpleAudio into my Cocos 2.X project.
The app is quite big.
What is the best way for me to import Cocos 3.0 into an existing project?
The final error looks like this:
This is what I've done so far:
The Cocos 3.0 Libraries stuff is brought into libs folder.
ARC flags are set for Cocos 3.0 files as this is a non-ARC project and Cocos 3.0 uses ARC.
Relevant frameworks used in Cocos 3.0 template put in for project.
Architecture problem appears when using simulator, complains for architecture i386. When I use an actual device (iPad) as opposed to simulator it complains for architecture armv7 in the exact same way as picture 3 above.
Using the official release and install instructions here kstenerud.github.io/ObjectAL-for-iPhone was sufficient.
Not using the whole Cocos 3.0 reduced the complexity of transition. However it was also necessary to make sure that all instances of the old audio engine were deleted - before then even though it ran without errors the audio didn't work.
Related
I'm following a tutorial to learn to make a cocoapod. Unfortunately the tutorial instructs to create a "Cocoa Touch Framework" when that no longer exists in current XCode.
What's the current equivalent, that I can use for the purposes of this tutorial / to make a cocoapod?
The answer isn't too complicated: it's the "Framework" option.
A Static Library is pure object code (a.k.a. compiled code), and it cannot contain images, storyboards, etc. Pure object code also means you can't read the code files which makes it pretty much un-debuggable.
A Metal Library lets you develop using the Metal library, basically for 3D graphics and GPU stuff.
Framework is a cocoapod framework. Tried and tested and loved by all Apple Developers.
I got an existing Objective-C project. Now I decided to rewrite some code and add Cocos2d to it. I know this framework for a long time and I recently discovered that they stopped the support for Cocos2d and created a new version called Cocos2d-x. There I found the Swift library and I asked me how to use the Cocos2d-Swift framework in my existing Objective-C project ? A step by step tutorial would be great. I searched a bit in the internet and found this:
Stackoverflow Link
But since the post is from 2011 it does not cover how to add the swift library, since Swift wasn't introduced at this moment.
Cocos2d-swift is a bit of a misnomer : it is currently written in objective-c. The software is now distributed with SpriteBuilder, that is why there is no 'install.sh' as there used to be. So integrating it into your project should not be too difficult. Use SpriteBuilder (from the AppStore) to create a 'blank' SB project, and see how cocos2d is integrated in there. Then, what you see is what you integrate !
caveat : Cocos2d is now ARC, so it is best your project defaults ARC. Otherwise you will have to do a lot of Xcode click-click-click to make the reference count strategy file specific.
An error occurs when compiling cocos2d-iphone v2.x and including arm64 architecture. The error is in the assembly code for kazmath. Is there a fix for this? (other than removing arm64)
libs/kazmath/src/neon_matrix_impl.c:
Unknown register name 'q0' in asm
Well, maybe no big deal... would be nice to support iPhone 5s etc fully with existing code.
I guess this is fixed or will be fixed in the cocos2d 3.x line. https://github.com/cocos2d/cocos2d-iphone/issues/534
Correct, cocos2d-iphone v3 does build successfully for the arm64 architecture, v2.x does not.
Even though the compiler warnings/errors are relatively easy to fix, there are a number of 64-bit compatibility issues that remain in v2.x (like CGFloat vs float mismatches and others) which means it's not recommended to enable arm64 builds for v2.x unless you're prepared to debug and fix these issues yourself. More so if you use 3rd party extensions which haven't been tested with arm64 either, for example anything in the cocos2d-iphone-extensions project.
Since currently no one is assigned to work on the v2.x branch and I don't expect v2.x to receive any future updates at all it's probably best to not include arm64 code (not much to gain anyway). Then start your next project with cocos2d-iphone v3.
I also had this problem in my one of old projects with Cocos2d.
I've downloaded Cocos2d v3, and copied the "kazmath" folder only to my older project, and replaced them.
If you don't want to change all the files, change :
#if defined(__ARM_NEON__)
into
#if defined(_ARM_ARCH_7)
By the way, I'm trying to update fully to the Cocos2d v3, and I think that is the right solution for this. even though my problem is handled, it is still problematic in general.
Cocos2D 2.2 now has 64 bit support!
You can download version 2.2 form here.
Upgrade your karmath library with cocos2D v3 kazmath lib (https://github.com/cocos2d/cocos2d-iphone/tree/develop-v3/external/kazmath).
It works for me (on iPad Air)
I solved in this way:
Downloading Cocos2D 2.2 here as suggested by #appzYourLife
Replaced folders cocos2d and CocosDenshion inside xcode project folder with folders of version 2.2
In folder kazmath/src edit mad4.c and neon_matrix_impl.c and replace line:
#if defined(__ARM_NEON__)
with
#if defined(_ARM_ARCH_7)
I might sound lazy but I am slightly confused on how to proceed on this subject. I have followed this guide which is very well done.
My goal is to convert the Cocos2d v1.x game project to Cocos2d v2.x and then refactor the project code to ARC.
To get started I created an empty HelloWorld Cocos2d v2.x project and created the v2.x static library (as from Steffen's guide). I then rafactored the code to ARC and the HelloWorld worked smoothly.
The issue is when I try to add to the same project the classes I had already written that don't complain to ARC (assuming that there will be not many Cocos2d v2.x vs v1.x problems - e.g. use of deprecated methods and classes like TouchJSON - my project doesn't at least as far I can see). So, I added a couple of Game classes that don't depend from the rest of the game (to reduce the number of potential Cocos2d v2. Vs v1 issues) to the project to see if the ARC covnersion worked for those as a proof of concept. After adding them I choosed: EDIT->Refactor option from XCode.
But now the compiler gives me some ARC warning messages like "ARC forbids explicit message send of autorelease" in the following method:
return [[[self alloc] init] autorelease];
Or similar problems with the dealloc method already written.
I was assuming that EDIT->Refactor would have changed the added code but it appears to work only once. Any hint on this? should I add all my code to the new project template before refactoring the code?
EDIT:To verify whether it was an XCode bug I created an empty iOS project with no Cocos2d libraries and then converted it to ARC. Then created a new empty sublcass of NSObject and added a dealloc method and run the conversion again, it did work! So I might have not followed correctly some of the steps to create and link to the static library..
In addition to this there are some other small issues (not XCode related, but Cocos2d v2.x related), like the fact that the CDXPropertyModifierAction is not automatically included to the CocosDenshion folder and I had to add it to the project after creating the static library (when I noticed the issue).. but I guess this is more template creation related.
Thanks for reading!
so, yeah, I can confirm that the solution in the comment did work. As usual with some IT things is was just about playing around a bit with the various options and see if it works changing the prospective (its not a bug but is me being stupid or lazy).
What worked for me was to use the EDIT->Refactor from the XCode menu and de-select the files created in the first instance by the Cocos2d 2.x template that I had converted after creating the static library (e.g. main.m and AppDelegate.m) (ask if this is unclear).
This converted smoothly all my newly converted Cocos2d 2.x classes into ARC complaint classes and yeah, I have my project fully supporting both Cocos2d 2.x and ARC :).
Please find below the screenshot of the files I deselected to get it working:
Good day
I have created a static library with Xcode. Then I compiled my ANE using adobe's ADT tool. Thereafter I've included the ANE in my FlashBuilder project. However, when attempting to package my project, I get the following error:
"Error occurred while packaging the application:
Undefined Symbols: "_obj_storeStrong", referenced from ...
.
"_obj_release", referenced from ...
.
"
My guess is that ARC is probably not supported for ANE's. I'm guessing that this is probably due to the fact that FlashBuilder is recompiling the entire AIR + the native libs into one iOS application, probably using their own compiler or something (which is why Air apps for iOS can be compiled on windows platforms as well), and this compiler is probably not 4.3 ready yet?
I have attempted adding the flag -fobjc-arc to my ios-platformoptions.xml as well (where this file is the parameter to the -platformoptions flag of adt), but still no joy. It results once again in an error when packaging. Perhaps any other flag I can try to use here?
Any corrections, suggestions, alternative ideas or comments will be most welcome. I am very new to Xcode, Objective C and ANE, so please excuse any incorrect statements or assumptions, and please correct me on these.
I would be glad if somebody can please confirm weather I am correct with my assumption that I cannot use ARC at this stage on ANE's.
Thanks
Christo
START EDIT:
Very late update, sorry.
You might be able to use ARC after all. There is a library called arc lite that I forgot to mention and it works. I created an ANE for MapKit on iOS targeting the 5.0.x SDK. When I tried to move to a device that only had 4.3.x ( could have been 4.3.3 or 4.3.5 ) the app crashed or would not compile. I found information on the arc lite library that is included in the newer sdks, followed the instructions on how to include this library and pow! A working ANE on a 4.3.x device without rewriting my code!
Hope all of this helps and half of my original comment :)
Markus
END EDIT
I don't think ARC is supported just yet. There isn't much to go on in terms of settings or examples of what the settings should be in Xcode. Take a look at any of the Xcode ANE projects you can get your hands on. You will see that most or all of the projects have:
Object-C Automatice Reference counting = NO
Objective-C++ Automatic Reference counting = NO
Take a look at the following:
Vibration ANE - On Adobe Devnet site
Liquid Photo - http://www.liquid-photo.com/2011/10/30/common-native-extension-issues/
Liquid Photo - http://www.liquid-photo.com/2011/10/28/native-extension-for-adobe-air-and-ios-101/
There are a lot of examples in Github but you have to find them via Google. Pull down the Xcode ANE projects and compare the settings.
Hope this helps!!!
Markus