Error building iOS workspace from terminal - ios

I'm having problems building an iOS app from the terminal. I'm following the xcodebuild -h help but I can't make it work... I've been googling a lot the errors I'm getting but can't find an answer to this...
This is what I'm doing:
xcodebuild -workspace AppName.xcworkspace -scheme 'Integration Tests' -configuration Debug
And the error I'm getting is:
The following build commands failed:
ProcessPCH /Users/UserName/Library/Developer/Xcode/DerivedData/AppName/Build/PrecompiledHeaders/AppName-Prefix/AppName-Prefix.pch.pth AppName/AppName-Prefix.pch normal armv6 objective-c com.apple.compilers.llvm.clang.1_0.compiler
ProcessPCH /Users/UserName/Library/Developer/Xcode/DerivedData/AppName/Build/PrecompiledHeaders/AppName-Prefix/AppName-Prefix.pch.pth AppName/AppName-Prefix.pch normal armv6 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)
I can't find whats failing, using xCode I do can compile and run this app without problem... Any idea in whats happening?
Thanks!

Have you tried selecting your xcode with xcode-select?
xcode-select -switch /Applications/Xcode.app/Contents/Developer
In most cases…
You could also try to renew the xcodebuild via
$sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer
$cd /usr/bin
$sudo rm xcodebuild
$ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild xcodebuild

Related

AppCenter failed to get module and shows error 65

I am using Swift with CocoaPods and trying to build it in AppCenter.
I kept getting this failing log
CompileSwift normal arm64 (in target 'Wundercast' from project 'Wundercast')
cd /Users/runner/runners/2.165.2/work/1/s
/Applications/Xcode_11.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -emit-bc /Users/runner/runners/2.165.2/work/1/s/Wundercast/ViewController.swift /Users/runner/runners/2.165.2/work/1/s/Wundercast/Utils/Colors.swift /Users/runner/runners/2.165.2/work/1/s/Wundercast/AppDelegate.swift /Users/runner/runners/2.165.2/work/1/s/Wundercast/Controllers/ApiController.swift /Users/runner/runners/2.165.2/work/1/s/Wundercast/Utils/Appearance.swift -supplementary-output-file-map /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/supplementaryOutputs-8c8267 -target arm64-apple-ios10.1 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk -I /Users/runner/Library/Developer/Xcode/DerivedData/Wundercast-ermhkmlzqioflkgqqzuvbqmqczqy/Build/Intermediates.noindex/ArchiveIntermediates/Wundercast/BuildProductsPath/Release-iphoneos -F /Users/runner/Library/Developer/Xcode/DerivedData/W...
/Users/runner/runners/2.165.2/work/1/s/Wundercast/ViewController.swift:30:8: error: no such module 'RxSwift'
import RxSwift
^
** 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)
##[error]Error: /usr/bin/xcodebuild failed with return code: 65
With previous research, I have configured the project with xcworkspace, and appcenter-post-clone.sh to install CocoaPods.
Here is the test project link.
What should I do to fix this?
After a few tries with a blank project, it worked pretty well with the following appcenter-post-clone.sh
#!/usr/bin/env bash
echo "Uninstalling all CocoaPods versions"
sudo gem uninstall cocoapods --all --executables
COCOAPODS_VER=`sed -n -e 's/^COCOAPODS: \([0-9.]*\)/\1/p' Podfile.lock`
echo "Installing CocoaPods version $COCOAPODS_VER"
sudo gem install cocoapods -v $COCOAPODS_VER
cd $APPCENTER_SOURCE_DIRECTORY
pod install
However, the original project still fails in the release mode even locally. At least I now know the problem has nothing to do with AppCenter, but rather has some issues with Xcode. By dragging the project files into a new Xcode project, it worked like charm.

Xcode 10 archiving fails - only on command line (xcodebuild)

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.

xcodebuild: cdtool cannot compile: DataModelCompile /path/to/coredatamodel.xcdatamodeld dyld: Symbol not found: _OBJC_CLASS_$_OS_object

I'm building a Mac Desktop/Cocoa Application to archive my iOS project, the core implementation uses NSTask with xcodebuild command, followed by raywenderlich's this guide.
The root cause is the CoreData model file compile, I used this app to build my another project which didn't contain any CoreData files and no issue there. More interesting comparison is, I tried the same xcodebuild command in my terminal and it just succeed!
Then I start to diff the two xcodebuild output and found some differences,
In terminal,
DataModelCompile /Users/hanwei/Library/Developer/Xcode/DerivedData/youYue3xMaster-cjatyqmgblwyoyccarejxlozikdi/Build/Intermediates/ArchiveIntermediates/youYue3xMaster/InstallationBuildProductsLocation/Applications/youYue3xMaster.app/ youYue3xMaster/LogicBook.xcdatamodeld
cd /Users/hanwei/work/DragonSource/projects/ios_youyue3_xmaster/youYue3xMaster
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/opt/subversion/bin:/usr/local/bin:/opt/subversion/bin:/usr/local/bin:/opt/subversion/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin"
/Applications/Xcode.app/Contents/Developer/usr/bin/momc --sdkroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk --iphoneos-deployment-target 7.0 --module youYue3xMaster /Users/hanwei/work/DragonSource/projects/ios_youyue3_xmaster/youYue3xMaster/youYue3xMaster/LogicBook.xcdatamodeld /Users/hanwei/Library/Developer/Xcode/DerivedData/youYue3xMaster-cjatyqmgblwyoyccarejxlozikdi/Build/Intermediates/ArchiveIntermediates/youYue3xMaster/InstallationBuildProductsLocation/Applications/youYue3xMaster.app/
In my cocoa app's log
DataModelCompile /Users/hanwei/Library/Developer/Xcode/DerivedData/youYue3xMaster-cjatyqmgblwyoyccarejxlozikdi/Build/Intermediates/ArchiveIntermediates/youYue3xMaster/InstallationBuildProductsLocation/Applications/youYue3xMaster.app/ youYue3xMaster/MagazineModel.xcdatamodeld
cd /Users/hanwei/work/DragonSource/projects/ios_youyue3_xmaster/youYue3xMaster
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/usr/bin/momc --sdkroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk --iphoneos-deployment-target 7.0 --module youYue3xMaster /Users/hanwei/work/DragonSource/projects/ios_youyue3_xmaster/youYue3xMaster/youYue3xMaster/MagazineModel.xcdatamodeld /Users/hanwei/Library/Developer/Xcode/DerivedData/youYue3xMaster-cjatyqmgblwyoyccarejxlozikdi/Build/Intermediates/ArchiveIntermediates/youYue3xMaster/InstallationBuildProductsLocation/Applications/youYue3xMaster.app/
dyld: Symbol not found: _OBJC_CLASS_$_OS_object
Referenced from: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk/usr/lib/system/libxpc.dylib
Expected in: /usr/lib/system/introspection/libdispatch.dylib in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk/usr/lib/system/libxpc.dylib
2016-06-17 09:46:28.158 momc[76594:13533677] *** -[NSKeyedUnarchiver initForReadingWithData:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?
cdtool invalid hashes:
/Users/hanwei/work/DragonSource/projects/ios_youyue3_xmaster/youYue3xMaster/youYue3xMaster/MagazineModel.xcdatamodeld/MagazineModel.xcdatamodel:: error: cdtool cannot compile
The main error log detail could be found in later part, the diff result is "export PATH=...". In terminal, the PATH contains the current user's ${PATH}, I through that should be the final cause, but no luck there after trying to export the same path to my cocoa app's shell script.
Here is my shell script,
command -v xcodebuild >/dev/null 2>&1 || { echo >&2 "It requires xcodebuild but it's not installed. Aborting."; exit 1; }
#export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/opt/subversion/bin:/usr/local/bin:/opt/subversion/bin:/usr/local/bin:/opt/subversion/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin
#PATH=$PATH:/opt/subversion/bin:/usr/local/bin:/opt/subversion/bin:/usr/local/bin:/opt/subversion/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin
echo ${PATH}
type xcodebuild
type xcpretty
if [ -x "$(command -v xcpretty)" ]; then
xcodebuild -workspace "${1}" -scheme "${2}" -sdk iphoneos -destination generic/platform=iOS -archivePath "${3}" archive | xcpretty
else
echo "xcpretty is not installed, suggest to install it and try again.";
xcodebuild -workspace "${1}" -scheme "${2}" -sdk iphoneos -destination generic/platform=iOS -archivePath "${3}" archive
fi
For the error "dyld: Symbol not found: _OBJC_CLASS_$_OS_object...", I googled it and found that _OBJC_CLASS_$_OS_object symbol built from libdispach, libdispatch should be built in Foundation.framework, then I tried to link Foundation.framework in my project explicitly, the same error exists.
For the "Referenced from:...Expected in:..."* statement, it references to iPhone simulator, then I guess there maybe something wrong about xcodebuild -destination, passing generic/platform=iOS or my iOS device (references from this cheetsheet) doesn't work, either.
For "error: cdtool cannot compile", I found this big question related in Xcode bug, .xcdatamodel: cdtool cannot compile, I tried the rename solution and no luck, that question background is for Xcode beta version.
Currently my environment is Xcode 7.3.1 (7D1014), 10.11.5 (15F34).
I've focus on this issue over 8 hours, If you have some good suspect points or solutions, please help me, great thanks in advance!
BTW, I found #MichalMoskala encountered the same problem and no solution there, Calling xcodebuild from Swift command line tool fails. He didn't statement the background it happened in Xcode-beta version.
If there is really no final solutions, I have to decide to transit CoreData to FMDB/Realm.
UPDATE
SOLUTION
After several days' investigation, I didn't find a real final solution for this, it should be bug in Xcode when compiling xcdatamodeld file in xcodebuild by hand. But why not appear in Xcode IDE? Maybe Apple developers made some patches in Xcode.
Here is my solution, copy the compiled xcdatamodeld files (*.momd) to project, remove the *.xcdatamodeld file from Build Phrases - Compile Sources in project, so that they will not be compiled when building/archiving. Add custom script to copy the .momd backup files to product directory, it's executed before Compile Sources, just like the build progress in Xcode.
Here is my script,
cp -r ${SRCROOT}/CoreDataFiles/*.momd ${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}/
Validation passed!

xcode command line build failed with com.apple.compilers.llvm.clang.1_0.compiler

XCode Version: Version 7.2 (7C68)
Building for PhoneGAP IOS
Commands used:
xcodebuild -project HelloCordova.xcodeproj -scheme HelloCordova -configuration Release -sdk iphonesimulator IDENTIFIER=com.kony.SyncApp build
It used to work well before upgrading Xcode after upgrading to 7.2 , i am facing this issue. And same wokring form XCODE UI
Problem with command line build
Error Info:
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
** BUILD FAILED **
The following build commands failed:
ProcessPCH /Users/konysync/Library/Developer/Xcode/DerivedData/HelloCordova-gyroiomjvclmgtfewwtckeoypgfd/Build/Intermediates/PrecompiledHeaders/CordovaLib_Prefix-almeazhzuslzcvewimbluxlrnwby/CordovaLib_Prefix.pch.pch CordovaLib_Prefix.pch normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
ProcessPCH /Users/konysync/Library/Developer/Xcode/DerivedData/HelloCordova-gyroiomjvclmgtfewwtckeoypgfd/Build/Intermediates/PrecompiledHeaders/CordovaLib_Prefix-bvlrmrstkahcccfcihrhcdumeenk/CordovaLib_Prefix.pch.pch CordovaLib_Prefix.pch normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)
found some links , but those links did not help.
Apple LLVM Compiler 3.1 error clang
Unsupported compiler 'com.apple.compilers.llvm.clang.1_0' selected for architecture 'x86_64' on Xcode 7 Beta 2
Clear the cache of pod with
rm -rf ~/Library/Caches/CocoaPods
rm -rf Pods
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod deintegrate
pod setup
Change flipper version in pod file:
use_flipper!({ 'Flipper-Folly' => '2.5' })
And delete the project's Pods directory. The location of it is project directory > ios > Pods.
Then in the project directory > ios location, install pod with pod install
And
react-native run-ios
in project directory.
This is a bug introduced in Xcode 7.2 (and still not fixed as of 7.2.1), see https://openradar.appspot.com/23857648 It seems that xcodebuild is not setting correctly the ARCH and PLATFORM_NAME variables when invoked with -sdk iphonesimulator.
There are two known workarounds at the moment, both involve passing extra flags to xcodebuild:
1) Pass the -destination flag, eg:
xcodebuild [...] -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6'
2) Override the PLATFORM variable, eg:
xcodebuild [...] -sdk iphonesimulator PLATFORM_NAME=iphonesimulator
I had this error after upgrading to React Native 0.68.x
AppDelegate.m changed to AppDelegate.mm
You have to do this: https://github.com/software-mansion/react-native-reanimated/issues/841#issuecomment-636297029 open the project in XCode, then navigate to Build Phases, in Compile Sources remove the AppDelegate.m file and add AppDelegate.mm instead.
If it is not already renamed: Open XCode, rename AppDelegate.m to AppDelegate.mm in the Project Navigator
i have tried to resolve this error many times and follows multiple steps of every one but not worked for me after that i deleted my build folder from project ios directory like react-native-project>ios>Build folder
it worked for me.

xcodebuild test command for using with jenkins doesn´t work

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.

Resources