Failed to archive an app using xcodebuild - ios

I am trying to archive an app using xcodebuild but it keeps on failing at the last step of certificate signing with no clear error message. All I am getting is
Validate /Users/ashraftawfeeq/Library/Developer/Xcode/DerivedData/<ProjectName>-ghodnwbxujykykezmtkiilwfkxrf/Build/Intermediates.noindex/ArchiveIntermediates/<APP>/InstallationBuildProductsLocation/Applications/<APP>.app (in target '<Target>' from project '<ProjectName>')
cd /Users/ashraftawfeeq/<ProjectRepo>
builtin-validationUtility /Users/ashraftawfeeq/Library/Developer/Xcode/DerivedData/<ProjectName>-ghodnwbxujykykezmtkiilwfkxrf/Build/Intermediates.noindex/ArchiveIntermediates/<APP>/InstallationBuildProductsLocation/Applications/<APP>.app
Touch /Users/ashraftawfeeq/Library/Developer/Xcode/DerivedData/<ProjectName>-ghodnwbxujykykezmtkiilwfkxrf/Build/Intermediates.noindex/ArchiveIntermediates/<APP>/InstallationBuildProductsLocation/Applications/<APP>.app (in target <TargetName> from project <ProjectName>)
cd /Users/ashraftawfeeq/<ProjectRepo>
/usr/bin/touch -c /Users/ashraftawfeeq/Library/Developer/Xcode/DerivedData/<ProjectName>-ghodnwbxujykykezmtkiilwfkxrf/Build/Intermediates.noindex/ArchiveIntermediates/<APP>/InstallationBuildProductsLocation/Applications/<APP>.app
** ARCHIVE FAILED **
When I try to archive using Xcode, it works as intended. Also when I try xcodebuild build it succeeds as well. Digging in the logs it seems like xcodebuild is not creating InstallationBuildProductsLocation/Application.

After a lot of searching and debugging, it turned out that I have a Perl script that wasn't producing errors but without a non zero exit. The process continues and the archive is created but the process was failing.

I removed 'arm64' from 'Excluded Architectures' (Target -> Build Settings).

Related

ARCHIVE FAILED : After updating Xcode from 9.1 to 10.1

Archive was getting created with Xcode 9.1 but it is now failing with below error after updating Xcode to 10.1.
**ARCHIVE FAILED**
The following build commands failed:
SymLink /Users/rsKRISH/dir/build/Release-iphoneos/Output.app /Users/rsKRISH/Library/Developer/Xcode/DerivedData/Output-fdnrztthdyjgzvfkiyrgfpahdjxd/Build/Intermediates.noindex/ArchiveIntermediates/Output/InstallationBuildProductsLocation/Applications/Output.app
(1 failure)
The command I am using is :
xcodebuild -project "$PROJECT_NAME.xcodeproj" -configuration Debug clean build VALID_ARCHS="armv7 arm64" CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build/Release-iphoneos" -scheme "$PROJECT_NAME" archive -archivePath build/Release-iphoneos/Output.xcarchive
I am able to create the archive from Xcode but it is failing while using command line.
And there is no other information about error (error number etc.) in the build log.
Does anybody has any idea, what might be the issue ?
OS: MacOS 10.13.6
After making some changes to the build command. I found out that the issue was caused due to build parameter:
CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build/Release-iphoneos"
So, I've removed this parameter for now. But the root cause of the error is still unknown since I haven't received any permission error (or any other error), which can explain the reason why SymLink cannot be created at the given build directory.

Producing .xcarchive for target when building for iOS with CMake

I'm trying to automate iOS building through CMake, up to and including authoring .ipas. I have my provisioning profile and certificates set up, build is successful, but when I execute cmake --build I can't get .xcarchives to generate, and my POST_BUILD command (using xcodebuild) to author the .ipa is dependent on that.
I've tried setting some archive options though CMake (setting cmake_archive_output_directory), but there's a flag or option to set that can produce xcarchives during build, I don't know it. Does anyone have experience with this?
Despite many attempts, a post-build command to xcodebuild archive never worked -- I'm still not sure why, either. What I ended up doing to work around this was have CMake generate a script.
So my create executable custom function does this:
It creates a script file if it doesn't already exist, then for each executable target, appends an xcodebuild command if it's not a duplicate:
xcodebuild -workspace ${pathToTargetWorkspace} -scheme ${targetScheme} -configuration ${config} -archivePath ${pathToGeneratedArchive}.xcarchive archive
Then after building is finished, you just run the script with the aggregation of archive commands and it archives all the targets.

TeamCity + Xcode 6 - Run Test action fails

I am trying to make a simple Xcode project work with TeamCity. Without running any tests I have succeeded.
I have a basic, Single View Application in Swift with one label on the screen. Both TeamCity (9.0.2) and Xcode (6.1.1) runs on the same machine (Mac mini) with an OS X (10.10.2) Server (4.0.3) installed on it. I have created a Git repository with Server and added as a remote to my sample Xcode project. After that, I've created successfully a working TeamCity project and build.
However when I try to check the Run tests checkmark the build WILL fail no matter what I do.
Configuration (dropbox image)
https://dl.dropboxusercontent.com/u/55101816/Screen%20Shot%202015-03-01%20at%2002.45.48.png
Error message (and the messages right before that)
[02:31:48][FirstTeamCityProjectTests (BUILD)] Touch
[02:31:48][Touch] Touch build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][Touch] cd /Library/TeamCity/buildAgent/work/55b27ad210b8fe77
[02:31:48][Touch] export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/> ontents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin"
[02:31:48][Touch] /usr/bin/touch -c /Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][FirstTeamCityProjectTests (BUILD)] CodeSign
[02:31:48][CodeSign] CodeSign build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][CodeSign] cd /Library/TeamCity/buildAgent/work/55b27ad210b8fe77
[02:31:48][CodeSign] export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
[02:31:48][CodeSign] export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/ Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin"
[02:31:48][CodeSign] Signing Identity: "iPhone Developer: *"
[02:31:48][CodeSign] /usr/bin/codesign --force --sign * /Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][Step 1/1] ** BUILD SUCCEEDED **
[02:31:48][Step 1/1] xcodebuild: error: Failed to build workspace FirstTeamCityProject with scheme FirstTeamCityProject.
[02:31:48][Step 1/1] Reason: Xcode cannot run using the selected device.
[02:31:48][Step 1/1] Process exited with code 70
[02:31:48][Step 1/1] Step Xcode Project failed
Main problem I found with this error code and CI that they were trying with ssh and there were no GUI session. Currently I have a valid GUI session with the same user it uses, so it shouldn't be a problem.
The xcodebuild command is the following.
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace FirstTeamCityProject.xcodeproj/project.xcworkspace -scheme FirstTeamCityProject SYMROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build OBJROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build clean build test
What is missing here (I suppose) is one or more destinations.
I've executed the following command and it worked just fine. (Opened the Simulator, then exited with success.)
xcodebuild test -project FirstTeamCityProject.xcodeproj -scheme FirstTeamCityProject -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1'
I seem to be alone with this problem, I didn't find any other relevant hits. Looking at this tutorial: http://pivotallabs.com/ios-continuous-deployment-teamcity-hockeyapp/, my issue should not be present at all.
EDIT:
The destination is indeed missing, but I don't understand why. Moreover if I try to add it manually the build fails. (I suspect that the order of the parameters matters, but how could I add this destination elsewhere in TeamCity.)
[01:48:12][Step 1/1] Building project: /Library/TeamCity/buildAgent/work/55b27ad210b8fe77/FirstTeamCityProject.xcodeproj
[01:48:12][Step 1/1] Using Xcode 6.1.1
[01:48:12][Step 1/1] Starting: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace FirstTeamCityProject.xcodeproj/project.xcworkspace -scheme FirstTeamCityProject SYMROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build OBJROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build clean build test -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1'
[01:48:12][Step 1/1] in directory: /Library/TeamCity/buildAgent/work/55b27ad210b8fe77
[01:48:12][Step 1/1] xcodebuild: error: option 'Destination' requires at least one parameter of the form 'key=value'
I appreciate any idea you have! Thanks in advance!
in team city, when you configure the 'Xcode Project' build step,
add the destination parameter in the 'Additional command line parameters'
input box like so:
"-destination" "platform=iOS Simulator,name=iPhone 6,OS=8.4"
pay attention to the quotation marks
that solved the issue for me (I checked it on TeamCity Professional 9.1.5 (build 37377)).
Please see How to start TeamCity Build Agent on Mac OS on a user logon to make it able to run the GUI applications (also see the note for Yosemite OS).

Xcodebuild is not creating an app

I'm trying to create a simulator app to submit to Facebook for review. I've followed their instructions to the letter, but keep running into problems. I am using CocoaPods and have a workspace instead of a plain old project. Here's the command I'm running:
xcodebuild -arch i386 -sdk iphonesimulator8.1 -workspace [APP].xcworkspace -scheme [APP]
I get a ** BUILD SUCCEEDED ** message, but either one of two things will happen:
No build folder is created, and I can't find where the .App file is.
A .App is created in a build folder, but is 0 bytes in size and crashes when running with ios-sim.
I read that changing the Run scheme to 'Release' might fix it, but that didn't do anything. Any ideas?
So, I had the same problem and solved it by doing the following:
I made my app as release build instead of debug in xcode: Product->Scheme->Edit Scheme and then Build Configuration set to Release.
After doing this I then went back to the command line and added a destination for the build:
xcodebuild -arch i386 -sdk iphonesimulator8.1 -workspace [APP].xcworkspace -scheme [APP] -derivedDataPath /path/to/build
If you are still having problems make sure you clean and build all of your targets (pods included) and try the above steps again.
Hope this works; it did for me.

xcrun error: Failed to read entitlements from

So im trying to automate the build and archive process through a script. In my script, I run the xcodebuild script and that builds fine. Then I try to run the xcrun
/usr/bin/xcrun -sdk iphoneos PackageApplication "path_to_.app" -o "output_path" --sign "devname" --embed "provnprofile"
However I get this error:
error: Failed to read entitlements from '/var/folders/U5/U5q0xqZRG6SrO8AMQkMjeE+++TM/-Tmp-/fIcrdMUa76/Payload/MyApp.app'
Anyone have any ideas why?
Thanks in advance
I just encountered the same issue. It was actually related to my .app folder generated with xcodebuild which wasn't successfully built.
Try to use xcodebuild with the verbose (-verbose) enabled and check the stack trace.
I hope it will help.
double check the package you are building in Xcode. Very often, a project has multiple packages and targets to build. You might have selected a distribution package or not the one you intent to build.

Resources