0

I've been struggling for a couple of days now...

I have an app that works great in AdHoc and now I'm delivering a .ipa to the customer for uploading to their private store.

I'm using XCode6.4 and Swift, and archived through xCode.

During the first attempts the app was crashing for the customer with the following log:

Library not loaded: @rpath/libswiftCore.dylib
Referenced from:  /private/var/mobile/Containers/Bundle/Application/F223C4F8-4CBA-4474-9809-79D80C5AB11F/appname.app/appname
Reason: no suitable image found.  Did find:
/private/var/mobile/Containers/Bundle/Application/F223C4F8-4CBA-4474-9809-79D80C5AB11F/appname.app/Frameworks/libswiftCore.dylib: code signature invalid for '/private/var/mobile/Containers/Bundle/Application/F223C4F8-4CBA-4474-9809-79D80C5AB11F/appname.app/Frameworks/libswiftCore.dylib'
Dyld Version: 353.12

After many attempts to fix this I tried to manually sign the app. When decompressing the "somename.ipa" I get a "somename" folder with 3 subfolders: Payload, SwiftSupport, Symbols. I ran: codesign --force --verbose --sign 'iPhone Distribution: certificate' appname.app/

and then: codesign --force --verbose --sign 'iPhone Distribution: certificate' appname.app/Frameworks/*

And the resulting CodeResources file looked exactly the same as before. So then I did it the other way around - signed the frameworks first and the app after that. This time I got a CodeResources file that had different hashes for the framework files and same hashes as before for the rest of the files.

Now, I zipped the "somename" folder and changed the extension from ".zip" to ".ipa". Note it still has the same structure.

Now when the customer tries to upload they get the following answer: "submission error: this build did not pass automatic validations Fatal errors: - Application directory structure should be Payload/appname.app/"

the .ipa does include that directory, I doubled and tripled checked, along with the (new) Swift top directory and the symbol files directory.

Not sure where to go with this...

T-Rex
  • 1,550
  • 2
  • 11
  • 17

1 Answers1

0

I'm using following script command to resign application with new provision:

#Pulls the entitlements out of the provision profile
/usr/libexec/PlistBuddy -x -c "print :Entitlements " /dev/stdin <<< $(security cms -D -i $PROVISION_PATH/$ADHOC_PROVISION) > entitlements.plist

#Remove old CodeSignature
rm -rf Payload/$1.app/_CodeSignature Payload/$1.app/CodeResources

# Replace embedded mobile provisioning profile
cp $PROVISION_PATH/$ADHOC_PROVISION Payload/$1.app/embedded.mobileprovision

# Re-sign
/usr/bin/codesign --verify -f --sign "iphone distribution" --resource-rules=Payload/$1.app/ResourceRules.plist --entitlements entitlements.plist Payload/$1.app

# Re-package
zip -qr $1.adhoc.ipa Payload

Where

$1 - Application name

$PROVISION_PATH/$ADHOC_PROVISION - new provision profile

user3687611
  • 31
  • 1
  • 4
  • thanks! I only want to re-sign with the same certificate so I don't think I need to change the provisioning profile - what do you think? Plus, judging by your last row, your app is maybe obj-c and not swift? – T-Rex Nov 02 '15 at 14:28
  • Hmm, only re-sing with new certificate? When you generate the provision profile you have to set the distribution cerificate. If you are trying to sing with some other certificate - the error should be occured. I use this script for objC and Swift projects. – user3687611 Nov 03 '15 at 12:02
  • About crash with libswiftCore.dylib - Embeded frameworks may help you, please find details [here](http://stackoverflow.com/questions/26024100/dyld-library-not-loaded-rpath-libswiftcore-dylib) – user3687611 Nov 03 '15 at 12:12
  • thanks. I'm re-signing with the same certificate. I deduced you have obj-c only because you only zipped the Payload folder - swift projects have another folder. – T-Rex Nov 03 '15 at 13:09
  • Hi, did you find a solution? I have exactly the same issue. I resign an .ipa (that works fine) but when I run the app, it crashes because it cannot load the `libswiftCore.dylib` – Jan Aug 11 '17 at 12:24