xcodebuild command for Xcode 8 beta to set provisioning profile and team ID - command-line

I am not able to build a project from command line in the latest Xcode 8 beta version. Can you please let me know the "xcodebuild" commands for Xcode 8 beta version to build a project through command line. previous commands which we used in previous versions of Xcode does not work now. Every time it throws and error : "Check dependencies
Signing for MyTestApp3 requires a development team. Select a development team in the Target Editor.
Code signing is required for product type 'Application' in SDK 'iOS 10.0'"
Command i used to build - xcodebuild -project MyTestApp3.xcodeproj -sdk iphoneos -configuration Release clean build DEBUG_INFORMATION_FORMAT=dwarf-with-dsym DSTROOT=build GCC_GENERATE_DEBUGGING_SYMBOLS=YES SHARED_PRECOMPS_DIR=build OBJROOT=build SYMROOT=build PROVISIONING_PROFILE_SPECIFIER= CODE_SIGN_IDENTITY="iPhone Distribution: Our Distribution Certificate".

Did you try DEVELOPMENT_TEAM command line parameter?
It can also be set in Xcode (General and Build Settings tabs).

I found the solution by this answer!
Mybe you also want to know how to get the 10-digit team id. Well, I found it in the output of command
xcodebuild -showBuildSettings -project <YourProject> |grep DEVELOPMENT_TEAM

Related

Swift 5 test build fails with missing Provisioning Profile error

I am trying to build my iOS app from the command line using this command :
$ CODE_SIGNING_ALLOWED=NO xcodebuild -target 'MyApp' -sdk iphoneos -configuration Release
But it fails with the following error :
note: Using new build system
note: Planning build
note: Constructing build description
error: "MyApp" requires a provisioning profile. Select a provisioning profile in the Signing & Capabilities editor. (in target 'MyApp' from project 'MyProject')
Im not interested in signing my app at all. I just want to be able to build from the command line.
Is anyone aware what I am doing wrong?
BTW, I have NOT downloaded any provisioning profile from Apple but Xcode is able to build and run the app. Why is that?

Command Line Tool - Error - xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH

I am getting this error while building the SwiftJSON framework to the Some Xcode project through Carthage Dependency Manager.
Sivaramaiahs-Mac-mini:GZipDemoApp vsoftMacmini5$ carthage update
--platform iOS
*** Fetching GzipSwift
*** Fetching SwiftyJSON
*** Checking out GzipSwift at "3.1.1"
*** Downloading SwiftyJSON.framework binary at "3.1.3"
*** xcodebuild output can be found in /var/folders/7m/y0r2mdhn0f16zz1nlt34ypzr0000gn/T/carthage-xcodebuild.apLXCc.log
A shell task (/usr/bin/xcrun xcodebuild -project
/Users/vsoftMacmini5/Desktop/GZipDemoApp/Carthage/Checkouts/GzipSwift/Gzip.xcodeproj
CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES -list)
failed with exit code 72:
xcrun: error: unable to find utility "xcodebuild", not a developer
tool or in PATH
I solved that problem by setting the Command Line Tools in Xcode. Go to:
Xcode > Preferences > Locations
And select the command line tool from the dropdown. If you have only one version of Xcode installed, there should be only one option. If you have several versions of Xcode, then you must choose the one you need.
Update (added image for reference)
The simplest fix is from CLI:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
(this should be path to your Xcode.app)
By the way this can happen even if you have only one version of Xcode . It happens when you instal homebrew before the first Xcode installation (which makes sense because you may want to install Xcode through mas install 497799835 and mas needs homebrew).
Following command worked for me
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Build fail error

I am baffled about this error since I installed xcode 4.2 from xcode 3.2 and switched back to xcode 3.2 Since then I am not able to build for device for any of my projects for any configurations.
The error shown is:
CodeSign build/Debug-iphoneos/MyProject.app cd
"/Users/macadmin/Documents/iPhoneProjectDocs/Madhup/Test/Test
Development/MyProject" setenv PATH
"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
setenv _CODESIGN_ALLOCATE_
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
/usr/bin/codesign -f -s "iPhone Developer: Madhup (MW9495NA8W)"
"--resource-rules=/Users/macadmin/Documents/iPhoneProjectDocs/Madhup/Test/Test
Development/MyProject/build/Debug-iphoneos/MyProject.app/ResourceRules.plist"
--entitlements "/Users/macadmin/Documents/iPhoneProjectDocs/Madhup/Test/Test
Development/MyProject/build/MyProject.build/Debug-iphoneos/MyProject.build/MyProject.xcent"
"/Users/macadmin/Documents/iPhoneProjectDocs/Madhup/Test/Test
Development/MyProject/build/Debug-iphoneos/MyProject.app"
/Users/macadmin/Documents/iPhoneProjectDocs/Madhup/Test/Test
Development/MyProject/build/Debug-iphoneos/MyProject.app: object
file format invalid or unsuitable Command /usr/bin/codesign failed
with exit code 1
The things I have tried to get over this are:
Completely removed all provisioning profiles and certificates and re-install them.
Change configurations (Debug to some other)
Completely uninstall and re-install xcode
Moreover if I try to build my project from some other systems with same provisioning profile, developer certificate and same build configuration I don't face any problem.
Please help me out as I am so frustrated and thinking of OS re-install :(
So to clarify, you've removed xcode with...
sudo /Developer/Library/uninstall-devtools –mode=all
Have you also cleaned the build (Product menu -> Clean)? I know this sounds a bit of an obvious one - but lots of people forget to do it!

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

(iphone) build xcode4 project from command line

I've used to build my project with
xcodebuild -proj MyProject.xcodeproj -target MyTarget - configuration Debug -sdk iphonesimulator4.3
this works(it builds fine) but when I hit run in xcode, it recompiles.
(with xcode3, there was no need to rebuild once I build using command line)
I suspect xcode build use workspace/scheme rather than project/target.
How do I find out the workspace name that my current xcode project is using?
Thank you
edit
Chetan's links gave me directions what to look for.
xcode4 stores build output in ~/Library/...
whereas xcodebuild -project .. saves build output in project's build directory.
(if you want the workspace capability, you can't use the build directory for build output)
I created a workspace containing my project and ran
xcodebuild -workspace myWorkSpace -scheme myScheme
this saves build output in ~/Library/...../Debug-iphoneos
whereas xcode4 run button from the same workspace and same scheme saves output in
~/Library/..../Debug-iphonesimulator
any guess on why xcodebuild command uses Debug-iphoneos? :(
edit2
xcodebuild -workspace myWorkSpace -scheme myScheme -sdk iphonesimulator4.3
specifying sdk solved it
I know it isn't strictly the answer to your question, but you can configure the output directory of your build using the CONFIGURATION_BUILD_DIR environment variable.
Source: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/0-Introduction/introduction.html#//apple_ref/doc/uid/TP40003931-CH1-SW1