Unity Technologies Blog: Unity and iOS SDK 4.3

Unity Technologies Blog
A glimpse inside Unity Technologies...

Unity and iOS SDK 4.3
15 Jun 2011, 2:29 pm


Many of you have reported troubles submitting your applications built with iOS SDK 4.3 to the iOS AppStore. At the time the problem looked very complex and there were only few ineffective ways to trace it down, because all the troubles were happening after application gets post-processed for AppStore on Apple's side. We mailed all registered Unity iOS developers with some basic recipe how to get their applications onto AppStore:
Dear Unity iOS Developers,

Unfortunately, many (and probably all) Unity iOS applications built with iOS SDK 4.3 are crashing during the App Store Review process while still running successfully on developer’s devices. We have contacted Apple regarding this issue and received confirmation that this is of highest priority to them. Our iOS team is working on a solution as well, but due to complex nature of the problem it will take longer than expected to properly resolve. A currently known workaround is to keep using iOS SDK 4.2.Many users reported that applications built with Xcode 3.2.5 + iOS SDK 4.2 successfully pass the Apple App Store review process currently. OS SDK 4.2 is not publicly available on the iOS Developer site anymore, but it still can be downloaded via direct link. We want to assure you that building final applications with iOS SDK 4.2 provides all the features the Unity iOS run-time supports and is proven to work fine with devices running older generation iOS (3.x-4.2.x) as well as the newer devices running iOS 4.3.x (like iPad 2).
Please feel free to contact us if you have issues releasing your application to the App Store.
Regards,
The Unity Team
Since then we spent many hours listening to your stories in forums, analyzing your builds, trying out some ideas. Finally we nailed the issue. iOS SDK 4.3 introduced tiny problem in native code linker. In some circumstances it improperly calculates, how much code should be protected by AppStore code protection system, and embeds it into binary. The problem exposes itself only when AppStore protection is applied to the application. At the time few forum users reported about successful submission to the App Store using iOS SDK 4.3 and this led us to the solution (we would like to say big thanks to forum users "susantio" and "ratrodstudio"!). Our investigation of their projects revealed common use of special linker flag “-all_load” (which is required by some 3rd party ObjC plugins). Using this flag forces iOS SDK 4.3 native linker to properly calculate protected code size and so it solves the problem.
Unity 3.4, which is just around the corner, will include this flag by default, but you can try it sooner just my applying few changes to your Xcode project by hand.
Instructions how to add this flag to your release build when using Xcode 3.2.6 (SDK 4.3):
1. Open your project in Xcode.
2. In Xcode menu select Project->Edit Active Target.
3. In Configuration drop down select “Release”.
4. In Search field type “linker”.
5. Find the field named “Other Linker Flags” and double click on it.
Xcode3_config
6. Click “+” and add “-all_load”.
Xcode3_linkerflags
7. Clean all targets.
Instructions how to add this flag to your release build when using Xcode 4/4.0.2 (SDK 4.3):
1. Open your project in Xcode.
2. In Project Navigator click on your project.
3. On next pane select “Unity-iPhone” under TARGETS.
4. On next pane select “Build Settings”.
5. In Search field type “linker”.
6. Find the field named “Other Linker Flags” and double click on “Release” configuration near it.
Xcode4_config
7. Click “+” and add “-all_load”.
Xcode4_linkerflags
8. Clean all targets.
9. Make a distribution build by clicking "Product"->"Build For"->"Build For Archiving" (Note: don't use Product->Build, because it will make "debug" build by default and won't include "-all_load" flag).
We have received multiple confirmations from forum users that this helped them get into AppStore using iOS SDK 4.3. Also we are sharing all our findings with Apple and we hope that this will help to get some fix included into SDK update.
As always please feel free to contact us if you have issues releasing your application to the App Store. 

No comments: