I am attempting to run an enterprise signed build of my Swift app on a real phone running iOS 7.1.
If I create the enterprise signed app via the Xcode interface, the app works perfectly. If I create the enterprise signed app via xcodebuild and codesign on the command line, then the app crashes on open with the following log:
Dyld Error Message:
Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /var/mobile/Applications/96578E7F-7FE6-4603-82F2-8941561225D8/Foo.app/Foo
Reason: no suitable image found. Did find:
/private/var/mobile/Applications/96578E7F-7FE6-4603-82F2-8941561225D8/Foo.app/Frameworks/libswiftCore.dylib: code signature invalid for '/private/var/mobile/Applications/96578E7F-7FE6-4603-82F2-8941561225D8/Foo.app/Frameworks/libswiftCore.dylib'
Dyld Version: 324
When I create the IPA via the command line, the IPA always contains the same libswiftCore.dylib
$ md5 cli/Payload/Foo.app/Frameworks/libswiftCore.dylib
MD5 (cli/SwiftSupport/libswiftCore.dylib) = 0fe0370b5585a88a89d230b7501aee31 <- same every time; matches what is provided by Xcode
$ md5 /Applications/Xcode6-Beta5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib
MD5 (/Applications/Xcode6-Beta5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib) = 0fe0370b5585a88a89d230b7501aee31 <- Same!
When the Xcode UI produces the IPA, it is clear that it is somehow signing or modifying libswiftCore.dylib
$ md5 ui/Payload/Foo.app/Frameworks/libswiftCore.dylib
MD5 (ui/Payload/Foo.app/Frameworks/libswiftCore.dylib) = df73f604b1370b19721dfa7de298340f <- different every time
I have tried using the --deep option on codesign with no luck.
How can I get libswiftCore.dylib to get signed correctly when building/codesigning via the command line?
go to the 'Info' tab and in a menu 'Executable' choose 'Other...' in file window go to search input field and type 'terminal' and click on its icon when you find it. Now you should see 'Terminal. app' in 'Executable' field.
This is a cryptographic process that identifies you as a developer, and identifies your application as something that has been distributed by you. The process of obtaining a code signing identity is slightly different on every platform.
It looks like as of Xcode 6 Beta 6 you need to codesign the Swift libraries manually.
codesign --force --verbose --sign 'iPhone Distribution: My Company' Foo.app/
codesign --force --verbose --sign 'iPhone Distribution: My Company' Foo.app/Frameworks/*
I have filed a bug report with Apple and hopefully they will make this happen automatically if you use codesign's --deep
option.
The solution is not obvious but easy. Apple changed something in the code signing process for Swift:
The error should be gone.
I create a gist to solve this problem, and it works (->link).
The main idea is to codesign the dylibs frist, and then codesign the app.
codesign -f -s 'iPhone Distribution: My Company' Foo.app/Frameworks/*
codesign -f -s 'iPhone Distribution: My Company' Foo.app --entitlements=$ENTITLEMENTS_PATH
not the other way around, otherwise it will fail on installing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With