For the fast few weeks I've been working with Orx SVN and Xcode 4.2.1 to develop for iOS. This is my first experience with iOS dev and Xcode, so please excuse any newbie mistakes.
For testing the Debug version of my project on the device, everything seemed to work pretty well in the sample project from SVN.
When I changed to the Release version, though, things didn't work quite right. Basically I noticed some strange behavior in the simulator and on the device. Objects wouldn't delete properly and there would be crashes.
It seems the release version of the orxTest target was still linking the debug version of orxLIB and this was causing the problem.
The orxTest target has this option set by default: Summary | Linked Frameworks and Libraries | liborxd.a | Required
I set this option to make sure it links the correct version of orxLIB for the Release version: Build Settings | Linking | Other Linker Flags | Release | Any Architecture | Any SDK | <path-to-orx-source>/orx/code/lib/static/iphone/liborx.a
After making that change, the Release version seems to correctly link the release version of orxLIB and the strange behavior disappeared.
Comments
I don't have XCode 4 at home so, if you don't mind, you could send me the project file, I'll put it on the SVN.
I guess the conversion from the XCode3 format doesn't work that well.
- Retrieve orx-iphone.xcodeproj from SVN
- Remove this:
Targets | orxTest | Summary | Linked Frameworks and Libraries | orxlibd.a
- Add these options:
Build Settings | Linking | Other Linker Flags | Debug | Any Architecture | Any SDK | ../../../lib/static/iphone/liborxd.a
Build Settings | Linking | Other Linker Flags | Profile | Any Architecture | Any SDK | ../../../lib/static/iphone/liborxp.a
Build Settings | Linking | Other Linker Flags | Release | Any Architecture | Any SDK | ../../../lib/static/iphone/liborx.a
Tested Debug and Release in both iPhone Simulator and my iPod Touch and no more freezing. The Release version of the orxTest freezes and crashes in Simulator and on device without these changes.
Note: I did not change the Xcode compatibility level, so I think the project I attached should also still work in Xcode 3, but I can't test that. https://forum.orx-project.org/uploads/legacy/fbfiles/files/orx_iphone.zip
I'll try that during the week, whenever I get the opportunity.
I guess you could make the changes I described to the Xcode 3 project. Here is a link describing how to find the "Other Linker Flags" in Xcode 3:
http://developer.adfonic.com/index.php/IOS_SDK
Let me know if I can help in any other way.
If not, let me know the exact version of Xcode you're using and I'll try to send you another one that hopefully works...
Thanks,
Alex
@godexsoft: There's nothing I hate more than XCode 3 except XCode 4. I'll get over it and will install it. Eventually.
I'll also update the project file to link against orx using explicitly defined command line parameters (which I'm using in my game projects as it's the only way to go when using a pre-compiled library, afaik).
Everything should be on svn within 10 mins. Let me know if it worked for XCode 4.
So build of orxTest fails if the liborxd hasn't been built yet... if it has, the build would link with both debug and release, which is probably not what we want.
But if you remove that reference, it works unconditionally here.
The reason is that on the mac project there's a 'All' target that will reference orxLib and make sure it's compiled before the other targets. I couldn't find a way to create the 'All' target for iPhone.
Unless you know how to create such a target, a solution would then be to create two projects, one for actually compiling orx for my needs and one other that would be for the test project and that would link against the compiled library instead of compiling orx all the time. Not ideal but if you have another idea, let me know!
See this screenshot for the "scheme" where this is illustrated: http://imgur.com/LkPFd
The one exception to this I've found is when changing architectures. For example, if I've built and tested the project on iPhone Simulator, I have to explicitly rebuild orxLIB before I can build the project for a real iOS device. Otherwise, Xcode sees the iPhone Simulator orxLIB already exists, tries to link to it, and fails.
And XCode 4 converts incorrectly the project file if I set the dependency in XCode 3 using the target sub-tree and it ends up in linking against the wrong version. I'll try to find more info about that next week end.