How to specify output dir name for ios simulator when using xcodebuild cli in combination with a xcworkspace? - ios

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

Related

Xcode: build all the dependent targets when building a framework target

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?

Got an Archive failed when trying "xcodebuild archive" in terminal

I have created a framework with few cocoapod dependencies
.The archive for the framework is failing when i do 'xcodebuild archive' after adding the pod files (Did pod install).
In the normal build, it is working fine. There is no error and the build is successful but when I do 'xcodebuild archive' on my terminal got this below issue.
error: no such module 'Lottie'
import Lottie
^
** ARCHIVE FAILED **
The following build commands failed:
CompileSwift normal arm64 /Users/surya/Documents/Projects/Sampe\ lottie\ test/TestFramework/TestFramework/ViewController.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
Below is my xcode build archive command
xcodebuild archive \
-scheme TestFramework \
-destination "generic/platform=iOS" \
-archivePath ../Output/TestFramework.framework-iphoneos.xcarchive \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
Found the answer - we need to add - workspace ProjectName.xcworkspace, if our framework uses pods. Check the below command
xcodebuild archive -workspace projectName.xcworkspace \
-scheme projectName \
-sdk iphonesimulator \
-archivePath "./archives/ios_Simulators.xcarchive" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
SKIP_INSTALL=NO

xcodebuild: error: Failed to build workspace. Reason: A build only device cannot be used to run this target

I'm trying to build and test on device (iPhone) using command line:
xcodebuild \
-workspace MyApp.xcworkspace \
-scheme MyApp \
-destination 'generic/platform=iOS,id=iPhoneUUID' \
clean test
But I'm getting this error:
xcodebuild: error: Failed to build workspace MyApp with scheme MyApp.
Reason: A build only device cannot be used to run this target.
Any of you knows why I'm getting this error?
I'll really appreciate any help.
Cut off the generic part in your -destination value. Else Xcode won't try to build for your device, but for the generic build only device:
xcodebuild \
-workspace MyApp.xcworkspace \
-scheme MyApp \
-destination 'platform=iOS,id=iPhoneUUID' \
clean test

Getting Issue in Jenkins Continues Integration to HockeyApp in Xcode 8.3.2

All,
We are using Jenkins Continuous integration for App Uploads Below is the Script in Execute Shell in the Job.
rm -fr ~/Library/Caches/CocoaPods/
rm -fr Pods/
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod install
xcodebuild -configuration Release -scheme MyApp_Test -workspace MyApp.xcworkspace SYMROOT="${WORKSPACE}/MyApp/Build/"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${WORKSPACE}/MyApp/Build/Release-iphoneos/MyApp_Test.app" -o "${WORKSPACE}/MyApp/Build/Release-iphoneos/MyApp.ipa"
Earlier it is working perfectly and able to the integration, Recently we updated he Xcode to 8.3.2, From then we are getting errors below are the Errors we are getting
xcrun: error: unable to find utility "PackageApplication", not a developer tool or in PATH
Build step 'Execute shell' marked build as failure
Build step 'Upload to HockeyApp' marked build as failure
Can any one help in solving the issue seems PackageApplication is deprecated and exportArchive is added, how can we change to that syntax
Before: xcrun with PackageApplication
# Build the application
xcodebuild \
-scheme "${SCHEME_NAME}" \
-sdk "${TARGET_SDK}" \
-configuration Release build
# Package the application
/usr/bin/xcrun \
-sdk "${TARGET_SDK}" \
PackageApplication \
-v "${PROJECT_BUILDDIR}/${SCHEME_NAME}.app" \
-o "${BUILD_OUTPUT_DIR}/${APP_NAME}.ipa" \
--sign "${DEVELOPER_NAME}" \
--embed "${PROVISIONING_PROFILE}"
After: xcodebuild with -exportArchive
# Archive the application
xcodebuild \
-scheme "${SCHEME_NAME}" \
-sdk "${TARGET_SDK}" \
-archivePath "${PROJECT_BUILDDIR}/${SCHEME_NAME}.xcarchive" \
-configuration Release \
PROVISIONING_PROFILE="${PROVISIONING_PROFILE}" \
archive
# Export the archive to an ipa
xcodebuild \
-exportArchive \
-archivePath "${PROJECT_BUILDDIR}/${SCHEME_NAME}.xcarchive" \
-exportOptionsPlist "${EXPORT_PLIST}" \
-exportPath "${BUILD_OUTPUT_DIR}"

XCodeBuild is not picking a configuration from my workspace

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

Resources