This is my build command
xcodebuild -workspace MyApp.xcworkspace \
-scheme MySchemeName \
-configuration AdHoc \
clean archive
It works but its uses the default configuration for the archive scheme (which is release) instead of AdHoc which I specified. In fact if you specify -scheme ASchemeNameThatDosnNotExist it still works and silently ignores the configuration name.
The project is setup like this:
xcodebuild -list
Targets:
MyApp
MyAppTests
Build Configurations:
Debug
AdHoc
Release
If no build configuration is specified and -scheme is not passed then "Release" is used.
This project contains no schemes.
And the workspace like this:
xcodebuild -workspace MyApp.xcworkspace -list
Schemes:
MyApp
Pods
Pods-AFNetworking
.. More pods
I.e. There are no targets and no configurations in the workspace.
How do I make a target visible to the workspace? Or is there another way?
It's impossible to configure target for workspace. You can create a scheme based on a particular target and then build a project passing scheme name. Setting configuration via '-configuration' switch works fine for me. I use xcode v. 5.0.2.
In general a configuration is set via action. You can create multiple schemes for archiving (with different configurations) and there's no need to pass configuration at all. Default configuration will be taken.
Thank you #Opal for your answer. I was initially mislead by your statement that '-configuration' was working. In fact, this does not work, and the specified configuration is silently ignored when performing an xcodebuild via the workspace:
xcodebuild -workspace $WORKSPACE.xcworkspace \
-scheme $SCHEME \
-configuration QA \
clean archive -archivePath archives/$APP_NAME
xcodebuild -exportArchive \
-archivePath archives/$APP_NAME.xcarchive \
-exportPath . \
-exportOptionsPlist $WORKSPACE/ExportOptions.plist
mv $APP_NAME.ipa $APP_NAME.$VERSION.$BUILD_NUMBER.ipa
However, after creating a custom shared scheme for that configuration, "myapp-QA", the build completes correctly:
xcodebuild -workspace $WORKSPACE.xcworkspace \
-scheme $SCHEME-QA \
clean archive -archivePath archives/$APP_NAME-QA
xcodebuild -exportArchive \
-archivePath archives/$APP_NAME-QA.xcarchive \
-exportPath . \
-exportOptionsPlist $WORKSPACE/ExportOptions.plist
mv $APP_NAME-QA.ipa $APP_NAME.$VERSION.$BUILD_NUMBER.qa.ipa
There is an issue with using configuration & scheme arguments. A scheme has its own configuration and most probably it overrides configuration specified via xcodebuild -configuration.
You can solve it by using configuration & target:
xcodebuild -project <project>.xcodeproj \
-configuration <configuration> \
-target <target> \
-sdk iphonesimulator \
clean build
Related
Xcode 14.2 command line tools archive failed.
xcodebuild -allowProvisioningUpdates \
-workspace $WORKSPACE \
-scheme $SCHEME \
archive \
-configuration Release \
-archivePath $ARCHIVEPATH \
ONLY_ACTIVE_ARCH=NO \
EXCLUDED_ARCHS="" | xcpretty;
** ARCHIVE FAILED **
For whom might facing the problem:
This might be the update that required the "-sdk" flag to avoid the error.
i.e.
-sdk iphoneos
I have an Xcode project with a Framework A target.
That target depends on a few other modules, e.g. SubFramework A and SubFramework B.
When running the Xcodebuild command:
xcodebuild archive \
-scheme SchemeName \
-configuration Release \
-destination 'generic/platform=iOS Simulator' \
-archivePath './build/SchemeName.framework-iphonesimulator.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
I'm getting only the resulting library out, i.e. SchemeName.framework. When I then try to bundle it into the application, of course, I cannot compile it as SubFramework A and SubFramework B are not included.
Q:
Is it possible to modify the scheme's build settings, xcodebuild command or target settings in order to get the SubFramework A and SubFramework B as the build output results too?
I am trying to use xcodebuild to create an ipa of my iOS app. These are the commands my script is running
xcodebuild build \
-project AirQuality.xcodeproj \
-scheme "Air Quality - Development" \
-derivedDataPath /Users/gbreen/src/cuwcd/air-quality-ios/derivedData \
-configuration "Development Release" SYMROOT=/Users/gbreen/src/cuwcd/air-quality-ios/build OBJROOT=/Users/gbreen/src/cuwcd/air-quality-ios/build DEPLOYMENT_LOCATION=YES | xcpretty
xcodebuild archive \
-project AirQuality.xcodeproj \
-scheme "Air Quality - Development" \
-derivedDataPath /Users/gbreen/src/cuwcd/air-quality-ios/derivedData \
-configuration "Development Release" SYMROOT=/Users/gbreen/src/cuwcd/air-quality-ios/build OBJROOT=/Users/gbreen/src/cuwcd/air-quality-ios/build DEPLOYMENT_LOCATION=YES \
-archivePath /Users/gbreen/src/cuwcd/air-quality-ios/build/archive-Test/"Air Quality - Development".xcarchive \
| xcpretty
xcrun xcodebuild \
-exportArchive \
-exportOptionsPlist /Users/gbreen/src/cuwcd/air-quality-ios/build/archive-Test/exportOptions-Test.plist \
-archivePath /Users/gbreen/src/cuwcd/air-quality-ios/build/archive-Test/"Air Quality - Development".xcarchive \
-exportPath /Users/gbreen/src/cuwcd/air-quality-ios/build/archive-Test
It works great when my app is targeting iOS 12 but when I move it to iOS 13 the xcrun command fails with a message:
error: archive at path '/Users/gbreen/src/cuwcd/air-quality-ios/build/archive-Test/Air Quality - Development.xcarchive' is malformed
Are there any specific considerations I need to make when updating to iOS 13? Do I need to configure something on my machine so xcrun knows it's an iOS 13 xcarchive? I just don't know where to go with this?
Through trial and error I figured out this same issue with my own build process.
You need to take out the build flags:
SYMROOT=...
OBJROOT=...
DSTROOT=...
I don't entirely know why because I don't know the inner workings of xcodebuild and how it was updated for Xcode 11. So, I suspect the answer lies somewhere in : this long document.
I hope that helps!
I build a xcode (6.3.1) project that uses workspace because I'm using Pods.
When I do:
xcodebuild \
build \
-workspace MyProject.xcworkspace \
-scheme MyProject \
-configuration Debug \
-sdk iphonesimulator \
-ARCHS=i386 \
VALID_ARCHS=i386 \
SYMROOT="/tmp/build/emulator" \
SHARED_PRECOMPS_DIR="/tmp/build/sharedpch"
It outputs the app to:
/tmp/build/emulator/Debug-iphonesimulator/MyProject.app
Is there a way with the xcodebuild command to get it build to
/tmp/build/emulator/MyProject.app
I have tried to replace SYMROOT with
CONFIGURATION_BUILD_DIR="/tmp/build/emulator"
Now it builds to
/tmp/build/emulator/Monsenso.app
but that do not work smoothly with CocoaPods frameworks (e.g. Typhoon for DI) ~ build fails with:
The following build commands failed:
GenerateDSYMFile /tmp/build/emulator/Typhoon.framework.dSYM /run/emulator/Typhoon.framework/Typhoon
I managed to get static libraries working and its all fine. Now that I have moved onto the proper library I want to create Im having issues. Im using cocoapods to import other files and it creates a workspace. Now the script I have for compiling no longer works and my assumption is because I am working in a framework now. I have been googling for hours trying to get an answer but all the things I have found only relate to turning a single project into a library
My questions are:
1) Is it possible to combine a workspace into one single library?
2) should I be trying to create a framework instead?
3) Is it just my script that isnt right?
XCODEBUILD_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin
XCODEBUILD=$XCODEBUILD_PATH/xcodebuild
$XCODEBUILD -project T5Pusher.xcodeproj -target "T5Pusher" -sdk "iphoneos" - configuration "Release" clean build
$XCODEBUILD -project T5Pusher.xcodeproj -target "T5Pusher" -sdk "iphonesimulator" - configuration "Release" clean build
lipo -create -output "build/libT5Pusher.a" "build/Release-iphoneos/libT5Pusher.a" "build/Release-iphonesimulator/libT5Pusher.a"
also tried this
XCODEBUILD_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin
XCODEBUILD=$XCODEBUILD_PATH/xcodebuild
$XCODEBUILD -workspace T5Pusher.xcworkspace -scheme "T5Pusher" -sdk "iphoneos" - configuration "Release" clean build
$XCODEBUILD -workspace T5Pusher.xcworkspace -scheme "T5Pusher" -sdk "iphonesimulator" - configuration "Release" clean build
lipo -create -output "build/libT5Pusher.a" "build/Release-iphoneos/libT5Pusher.a" "build/Release-iphonesimulator/libT5Pusher.a"
The errors I get are
** BUILD FAILED **
The following build commands failed:
Libtool build/PusherTest.build/Release-iphoneos/PusherTest.build/Objects- normal/armv7/libPusherTest.a normal armv7
Libtool build/PusherTest.build/Release-iphoneos/PusherTest.build/Objects-normal/armv7s/libPusherTest.a normal armv7s
(2 failures)
lipo: can't open input file: build/Release-iphoneos/libPusherTest.a (No such file or directory)
Showing first 200 notices only
and for the second, the build succeeds but the library (.a) files are never created so it cannot combine them
I have found the solution. You have to use the command:
pod install --no-integrate
when installing the pod. This will not create a workspace and allow the use of the script
XCODEBUILD_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin
XCODEBUILD=$XCODEBUILD_PATH/xcodebuild
$XCODEBUILD -project T5Pusher.xcodeproj -target "T5Pusher" -sdk "iphoneos" - configuration "Release" clean build
$XCODEBUILD -project T5Pusher.xcodeproj -target "T5Pusher" -sdk "iphonesimulator" - configuration "Release" clean build
lipo -create -output "build/libT5Pusher.a" "build/Release-iphoneos/libT5Pusher.a" "build/Release-iphonesimulator/libT5Pusher.a"
Then to set the config file for pods:
-Go to project editor -> info -> configuration
-Set the target to use pods.xconfig file for debug and release
I was having the same issue myself and found that if I specified the output directories and then told lipo to look there then it worked while still letting me use the workspace. The may be different in Xcode 5 but when I use it as a custom build phase then it works without specifying the output directories and I only have to direct lipo to ${BUILD_DIR} to find the generated files.
$XCODEBUILD -project T5Pusher.xcodeproj \
-target "T5Pusher" \
-sdk "iphoneos" \
-configuration "Release"
OBJROOT=${env_variable_to_some_directory}/Obj.root \
SYMROOT=${env_variable_to_some_directory}/Sym.root \
DSTROOT=${env_variable_to_some_directory}/Dst.root \
clean build