ARCHIVE FAILED : After updating Xcode from 9.1 to 10.1 - ios

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.

Related

Can't build or archive app using xcodebuild "...-frameworks.sh: line 42: source: unbound variable"

I am unable to build our app using the xcodebuild command, however if I open the project in xcode and click build or archive from the Product menu, it builds absolutely fine. I can't work out what I am doing differently via cli that is causing it to error.
The command I am using:
xcodebuild archive -scheme Dropless -configuration Release -destination 'generic/platform=iOS' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
The error:
/ios/Pods/Target Support Files/Pods-Dropless/Pods-Dropless-frameworks.sh: line 42: source: unbound variable Command PhaseScriptExecution failed with a nonzero exit code
I have seen various posts online about this error and all seem to point toward the same thing with the defined architectures, however nothing I do seems to make a difference and if it builds in xcode manually I can't see there being an issue with what I've defined.
This is my settings:
xcode version: 13.4.1
osx version: 12.5.1 Monterey

react-native build failing due to PhaseScriptExecution error

Environment
Mac OS X Version 12.1 (Apple M1 chip)
Xcode Version 13.2.1
Simulator Version 13.2 (972.2)
react-native-cli 7.0.3
node v18.4.0
The Issue
This is my first time working on developing an app using React Native. I am trying to run my React Native project on Xcode's simulator, using npx react-native run-ios. However, I am encountering this error message.
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening MCompass.xcworkspace.
Command line invocation:
/Users/brx/Downloads/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace MCompass.xcworkspace -configuration Debug -scheme MCompass -destination id=DC3C75E6-19FD-4B80-87B1-62BF6404ED20
...
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/brx/src/projects/test/MCompass/ios/build/MCompass.build/Debug-iphonesimulator/MCompass.build/Script-00DD1BFF1BD5951E006B06BC.sh (in target 'MCompass' from project 'MCompass')
(1 failure)
Between the first error message and ** BUILD FAILED **, there were many lines of output listing exports.
I've installed dependencies using both yarn and npm. I've also looked at several other threads with this same issue, but none of the solutions (such as having only one version of nvm or running react-native upgrade) have been successful. Does anyone have any tips?
I had my root folder name "REACT NATIVE", changing it to "REACT_NATIVE" fixed the error as the folder that contains your react native project cannot contain white spaces.
The second solution would be running Xcode with rosetta. This is only applicable for M1 chip macbooks as there are few times Xcode projects fail because of this reason. Please refer to below link for reference:
https://penny-huang.medium.com/xcode-how-to-run-ios-simulator-on-m1-mac-66101b9fccd8

Fresh React Native Project Fails on IOS build (M1 MacBook)

I created my first react-native project and I started metro just fine. But When I try to run IOS it fails to build. Any suggestions on what I should check?
latest Xcode installed
karar#Karars-MacBook-Air TheGlobalDoctor % npx react-native run-ios
info Found Xcode workspace "TheGlobalDoctor.xcworkspace"
info Building (using "xcodebuild -workspace TheGlobalDoctor.xcworkspace -configuration Debug -scheme TheGlobalDoctor -destination id=845FA08B-2299-4B05-B9C9-207405392A77")
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening TheGlobalDoctor.xcworkspace.
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace TheGlobalDoctor.xcworkspace -configuration Debug -scheme TheGlobalDoctor -destination id=845FA08B-2299-4B05-B9C9-207405392A77
Xcode Failed Build error:
fatal error: module map file '/Users/karar/Library/Developer/Xcode/DerivedData/TheGlobalDoctor-axdadhlgtbbtzcabxyzzteupuwlt/Build/Products/Debug-iphonesimulator/YogaKit/YogaKit.modulemap' not found 1 error generated.
I had a similar issue. You can start XCode using Rosetta to circumvent the problem for now.
To do so open 'Applications' and find XCode. Open it's context menu and select 'Get Info'. In the info view, make sure the "Open using Rosetta" checkbox is checked.
(Thx to Karthik posting the solution in his blog)

Failed to archive an app using xcodebuild

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).

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).

Resources