How do I codesign a Swift app via the commandline?

后端 未结 5 1744
误落风尘
误落风尘 2020-12-25 15:01

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

相关标签:
5条回答
  • 2020-12-25 15:05

    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.

    0 讨论(0)
  • 2020-12-25 15:07
    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

    0 讨论(0)
  • 2020-12-25 15:10

    The solution is not obvious but easy. Apple changed something in the code signing process for Swift:

    • Delete your distribution certificate and provisioning profile from your developer machine
    • Log into the developer portal
    • generate a new production certificate and distribution provisioning profil
    • Install both on your mac

    The error should be gone.

    0 讨论(0)
  • 2020-12-25 15:12

    When building my Mac app from command line, I can see Xcode code-signing Swift libraries by running swift-stdlib-tool:

    /Applications/Xcode6-Beta5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-stdlib-tool --verbose --copy
    Copying libswiftCore.dylib from /.../XcodeDefault.xctoolchain/usr/lib/swift/macosx to /.../LiveReload.app/Contents/Frameworks
    ... (repeat for 8 libswift*.dylib libraries)
    /usr/bin/codesign '--force' '--sign' 'C2F5439B97B16E0BD7FF671913391346B17440DC' '--verbose' '/.../LiveReload.app/Contents/Frameworks/libswiftCore.dylib'
    ... (repeat for 8 libswift*.dylib libraries)
    

    Looks like you can run similar codesign commands yourself.

    Also, this is for Mac, but perhaps if you run xcodebuild for your iOS project, you will see the specific commands that are invoked for your project. (Just configure the binary to be signed in Release configuration, the way you'd like it signed in your IPA, including the provisioning profile.)

    0 讨论(0)
  • 2020-12-25 15:19

    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.

    0 讨论(0)
提交回复
热议问题