Is there a way to determine from the command line what the location of your derived data folder is after building with xcodebuild?
For example, after running xcodebuild:
xcodebuild -project projectname -target targetname
I want to be able to find out which folder the app is in. I would like to do this without changing the output path with CONFIGURATION_BUILD_DIR or within the project settings.
Any ideas?
xcodebuild -project myapp.xcodeproj -showBuildSettings
prints all build settings and values, in particular the folder where the app is build:
BUILT_PRODUCTS_DIR =
/path/to/myapp/DerivedData/myapp/Build/Products/Release
Related
Ok, so I know how to change XCode build setting to Legacy using the UI shown below.
But how do I build an app from the console using that Legacy setting? I think it has something to do with the command xcodebuild -derivedDataPath <path>. But how do I set it to legacy?
There is no Legacy setting from xcodebuild, although you could use CONFIGURATION_BUILD_DIR to change the default build path:
xcodebuild -project 'MyProject.xcodeproj' \
-configuration 'Release' \
-sdk macosx10.10 CONFIGURATION_BUILD_DIR=/Path/To/Build/Release
If you wanted to build a Debug version just change the configuration flag. If the path is a nonexistent directory xcodebuild should create it automatically.
I have an iOS Xcode project that has several targets. The number of targets in the project will continue to grow as the project progresses and expands. When I create a new version, it is a pain to have to go through each target and manually create the Archive. I looked into how to archive multiple targets using the command line, but none of the answers spoke to what I was trying to accomplish. Any help and guidance is appreciated.
I believe that the following partial command is part of the solution:
xcodebuild archive
archive: Archive a scheme from the build root (SYMROOT). This requires specifying a workspace and scheme.
I suppose you want to build it for CI server Manually
If you want to read all the schemes in a xcode project
xcodebuild -list | awk 'p && NF {print \$0";";} /Schemes:/ {p=1}' > schemeList.txt
This will put all your schemes in a text file. Then you have to read the text file manually to retrieve each scheme.
You can use the below command line to produce the archive
xcodebuild -scheme ${schemeName} -sdk iphoneos$sdkVersion -configuration Release clean archive -archivePath ${archivePath}.xcarchive
And then the below xcode command to produce the ipa.
xcodebuild -exportArchive -archivePath ${archivePath}.xcarchive -exportOptionsPlist exportOptions.plist -exportPath ${exportPath}
I use following command to build project using xcodebuild from the directory where .xcodeproj is.
admin$ xcodebuild install DSTROOT=. INSTALL_PATH=/bin
Could someone please tell me how to specify full path of .xcodeproj in xcodebuild command and run it from anywhere?
[EDIT]
...so you cannot specify absolute path of the project with xcodebuild command but you can specify where do you want your .app file placed like following. You need to run this command from the root project directory and you will be able to compile other sub projects without CD to their directories but you need to specify "scheme" that you are building.
admin$ xcodebuild install DSTROOT=/Users/admin/myProjectRoot INSTALL_PATH=/bin -scheme MySubProject1 -configuration Release -sdk iphonesimulator clean build
According to the manpage for xcodebuild, you must launch "xcodebuild" from within the directory where your project is. I.E. the specific line that clarifies that is:
To build an Xcode project, run xcodebuild from the directory
containing your project (i.e. the directory containing the
projectname.xcodeproj package).
And if there are multiple projects within that directory, that's when you can use the "-project projectname" command line parameter.
In my own build scripts, I "cd" to the folder where the project lives before calling "xcodebuild".
I am running into this error in my jenkins xcode build which I'm attempting to setup:
clang: error: no such file or directory: '/Users/boo/.jenkins/jobs/myProject/workspace/DerivedData/Release-iphoneos/libIBAForms.a'
clang: error: no such file or directory: '/Users/boo/.jenkins/jobs/myProject/workspace/DerivedData/Release-iphoneos/libLambdaAlert.a'
clang: error: no such file or directory: '/Users/boo/.jenkins/jobs/myProject/workspace/DerivedData/Release-iphoneos/libRestKit.a'
I cannot figure out a few things regarding the configuration:
what prompted the jenkins-xcode-plugin ( https://wiki.jenkins-ci.org/display/JENKINS/Xcode+Plugin ) to use /DerivedData/Release-iphoneos/ in the path for the lookup of the .a files
instead why didn't it select /DerivedData/Debug-iphoneos/ as the fragment in the path for the lookup to the .a files
finally the submodules that produce - libIBAForms, libLambdaAlert, libRestKit - are all projects that have a release and a debug profile ... so why the files are actually missing from the /DerivedData/Release-iphoneos/ path where they are supposed to be ... is beyond me.
Regarding points #1 and #2, this is configured based on the Configuration parameter for XCode plugin (and Xcode itself). By default, the plugin uses "Release" value for the parameter. If you want to use "Debug", you should set it as such.
Don't know what to say regarding #3
Personally, i found the Xcode plugin to be restrictive and not providing me with options that i needed. I am using the command line tools that came with xcode (through regular Execute Shell build step)
// Below are my build parameters for the job through regular means
CONFIGURATION=Debug
CODE_SIGN_IDENTITY=iPhone Developer: <DeveloperNameHere>
PROVISIONING_PROFILE=3000000B-7000-4000-9CD5-D0000B0F0000
//
// Code for Execute Shell
xcodebuild -verbose -alltargets -configuration ${CONFIGURATION} clean build CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" PROVISIONING_PROFILE=${PROVISIONING_PROFILE}
&&
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${WORKSPACE}/path_here/${CONFIGURATION}-iphoneos/application.app" -o "${WORKSPACE}/path_here/${CONFIGURATION}-iphoneos/application.ipa" --sign "${CODE_SIGN_IDENTITY}" --embed "/Users/<youruser>/Library/MobileDevice/Provisioning Profiles/${PROVISIONING_PROFILE}.mobileprovision"
Setup parameters as usual for the job
The xcodebuild command does the actual build
The xcrun command packages the app into an IPA (the Archive step in Xcode), signs it, and embeds a provisioning profile directly into the IPA.
Note that some of these switches are options and may not be required for you. But that's the benefit of doing through the command line: you have full control of what you want to do
Small note: make sure you provide full paths to -v and -o switches on the second command
I was able to get past all this when I adeed the submodules which generate libIBAForms and libLambdaAlert as the main project's "Target Dependencies"
What I am trying to achieve is editing code in vim then running make and that would invoke the same functionality as Cmd+R in Xcode: build and launch a simulator with latest changes.
What actual commands are invoked and what parameters are used in this process? Is there a way to view this from Xcode?
Try running xcodebuild from project's directory. Running with --help parameter will reveal all the stuff that you need - which project to build, which target to run, which sdk to use (iphoneos or iphonesimulator). Usually the call looks like this:
xcodebuild -project MyProject -target MyApplication -configuration Release -sdk iphonesimulator5.1