Search code examples
objective-cmacoscocoasandboxxcode6.1

OSX Cocoa Bad Instruction crash


I am developing an app (for like a year) and it works fine , when it comes to submitting to App Store -> all my problems started:

1)The app store would me to make my app to run in a sandbox(Why Apple ? Why !?). It took like 2 days to understand why just toggling "ON" in capabilities doesn't make it... etc ... in the end I somehow managed to convince my app to run in sandbox.

2)now the app passing the validation fine and can be submitted to the bloody App Store However when I checked the app before the submitting I discovered that it simply don't want to work (running from Xcode or product).

It just crashes before it comes to `applicationDidFinishLaunchingWithOptions" The crash itself is even more epic "thread1: EXC_BAD_INSTRUCTION (code=EXC_i386_INVOP, subdued = 0x0)"

and I see a lot of assembly lines -> from the comments inside the assembly I understood that the app tries to "Open" a sandbox , but then comes the bad instruction :( ud2

The stuck I see is:

_libseinit_initialize_once
0 _libsecinit_setup_secinitd_client
1 _libsecinit_initialize_once
2 _dispatch_client_callout
3 dispatch_once_f
4 libSystem_initializer
5 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) ()

I think the rest are not relevant since they are all about some IMAGE loader :/

lately I ensured that removing the app sandbox key or setting it to NO Resolves my Issue but if I do so i getting back to issue number 1

so I kinda stuck with an egg and a turkey problem :(

maybe some 1 knows any interesting workaround or solution to submit the bloody app to the mighty app store ?


Solution

  • Sounds like what Apple document here:

    OS X’s enforcement of container integrity impacts your development and distribution cycle. This is because, in the course of creating and distributing an app, the app is code signed using various signatures. Here’s how the process works:

    Before you create a project, you obtain three code signing certificates from Apple: a development certificate, a distribution certificate, and (optionally) a Developer ID certificate. (To learn how to obtain these code signing certificates, read App Distribution Guide.) When used in conjunction with the corresponding private keys from your keychain, these certificates form three separate digital identities. For development and testing, you sign your app with your development identity. When you submit a version to the app store, you use your distribution identity. If you are distributing a version outside the app store, you use your Developer ID identity.

    When the Mac App Store distributes your app, it is signed with an Apple code signature. For testing and debugging, you may want to run both versions of your app: the version you sign and the version Apple signs. But OS X sees the Apple-signed version of your app as an intruder and won’t allow it to launch: Its code signature does not match the one expected by your app’s existing container.

    If you try to run the Apple-signed version of your app, you get a crash report containing a statement similar to this:

    Exception Type: EXC_BAD_INSTRUCTION (SIGILL) The solution is to adjust the access control list (ACL) on your app’s container to recognize the Apple-signed version of your app. Specifically, you add the designated code requirement of the Apple-signed version of your app to the app container’s ACL.