开发者

Cannot build XCode project from command line but can from XCode

I've created in XCode a simple navigation-based iPhone app. The app builds and runs properly from under XCode but I cannot get it to build from command lin开发者_开发技巧e.

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). Development certs take the form 'iPhone Developer: Company Inc', distribution certs like this '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:

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:

xcodebuild -configuration Debug and clean beforehand 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. By passing --verbose to shenzhen. 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=''

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


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.

You enable services in the Apple Member Center: 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. It doesn't seem like it should work, but it does for some reason.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜