简体   繁体   English

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

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

I've created in XCode a simple navigation-based iPhone app. 我在XCode中创建了一个简单的基于导航的iPhone应用程序。 The app builds and runs properly from under XCode but I cannot get it to build from command line. 该应用程序从XCode下构建并正常运行,但我无法从命令行构建它。

From terminal I execute: 从终端我执行:

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

but I get that error: 但我得到了这个错误:

=== 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)

Is there something wrong with the way I try to handle it? 我尝试处理它的方式有问题吗?

In addition to unlocking the keychain, you might also specify the codesign identity (or set it in your target). 除了解锁钥匙串之外,您还可以指定codesign身份(或在目标中设置)。 Development certs take the form 'iPhone Developer: Company Inc', distribution certs like this 'iPhone Distribution: Company Inc'. 开发证书的格式为“iPhone Developer:Company Inc”,分发证书类似于“iPhone Distribution:Company Inc”。

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

You can build from the command-line a build targeted at the simulator without signing issues. 您可以从命令行构建针对模拟器的构建,而无需签署问题。

This solved the signing issue for me: 这为我解决了签名问题:

xcodebuild -sdk iphonesimulator

Source: xcodebuild Code Sign error: No matching codesigning identity found: 来源: xcodebuild代码签名错误:找不到匹配的代码签名标识:

That's particularly useful if the command line build is there only to sanity check the source code in a continuous integration setup. 如果命令行构建仅用于检查持续集成设置中的源代码,那么这尤其有用。

Most probably your keychain is locked. 很可能你的钥匙串是锁定的。 Try unlocking it before executing the script, you can do it from command line (right before building): 尝试在执行脚本之前将其解锁,您可以从命令行(在构建之前)执行此操作:

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

Note, I'm using "login" keychain which could be different in your case 注意,我正在使用“登录”钥匙串,在您的情况下可能会有所不同

Also, if that doesn't help, try removing all other parameters and just leave smth like this: 此外,如果这没有帮助,尝试删除所有其他参数,并像这样离开smth:

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

I'm using shenzhen, it shows this error too. 我正在使用深圳,它也显示了这个错误。

Turns out, it happens when I plug in my iPad but it is not in the provision profile. 事实证明,当我插入我的iPad但它不在配置文件中时会发生这种情况。 By passing --verbose to shenzhen. 通过--verbose到深圳。 it shows: 表明:

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'

unplug the device, everything works just fine... 拔掉设备,一切正常......

Depending on the purpose of your script, it may also be sufficient to just turn off code signing in the script, which you can do by setting CODE_SIGN_IDENTITY='' 根据脚本的用途,在脚本中关闭代码签名也可能就足够了,您可以通过设置CODE_SIGN_IDENTITY =''来完成

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

Obviously that's no good if you are trying to do a final build from a script, but it may be fine if you're just trying to do a test build for continuous integration (eg from Jenkins, to make sure that nobody has broken anything). 显然,如果你试图从脚本中进行最终构建,那就不好了,但是如果你只是想为持续集成做一个测试构建(例如来自Jenkins,以确保没有人破坏任何东西),这可能没什么问题。 。

I had an archiving error similar but not quite the same as the original post: 我的归档错误与原始帖子类似但不完全相同:

** ARCHIVE FAILED **


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

This turned out to be a missing Application Service (in my case, the HealthKit service/entitlement), which I had enabled in my development App ID but not my production App ID. 事实证明,这是一个缺少的应用程序服务(在我的情况下,HealthKit服务/权利),我已在我的开发应用程序ID中启用,但不是我的生产应用程序ID。

You enable services in the Apple Member Center: https://developer.apple.com/account/ios/identifiers/bundle/bundleList.action 您在Apple会员中心启用服务: https//developer.apple.com/account/ios/identifiers/bundle/bundleList.action

This can be fixed in XCode 8.0 by changing from "iOS Distribution" to "iOS Development" in XCode. 这可以通过在XCode中从“iOS Distribution”更改为“iOS Development”在XCode 8.0中修复。 It doesn't seem like it should work, but it does for some reason. 它似乎不应该工作,但它出于某种原因。

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

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