问题
I write an app for OS X and when I archive the app and export it as an application and try to open then it crashes with Code Signature Invalid error.
I have created Mac App Distribution, Mac Installer Distribution, Developer ID Application, Developer ID Installer certificates and distribution provisiong profile. The app is sandboxed and I tested it on Mavericks.
Exception Type: EXC_CRASH (Code Signature Invalid)
Exception Codes: 0x0000000000000000, 0x0000000000000000
VM Regions Near 0x7fff71ce90a8 (cr2):
__LINKEDIT 00007fff67043000-00007fff67057000 [ 80K] r--/rwx SM=COW /usr/lib/dyld
--> Submap 00007fff70000000-00007fff80000000 [256.0M] r--/rwx SM=PRV process-only VM submap
unused shlib __DATA 00007fff708d3000-00007fff730dc000 [ 40.0M] rw-/rw- SM=COW system shared lib __DATA not used by this process
Thread 0 Crashed:
0 dyld 0x00007fff66fd1028 _dyld_start + 0
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x000000000000000d rbx: 0x0000000000000000 rcx: 0x0000000000000000 rdx: 0x0000000000000000
rdi: 0x0000000000000000 rsi: 0x0000000000000000 rbp: 0x0000000000000000 rsp: 0x00007fff5eda9d30
r8: 0x0000000000000000 r9: 0x0000000000000000 r10: 0x0000000000000000 r11: 0x0000000000000000
r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x0000000000000000 r15: 0x0000000000000000
rip: 0x00007fff66fd1028 rfl: 0x0000000000000201 cr2: 0x00007fff71ce90a8
Logical CPU: 0
Error Code: 0x020000f4
Trap Number: 133
Binary Images:
0x7fff66fd0000 - 0x7fff67003817 dyld (???) <D1DFCF3F-0B0C-332A-BCC0-87A851B570FF> /usr/lib/dyld
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 47204
thread_create: 0
thread_set_state: 1299
There is something wrong with the distribution provisioning profile. When I set none or mac team provisioning profile for release then it works. I use iCloud and In-App Purchase.
The problem started when I enabled iCloud or In-App Purchase. If I disable them, then everything works. If I enable one of them, then my provisioning profile is set to none and it works, but when I change it to my distribution profile then stop working.
Can someone tell me what is wrong?
回答1:
You may not have a problem at all. Read: Technical Q&A QA1884 Testing Distribution Builds of Mac Apps
According to this you are not supposed to be able to create installer packages on your own. You are to make a package and check it via the terminal but it WILL NOT WORK.
By the way there is an error in this tech report. You may have to include the path to the app in the sudo installer -store -pkg Sample.pkg -target / it should be: sudo installer -store -pkg /user/yourname/desktop/Sample.pkg -target
this example assumes your installer.pkg is on the desktop
If you get all passes then you are good.
Drove me crazy too as the last app I uploaded in June the pkg just installed without a problem and the app it installed worked.
回答2:
Do you build this as a beta version which can only run on certain devices? I encountered this exact error when I got a new Mac and forgot to install my beta tester certificates.
I also had some trouble when configuring my profiles. When I found the configuration that worked, I created this screenshot, so that I won’t forget. Maybe it helps:

Edit: Also make sure to codesign all frameworks that you are compiling yourself. Each framework has to be signed seperately.
来源:https://stackoverflow.com/questions/20994343/mac-os-x-app-crash-with-code-signature-invalid-error