How to: `xcodebuild -xcworkspace..` with project and swift packages - xcode

I have created a xcworkspace to add my iOS.xcproj and local swift package. The workspace builds and runs great from Xcode. What would be the xcodebuild command to do in my CI?
I have been trying using the following:
xcodebuild -workspace [name].xcworkspace -scheme [scheme_name] -configuration [config] -xcconfig [path_xcconfig]
I get this in the output console:
...note: Building targets in dependency order
error: Multiple commands produce <RegisterExecutionPolicyException...
sample:
note: Target 'Firebase_FirebaseInAppMessaging_iOS' (project 'Firebase'): Touch /Users...

Related

xcodebuild fails, but building from Xcode succeeds

I'm trying to automate my build using xcodebuild.
However, my xcodebuild fails while building static libraries, complaining that it can't find headers that are part of dependency frameworks.
No problem to build from Xcode.
Why is the result of xcodebuild different from the one of Xcode?
You might accidentally build the Xcode project instead of the Xcode Workspace from xcodebuild.
If this is the case, replace:
xcodebuild -project "<*yourProjectFile*>.xcodeproj"
with:
xcodebuild -workspace <*yourWorkspaceFile*>.xcworkspace
After fixing this I get the exact same results from Xcode and xcodebuild.

Xcodebuild no such module

I'm trying to build an Xcode project through the terminal. My project uses a submodule called SwiftRichString which I'm importing in one of my files.
On my terminal, I tried:
xcodebuild -project MyProject.xcodeproj
But this says that it cannot find the module called SwiftRichString, as expected.
So then I tried,
xcodebuild -scheme SwiftRichString
This worked and said "Build Succeeded", but then if I try to do
xcodebuild -project MyProject.xcodeproj
it fails just like before.
If I go to Xcode and go to Product>Scheme>SwiftRichString and build it, it succeeds building. Then if I build my project within Xcode, it works, but it doesn't build in terminal.

Archive multiple IOS xcode target in command line

I have an iOS Xcode project that has several targets. The number of targets in the project will continue to grow as the project progresses and expands. When I create a new version, it is a pain to have to go through each target and manually create the Archive. I looked into how to archive multiple targets using the command line, but none of the answers spoke to what I was trying to accomplish. Any help and guidance is appreciated.
I believe that the following partial command is part of the solution:
xcodebuild archive
archive: Archive a scheme from the build root (SYMROOT). This requires specifying a workspace and scheme.
I suppose you want to build it for CI server Manually
If you want to read all the schemes in a xcode project
xcodebuild -list | awk 'p && NF {print \$0";";} /Schemes:/ {p=1}' > schemeList.txt
This will put all your schemes in a text file. Then you have to read the text file manually to retrieve each scheme.
You can use the below command line to produce the archive
xcodebuild -scheme ${schemeName} -sdk iphoneos$sdkVersion -configuration Release clean archive -archivePath ${archivePath}.xcarchive
And then the below xcode command to produce the ipa.
xcodebuild -exportArchive -archivePath ${archivePath}.xcarchive -exportOptionsPlist exportOptions.plist -exportPath ${exportPath}

Running Xcode target from command line

I am new to running unit tests using Catch.
I am using the Catch to run unit tests in my Xcode project. I have added a target to my project which includes my Catch files and tests cases. Selecting that target and running from Xcode runs fine. I am now trying to get it to run from the command line which will be the way it is run from Jenkins. I have a shell script that contains:
xcodebuild clean install
xcodebuild -target TestApp -configuration “Debug” -sdk iphonesimulator7.1 CONFIGURATION_BUILD_DIR=TestBuild ONLY_ACTIVE_ARCH=NO
The result is:
** INSTALL SUCCEEDED **
Build settings from command line:
CONFIGURATION_BUILD_DIR = TestBuild
ONLY_ACTIVE_ARCH = NO
SDKROOT = iphonesimulator7.1
--- xcodebuild: WARNING: Configuration “Release” is not in the project. Building default configuration.
=== BUILD TARGET CreativeSDKTest OF PROJECT CreativeSDKImage WITH THE DEFAULT CONFIGURATION (Release) ===
Check dependencies
** BUILD SUCCEEDED **
But the application doesn’t launch in the simulator. Maybe I’m not seeing the obvious but from all the docs I’ve read, this should launch the application.
I think you'll need to tell xcodebuild to test the project:
xcodebuild clean install
xcodebuild -target TestApp -configuration “Debug” -sdk iphonesimulator7.1 CONFIGURATION_BUILD_DIR=TestBuild ONLY_ACTIVE_ARCH=NO clean test
(See the end of the last command)
EDIT: In fact you probably don't even need the first command and just the second will do.

xcodebuild build xcode project with dependent project failed. dependent project's target not found

My main project named sample.xcodeproj dependends on sdklib.xcodeproj. The target of sdklib.xocdeproj is sdk.a.
when I build the sample.xcodeproj with xcodebuild command
xcodebuild -project sample.xcodeproj
It failed.
error: no such file or directory:'/Users/.../libsdklib.a
It seems the dependent project doesn't builded. I also didn't see the libsdklib.a in sdklib.xcodeproj's target path. But It runs well in xcode. So where is the sdk.a when I build sample.xcodeproj? and how can I use the xcodebuild command to build sample.xcodeproj with sdklib.xcodeproj?

Resources