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!
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'm trying to export a debug IPA of my IOS App from my CI (Github Actions) and I don't figure out why it fails. The following commands work on my computer:
xcodebuild clean archive \
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED="NO" CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO" \
-configuration Debug \
-allowProvisioningUpdates \
-workspace dist/ios-app/App/App.xcworkspace \
-scheme App \
-sdk iphoneos \
-archivePath dist/ios-assets/dist/myapp.xcarchive \
-destination 'generic/platform=iOS'
xcodebuild clean \
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED="NO" CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO" \
-configuration Debug \
-exportArchive \
-archivePath dist/ios-assets/dist/myapp.xcarchive \
-exportOptionsPlist dist/ios-app/App/exportOptions.plist \
-exportPath dist/myapp-preview
I end up with a debug App.ipa into the expected folder.
However, on my CI, only the 1st command succeeds, but the second yells
error: exportArchive: No signing certificate "iOS Development" found
How can it complain although I enforced an unsigned build?
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}"
Our CI server does a daily ad-hoc build of our app by swapping in a different bundle ID like this:
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.example.app.daily" \
app/app-Info.plist
and then building and archiving with xcodebuild:
xcodebuild \
CODE_SIGNING_REQUIRED=YES \
CODE_SIGN_IDENTITY="$DEVELOPER_NAME" \
PROVISIONING_PROFILE="$PROFILE_UUID" \
-sdk iphoneos \
-workspace "$XCODE_WORKSPACE" \
-scheme "$XCODE_SCHEME" \
clean archive \
-archivePath "$ARCHIVE_PATH"
with Xcode 6 this worked perfectly, but in Xcode 7 we're getting this error:
Code Sign error: Provisioning profile does not match bundle
identifier: The provisioning profile specified in your build settings
(“Daily AdHoc Profile for CI Servers”) has an AppID of
“com.example.app.daily” which does not match your bundle
identifier “com.example.app”.
It's as if Xcode 7 isn't seeing that we changed the bundle ID. Is it looking somewhere else?
#Mozilla pointed me in the right direction. Upgrading to an Xcode 7 project moved the bundle identifier into a "Product Bundle Identifier" setting in the Packaging section of the build settings.
Xcode's help sidebar revealed that this setting was named PRODUCT_BUNDLE_IDENTIFIER. So my command became:
xcodebuild \
CODE_SIGNING_REQUIRED=YES \
CODE_SIGN_IDENTITY="$DEVELOPER_NAME" \
PROVISIONING_PROFILE="$PROFILE_UUID" \
PRODUCT_BUNDLE_IDENTIFIER="com.example.app.daily" \
-sdk iphoneos \
-workspace "$XCODE_WORKSPACE" \
-scheme "$XCODE_SCHEME" \
clean archive \
-archivePath "$ARCHIVE_PATH"
and it worked!
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