I'm having an issue with xcodebuild. I use the xcodebuild archive command from a build server to create an archive. At the moment, it seems that it will not respect the build configuration I have set. Has anyone come across this, or have any idea how to alter it?
To give a bit more background, within the project I have my build location set as Legacy so that I can build multiple libraries into a single iOS app (similar to how three20 do it), and so I have my build directories set within an xcconfig file as so:
BUILD_DIR = ../Build
SYMROOT = ${BUILD_DIR}/Products
OBJROOT = ${BUILD_DIR}/Intermediates
TEMP_ROOT = ${BUILD_DIR}/Temp
If I run
xcodebuild -workspace ${WORKSPACE} -scheme ${SCHEME} -configuration ${CONFIGURATION} -sdk ${SDK}
It all works swimmingly, and the compilation command I get compiles into the common ../Build folder as you can see in the sample output here:
CompileC ../Build/Intermediates/Core.build/Release-iphoneos/Core.build/Objects-normal/armv7s/NumberUtils.o Source/NumberUtils.m normal armv7s objective-c com.apple.compilers.llvm.clang.1_0.compiler
However if I add archive on the end, and run:
xcodebuild -workspace ${WORKSPACE} -scheme ${SCHEME} -configuration ${CONFIGURATION} -sdk ${SDK} archive
It ignores my build settings, and just uses the DerivedData location:
CompileC /Users/user/Library/Developer/Xcode/DerivedData/workspace-bmancqbwwpbxuzbdtxezsoptpyur/ArchiveIntermediates/Release/IntermediateBuildFilesPath/Core.build/Release-iphoneos/Core.build/Objects-normal/armv7/NumberUtils.o Source/NumberUtils.m
Is there something else I need to set? I've set all the environment variables I can think of. Strangely archiving from within xcode itself also works fine. Any advice?
Related
I'm having issues with archiving on my CI machine (Jenkins), when running the process manually on the SAME machine but with the Xcode UI, everything works just fine.
The error I get is:
<unknown>:0: error: cannot have input files with file list
** ARCHIVE FAILED **
The following build commands failed:
CompileSwift normal armv7
CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
CompileSwift normal arm64
(4 failures)
The original command it's executing on failure is VERY long (68K+ characters), here it is stripped down from all pods/app info:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift #/var/folders/cc/h3hp1kt14rv3j5t_lybwwgqh0000gp/T/arguments-ece6e3.resp # -frontend -c -filelist /var/folders/cc/h3hp1kt14rv3j5t_lybwwgqh0000gp/T/sources-e4a704 -supplementary-output-file-map /var/folders/cc/h3hp1kt14rv3j5t_lybwwgqh0000gp/T/supplementaryOutputs-4e5601 -target arm64-apple-ios10.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk -g -module-cache-path / ... /ModuleCache.noindex -swift-version 4 -O -D RELEASE -serialize-debugging-options ... -module-name APPNAME -num-threads 8 -output-filelist /var/folders/cc/h3hp1kt14rv3j5t_lybwwgqh0000gp/T/outputs-3df91d
Some more info:
Using Cocoapods 1.5.3 (also reproduces with latest 1.6.0_beta.1)
Using the "Legacy Build System"
the exact command I'm running to archive is:
xcodebuild -scheme APPSCHEME -workspace APPNAME.xcworkspace -configuration Release clean build archive -derivedDataPath "../build" -archivePath "../build/APPNAME.xcarchive"
Just to make things even more interesting, when running the archive command on my local machine I see no failures... VERY strange and inconsistent.
Any help will be appreciated!
A related case in which this error appears is by running:
xcodebuild -scheme sharetec build
In my case I just had to tune up a little more the parameters like this:
xcodebuild -workspace [WP_NAME].xcworkspace -scheme [A_TARGET] -sdk iphoneos clean build
So the error disappears.
Eventually I figured it out, it's something that looks really UNRELATED, and yet it was the only thing that fixed the described issue for me.
Go to your build settings and remove any recursive search paths you have there. That's it. (any search path that ends with ** is a recursive one).
Good luck!
I had this issue when using AppCenter. I had selected a different version of xcode to that of my project's deployment target.
I had the same issue doing:
xcodebuild -workspace ABC.xcworkspace -scheme SCHEME_NAME archive -archivePath ABC.xcarchive
I solved it by stripping out the -archivePath and its parameter.
I have a possible general solution for this issue. In my case, I followed all the advices from all the possible websites, including this one, but it was no luck until I tried archiving the project on Xcode itself (I was archiving thru fastlane, and its logs didn't help me at all). When I archived in Xcode, it actually showed me where was the problem, and I was able to quickly solve the issue. So, in case nothing works, try archiving in Xcode itself if you happen to archive outside of it.
I'm trying to release a Simulator build for Facebook review of my app.
When I run this command I see a scheme called "Roomify":
xcodebuild -list
Information about project "Roomify":
Targets:
Roomify
RoomifyTests
Build Configurations:
Debug
Release
If no build configuration is specified and -scheme is not passed then "Release" is used.
Schemes:
Roomify
RoomApp
However, when I try to build it fails telling me the scheme doesn't exist, why so?
>xcodebuild -arch i386 -sdk iphonesimulator8.3 -workspace Roomify.xcworkspace/ -scheme Roomify
Build settings from command line:
ARCHS = i386
SDKROOT = iphonesimulator8.3
xcodebuild: error: The workspace 'Roomify' does not contain a scheme named 'Roomify'.
Turns out I used the wrong command to list the schemes in my workspace.
Instead of:
xcodebuild -list
Do:
xcodebuild -workspace Roomify.xcworkspace -list
The following script is part of an aggregate target build phase that is supposed to be used to combine simulator and device targets into one universal framework build. The build originated from this SO answer.
set -e
FRAMEWORK_NAME="${PROJECT_NAME}"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"
######################
# Build Frameworks
######################
echo "PROJECT_NAME: ${PROJECT_NAME}"
echo "CONFIGURATION: ${CONFIGURATION}"
echo "BUILD_DIR: ${BUILD_DIR}"
echo "SIMULATOR_LIBRARY_PATH: ${SIMULATOR_LIBRARY_PATH}"
echo "DEVICE_LIBRARY_PATH: ${DEVICE_LIBRARY_PATH}"
echo "UNIVERSAL_LIBRARY_DIR: ${UNIVERSAL_LIBRARY_DIR}"
xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphonesimulator -target ${PROJECT_NAME} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator
Here is the first error I get when executing this script:
PROJECT_NAME: My-project_Framework
CONFIGURATION: Debug
BUILD_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products
SIMULATOR_LIBRARY_PATH: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphonesimulator/My-project_Framework.framework
DEVICE_LIBRARY_PATH: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphoneos/My-project_Framework.framework
UNIVERSAL_LIBRARY_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphoneuniversal
Build settings from command line:
CONFIGURATION_BUILD_DIR = /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphonesimulator
SDKROOT = iphonesimulator8.1
=== CLEAN TARGET My-project_Framework OF PROJECT My-project_Framework WITH CONFIGURATION Debug ===
Check dependencies
Create product structure
/bin/mkdir -p /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphonesimulator/My-project_iOS.framework
Clean.Remove clean /Volumes/local\ my-project/my-project/ios/Framework/build/My-project_Framework.build/Debug-iphonesimulator/My-project_Framework.build
builtin-rm -rf /Volumes/local\ my-project/my-project/ios/Framework/build/My-project_Framework.build/Debug-iphonesimulator/My-project_Framework.build
Clean.Remove clean /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphonesimulator/My-project_iOS.framework
builtin-rm -rf /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphonesimulator/My-project_iOS.framework
** CLEAN SUCCEEDED **
=== BUILD TARGET My-project_Framework OF PROJECT My-project_Framework WITH CONFIGURATION Debug ===
Check dependencies
error: Unable to create directory: /Volumes/local my-project/my-project/ios/Framework/build (Permission denied)
Now here is the problem
This mount point, /Volumes/local my-project (with a space) has been replaced with /Volumes/localmy-project (without a space). Yet XCode still seems to have the old path somewhere.
Here's what I did to try rip it out of XCode (version 6.1.1):
Added the echo calls to the script to show all the command line inputs to xcodebuild. As you can see this path doesn't come in from the command line call.
Cleaned all targets (Choose each target, Product->Clean).
Checked all the files included in this framework project - all of them have location set to Relative to Project in the inspector.
Restarted XCode.
Restarted the Mac.
Checked project.pbxproj and all other XML files found in the project package contents - no absolute path to be found.
Checked the target in the inspector - its location is absolute (cannot be changed) and correctly points to the new path (/Volumes/localmy-project/...)
Went into the organizer and went Projects->My-Project->Derived Data->Delete.
After all this, the error still persists. So - where the hell is XCode getting this old path from?
Update
I've added the following echos to show a few more build environment variables according to #Louis Tur:
BUILT_PRODUCTS_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-Project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphoneos
CACHE_ROOT: /var/folders/w1/v31fpgnd7sl0yp5ctqjgsxsh0000gn/C/com.apple.DeveloperTools/6.1.1-6A2008a/Xcode
CONFIGURATION_BUILD_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-Project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphoneos
CONFIGURATION_TEMP_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-Project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-Project_Framework.build/Debug-iphoneos
SYMROOT: /Users/foouser/Library/Developer/Xcode/DerivedData/My-Project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products
Update2 - Now with even more echos!
DEPLOYMENT_LOCATION: NO
DERIVED_FILE_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build/DerivedSources
DSTROOT: /tmp/My-project_Framework.dst
INSTALL_DIR: /tmp/My-project_Framework.dst
INSTALL_PATH:
OBJECT_FILE_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build/Objects
OBJECT_FILE_DIR_normal: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build/Objects-normal
OBJECT_FILE_DIR_debug:
OBJROOT: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates
PROJECT_TEMP_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build
REZ_COLLECTOR_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build/ResourceManagerResources
REZ_OBJECTS_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build/ResourceManagerResources/Objects
SHARED_PRECOMPS_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/PrecompiledHeaders
SRCROOT: /Volumes/localmy-project/my-project/ios/Framework
TARGET_BUILD_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Products/Debug-iphoneos
TARGET_TEMP_DIR: /Users/foouser/Library/Developer/Xcode/DerivedData/My-project_Framework-fjaslxiqhnitqxdksjbcxyuugfpk/Build/Intermediates/My-project_Framework.build/Debug-iphoneos/My-project_Framework_Universal.build
Still none of these point to the old path then..
I encountered this problem and solved by reset the Location of Derived data folder in Xcode preference.
After setting, I quit Xcode and relaunch again. It solved.
I still don't know how that old path is coming in, but I've found a workaround that works for me: I can force the correct DerivedData path by using xcodebuild the following way (which replaces the old calls in the script):
xcodebuild -scheme ${PROJECT_NAME} -derivedDataPath ${BUILD_DIR}/../../ -project ${PROJECT_NAME}.xcodeproj -sdk iphonesimulator -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator
xcodebuild -scheme ${PROJECT_NAME} -derivedDataPath ${BUILD_DIR}/../../ -project ${PROJECT_NAME}.xcodeproj -sdk iphoneos -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos
If anyone has an idea where the old path could still persist, please let me know.
I am trying to build Xcode project from command line, using iphonesimulator as SDK. Here is the command line:
xcodebuild -scheme SchemeName -configuration Debug -sdk iphonesimulator PLATFORM_NAME=iphonesimulator clean build
However, when I add a post-build action in Xcode like:
echo "PLATFORM_NAME: ${PLATFORM_NAME}"
it always outputs "PLATFORM_NAME: iphoneos" and not iphonesimulator.
Is this a bug, or there is something wrong in my build configuration? Thanks
I am having one problem that is killing me. Here it is: I have and app project in xCode that goes perfect when I tried to do everything in xCode UI. Which that I mean build, run, test or whatever in all the different targets that I have (3), 2 of the App and one for the tests.
THe problem comes when I tried to install a continous integration to my system in Jenkins. I need to execute some commands in shell for it. Command like this one:
xcodebuild -project MYPROJECT -sdk iphonesimulator -scheme TESTS_SCHEME TEST_AFTER_BUILD=YES
I also have tried with this other one that in the end it does the same:
xcodebuild -project MY_PROJECT -target TEST_TARGET -sdk iphonesimulator -configuration "Debug"
Then is when the problems cames out, the terminal says the following:
....PrecompiledHeaders/MYLIBRARY-Prefix-hhjuztynfruquodlgqxroyfibfkh/MYLIBRARY-Prefix.pch.d
clang: error: invalid architecture 'arm' for deployment target '-mios-simulator-version-min=4.3'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
** BUILD FAILED **
The following build commands failed:
ProcessPCH /Users/nicoyuste/Library/Developer/Xcode/DerivedData/MY_APP-bxpgsdbefuawmiexyikbtvsatlsf/Build/Intermediates/PrecompiledHeaders/MYLIBRARY-Prefix-hhjuztynfruquodlgqxroyfibfkh/MYLIBRARY-Prefix.pch.pth MYLIBRARY-Prefix.pch normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
I´ve been looking in the Internet (almost in here) but everything what I found with same problem didn´t work for me. The xCode version is 4.5 and if you do xcodebuild -version is what I get so that´s fine.
I also have tried changing headers files and everything what I have found around but nothing fixes my problem...
any suggestions...
If you're using a custom build script, you can pass -arch i386 to xcodebuild
For instance:
xcodebuild -project MY_PROJECT -target TEST_TARGET -sdk iphonesimulator -configuration "Debug" -arch i386
(Scroll all the way to the right in the code sample above. The relevant flag is -arch i386)
Should force it to build against i386. However, you need to make sure i386 is in your VALID_ARCHS settings for the target.
In case anyone running into the same annoying problem again, I will share my script here:
Remember to run this command under the directory that has the xcodeproj file.
xcodebuild \
-project "full-path-to-your-xcodeproj-file" \
-target YOUR_TARGET \
-sdk iphonesimulator6.1 \
-arch i386 \
-configuration Debug \
VALID_ARCHS="armv6 armv7 i386" \
ONLY_ACTIVE_ARCH=NO \
TARGETED_DEVICE_FAMILY="1" \
clean install
I modified the TARGETED_DEVICE_FAMILY because I only build for iPhone. If you want to build for both iPhone and iPad, delete this line or replace with TARGETED_DEVICE_FAMILY="1, 2".
I am seeing people who is still wondering about this. I posted this question a long time ago. I stopped using xcodebuild and I am using xctool now, it works much better. This tool is developed by Facebook.
I think that the problem reside in that your are building for the simulator specifying arm as the architecture, try changing it to i386
I ran into a similar problem after upgrading to Xcode 4.5 on my build machine. In my case, I have a third-party library that can't be built for armv7s (yet) and so, I set the Architectures build setting to armv7. Worked fine for unit tests, simulator builds, and the like inside of Xcode. However, when I did the command-line build, it failed with the same message.
I changed my Architectures to armv7 i386 and now it seems to build fine at the command line for the simulator.
Despite the GUI indicating that Architectures of Standard (armv7,armv7s) includes just those two, I'm pretty sure there's an i386 hiding there when you build for the simulator.
In the end, that setting works fine now with Jenkins.
I tried below command:
xcodebuild -arch i386 -sdk iphonesimulator7.1
But failed with similar error as clang: error: invalid architecture 'arm' for deployment target '-mios-simulator-version-min=6.0'
Here is how I solved :
xcodebuild -arch i386 VALID_ARCHS="i386 armv7 armv7s" ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator7.1
U need to make u set VALID_ARCHS and ONLY_ACTIVE_ARCH correctly and it will work. You can make these settings on Xcode directly too.