繁体   English   中英

无法从命令行构建XCode项目,但可以从XCode构建

[英]Cannot build XCode project from command line but can from XCode

我在XCode中创建了一个简单的基于导航的iPhone应用程序。 该应用程序从XCode下构建并正常运行,但我无法从命令行构建它。

从终端我执行:

xcodebuild -project George.xcodeproj -alltargets -parallelizeTargets -configuration Debug build

但我得到了这个错误:

=== BUILD NATIVE TARGET George OF PROJECT George WITH CONFIGURATION Debug ===
Check dependencies
[BEROR]Code Sign error: The identity 'iPhone Developer' doesn't match any valid certificate/private key pair in the default keychain

** BUILD FAILED **


The following build commands failed:
    Check dependencies
(1 failure)

我尝试处理它的方式有问题吗?

除了解锁钥匙串之外,您还可以指定codesign身份(或在目标中设置)。 开发证书的格式为“iPhone Developer:Company Inc”,分发证书类似于“iPhone Distribution:Company Inc”。

xcodebuild -project George.xcodeproj -alltargets -parallelizeTargets -configuration Debug build CODE_SIGN_IDENTITY='iPhone Developer: Company Inc' 

您可以从命令行构建针对模拟器的构建,而无需签署问题。

这为我解决了签名问题:

xcodebuild -sdk iphonesimulator

来源: xcodebuild代码签名错误:找不到匹配的代码签名标识:

如果命令行构建仅用于检查持续集成设置中的源代码,那么这尤其有用。

很可能你的钥匙串是锁定的。 尝试在执行脚本之前将其解锁,您可以从命令行(在构建之前)执行此操作:

security unlock -p YourPasswordToKeychain ~/Library/Keychains/login.keychain

注意,我正在使用“登录”钥匙串,在您的情况下可能会有所不同

此外,如果这没有帮助,尝试删除所有其他参数,并像这样离开smth:

xcodebuild -configuration Debug预先xcodebuild -configuration Debug和清理xcodebuild -configuration Debug clean

我正在使用深圳,它也显示了这个错误。

事实证明,当我插入我的iPad但它不在配置文件中时会发生这种情况。 通过--verbose到深圳。 表明:

Check dependencies
Code Sign error: No matching provisioning profiles found: None of the valid     provisioning profiles include the devices:
XXXX’s iPad
CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 8.3'

拔掉设备,一切正常......

根据脚本的用途,在脚本中关闭代码签名也可能就足够了,您可以通过设置CODE_SIGN_IDENTITY =''来完成

xcodebuild -project George.xcodeproj -alltargets -parallelizeTargets -configuration Debug build CODE_SIGN_IDENTITY='' 

显然,如果你试图从脚本中进行最终构建,那就不好了,但是如果你只是想为持续集成做一个测试构建(例如来自Jenkins,以确保没有人破坏任何东西),这可能没什么问题。 。

我的归档错误与原始帖子类似但不完全相同:

** ARCHIVE FAILED **


The following build commands failed:
    Check dependencies
(1 failure)

事实证明,这是一个缺少的应用程序服务(在我的情况下,HealthKit服务/权利),我已在我的开发应用程序ID中启用,但不是我的生产应用程序ID。

您在Apple会员中心启用服务: https//developer.apple.com/account/ios/identifiers/bundle/bundleList.action

这可以通过在XCode中从“iOS Distribution”更改为“iOS Development”在XCode 8.0中修复。 它似乎不应该工作,但它出于某种原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM