I would like to build my iOS project (cocoapods) from command line, so I will be able to build it on jenkins. First trigger all unit tests after every commit. On Xcode it is easy, Product -> Test. Can I somehow check what command is executed when I click on it?
I found this: developer.apple
Maybe someone in the future will look for this, so this is how I solved it:
xcodebuild test -workspace 'MyWorkspace.xcworkspace' -scheme 'SchemaTests' -destination 'platform=iOS Simulator,name=iPhone 8,OS=12.1'
Related
I am working on a project that uses Carthage, it’s been a couple of months since the last time the project was opened. Now I am trying to move dependencies to .xcframeworks because with the old .framework, it wasn’t working. I encountered various errors and fixed them but there’s one dependency that I can’t fix,
SwinjectStoryboard
.
I tried using this workaround and setting command line tools
I have also tried creating an empty project with only Swinject and SwinjectStoryboard dependency
but still, my build is failing with the following message
Build Failed Task failed with exit code 65: /usr/bin/xcrun
xcodebuild -project
/Users/abu/Developer/xcframework_2/Carthage/Checkouts/SwinjectStoryboard/SwinjectStoryboard.xcodeproj
-scheme SwinjectStoryboard-iOS -configuration Release -derivedDataPath /Users/abu/Library/Caches/org.carthage.CarthageKit/DerivedData/12.5_12E262/SwinjectStoryboard/2.2.0
-sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive VALIDATE_WORKSPACE=NO
-archivePath /var/folders/g9/rjxzfx7d2s51_sr6stdkpc5c0000gn/T/SwinjectStoryboard
SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO
CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO
FRAMEWORK_SEARCH_PATHS=$(inherited)
/var/folders/g9/rjxzfx7d2s51_sr6stdkpc5c0000gn/T/carthage-xcframework-HTlC
(launched in
/Users/abu/Developer/xcframework_2/Carthage/Checkouts/SwinjectStoryboard)
This usually indicates that project itself failed to compile. Please
check the xcodebuild log for more details:
/var/folders/g9/rjxzfx7d2s51_sr6stdkpc5c0000gn/T/carthage-xcodebuild.Tafjce.log
I am running the following command to build the dependencies
carthage.sh update --use-xcframeworks --platform iOS
here's my contents of my Cartfile
github "Swinject/Swinject"
github "Swinject/SwinjectStoryboard"
I am stuck on this problem for a couple of days now and would appreciate any help
This is really winding me up now, all I am trying to do is an Xcode CLI build using the Xcode command line tools.
The flow is as follows:
App Code is cloned from Git
Info Plist and my own custom plist are generated and copied to project folder
A new app icon set copied over into the assets directory
Xcode Archive build is executed
Xcode generate IPA build is executed
The issue is the Archive part keeps failing, and I cannot get it working. Annoyingly it works fine if I open the project in Xcode and Archive it through there, but that defeats the point of this automated process.
This is the command xcodebuild -verbose -scheme EpicHRV1.1.0 -archivePath ios/app.xcarchive archive
And here is the constant resultant error. I really can't figure out what its complaining about, I mean, it says something to do with Alamofire and missing modules, but why would this work in Xcode but not the command line?
Command failed: xcodebuild -verbose -scheme EpicHRV1.1.0 -archivePath ios/app.xcarchive archive
2017-01-07 20:24:04.255 xcodebuild[43780:2460638] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-11754/DVTFoundation/Utilities/DVTFileSystemUtilities.mm:142
Details: lstat('/Users/Justin/Library/Developer/Xcode/DerivedData/EpicHR-dgdtmzwowkyxgkfzmizhuhiaxkrt/Build/Intermediates/ArchiveIntermediates/EpicHRV1.1.0/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Alamofire.framework/Modules') failed with errno 2 (No such file or directory)
Function: DVTRecursiveMkdirResult dvt_recursiveMkdir_returningErrorString(NSString *__strong, NSString *__autoreleasing *)
Thread: <NSThread: 0x7f90e8ae7cf0>{number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
** ARCHIVE FAILED **
Here is another lovely error which also randomly appears, but not every time...
The following build commands failed:
SymLink /Users/Justin/Library/Developer/Xcode/DerivedData/EpicHR-dgdtmzwowkyxgkfzmizhuhiaxkrt/Build/Intermediates/ArchiveIntermediates/EpicHRV1.1.0/BuildProductsPath/Release-iphoneos/Alamofire.framework /Users/Justin/Library/Developer/Xcode/DerivedData/EpicHR-dgdtmzwowkyxgkfzmizhuhiaxkrt/Build/Intermediates/ArchiveIntermediates/EpicHRV1.1.0/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Alamofire.framework
And another error that sometimes appears. With all of the above the only consistent thing is Alamofire is mentioned in the error..
The following build commands failed:
Strip /Users/Justin/Library/Developer/Xcode/DerivedData/EpicHR-dgdtmzwowkyxgkfzmizhuhiaxkrt/Build/Intermediates/ArchiveIntermediates/EpicHRV1.1.0/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Alamofire.framework/Alamofire
So I solved it with the following commands:
xcodebuild -scheme EpicHRV1.1.0 -archivePath ../ios/app.xcarchive archive
xcrun xcodebuild -exportArchive -exportOptionsPlist exportPlist.plist -archivePath ../ios/app.xcarchive -exportPath ../ios/ipa/
My Expect: # Build Successed # and # Test Failed #
Actual Result: only # Build Succeeded #
How do I get fail/success in command line? [iphone, objective-c, xcode4, OCUnit]
I'm newbe of OCUnit and Xcode4. I create project:
https://github.com/sanemat/HogeHoge
This is scafold code by xcode4. I run test in xcode gui, #Test Failed# appear in successfully. In commandline (I want to use jenkins),I use following command.
xcodebuild -target HogeHogeTests -configuration Debug -sdk iphonesimulator4.3 clean build
I see # Build Succeeded # and then completed. I want run test and get it's result. How?
Edited:
I found BPOCUnitXMLReporter. This is for MacOS. I forked and adjusted iOS.
I found BPOCUnitXMLReporter. This is for MacOS. I forked and adjusted iOS.
Try the Text Finder Plugin It allows you to search a log for a string, and set pass or fail based on that.
You can integrate a custom test logger with OCUnit. See my answer here:
How do I trap OCUnit test pass/failure messages/events
what you're looking for is this undocumented argument (you do need sdk and target too) to run your OCUnit Tests from the terminal
xcodebuild -target MyTarget -sdk iphonesimulator TEST_AFTER_BUILD=YES
I've used to build my project with
xcodebuild -proj MyProject.xcodeproj -target MyTarget - configuration Debug -sdk iphonesimulator4.3
this works(it builds fine) but when I hit run in xcode, it recompiles.
(with xcode3, there was no need to rebuild once I build using command line)
I suspect xcode build use workspace/scheme rather than project/target.
How do I find out the workspace name that my current xcode project is using?
Thank you
edit
Chetan's links gave me directions what to look for.
xcode4 stores build output in ~/Library/...
whereas xcodebuild -project .. saves build output in project's build directory.
(if you want the workspace capability, you can't use the build directory for build output)
I created a workspace containing my project and ran
xcodebuild -workspace myWorkSpace -scheme myScheme
this saves build output in ~/Library/...../Debug-iphoneos
whereas xcode4 run button from the same workspace and same scheme saves output in
~/Library/..../Debug-iphonesimulator
any guess on why xcodebuild command uses Debug-iphoneos? :(
edit2
xcodebuild -workspace myWorkSpace -scheme myScheme -sdk iphonesimulator4.3
specifying sdk solved it
I know it isn't strictly the answer to your question, but you can configure the output directory of your build using the CONFIGURATION_BUILD_DIR environment variable.
Source: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/0-Introduction/introduction.html#//apple_ref/doc/uid/TP40003931-CH1-SW1
i like to run test cases from the command line but there is a little problem… maybe someone can help me…
i' ve created a simple HelloWorld Project with XCode4! The build works fine.
xcodebuild -project HelloWorld.xcodeproj -target HelloWorld -sdk iphonesimulator4.3 -configuration "Debug"
But the test doesn't work (i use the default unit test which xcode4 creates)
xcodebuild -project HelloWorld.xcodeproj -target HelloWorldTests -sdk iphonesimulator4.3 -configuration "Debug"
Here are some interesting outputs:
=== BUILD NATIVE TARGET HelloWorld OF PROJECT HelloWorld WITH THE
DEFAULT CONFIGURATION (Release) ===
Check dependencies
And
/Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/Tools/RunPlatformUnitTests:95:
warning: Skipping tests; the
iPhoneSimulator platform does not
currently support application-hosted
tests (TEST_HOST set).
I guess the last output is the problem but i haven't any idea to fix it :-(
It sounds as though you may have unit tests and application tests mixed up. Referring to the two following sources (especially the non-apple one) will help you out a lot:
Apple's Documentation
CocoaWithLove Article