如何通过命令行对Swift应用程序进行编码? [英] How do I codesign a Swift app via the commandline?

查看:84
本文介绍了如何通过命令行对Swift应用程序进行编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在运行iOS 7.1的真实手机上运行我的Swift应用程序的企业签名版本。

I am attempting to run an enterprise signed build of my Swift app on a real phone running iOS 7.1.

如果我通过Xcode界面创建企业签名应用程序,该应用程序完美。
如果我通过xcodebuild创建企业签名应用程序并在命令行上编码,那么应用程序会在打开时崩溃并显示以下日志:

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

当我通过命令行创建IPA时,IPA总是包含相同的libswiftCore.dylib

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!

当Xcode UI产生IPA时,很明显它以某种方式签署或修改libswiftCore.dylib

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

我尝试过使用代码签名上的--deep选项没有运气。

I have tried using the --deep option on codesign with no luck.

如何在通过命令行构建/代码签名时让libswiftCore.dylib正确签名?

How can I get libswiftCore.dylib to get signed correctly when building/codesigning via the command line?

推荐答案

解决方案并不明显,但很容易。 Apple在Swift的代码签名过程中改变了一些内容:

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


  • 从开发者计算机中删除您的分发证书和配置文件

  • 登录开发人员门户网站

  • 生成新的生产证书和分发配置文件

  • 在Mac上安装

  • 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

错误应该消失。

这篇关于如何通过命令行对Swift应用程序进行编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆