xcodebuild doesn't show all compile errors? - ios

There are 2 compile errors in my project(Display in XCode).
But when I use xcodebuild to compile the project in terminal, only one compile error display
xxx$xcodebuild -sdk iphoneos -configuration Debug
....
....
[self updateAccountInfo];1
^
1 warning and 1 error generated.
Is it possible to make xcodebuild display all compile errors?
In the Xcode's Preference, in the General Tab, check the "Continue building after errors" option. asked here
What I need is to use xcodebuild do the same thing.
EDIT:
After thinking and researching these days, I think xcodebuild can't do this. It's different from xcode. When we use xcode to compile iOS project, xcode compile every .m by clang. So xcode has "Continue building after errors" feature

You need to set the Xcode preferences to do this (from Terminal.app):
$ defaults write com.apple.Xcode PBXBuildsContinueAfterErrors YES
for xCode 8:
$ defaults write com.apple.dt.Xcode IDEBuildingContinueBuildingAfterErrors 1

If you want to continue building after errors using the latest version of xcodebuild/xctool you will need to run them with -IDEBuildingContinueBuildingAfterErrors=YES.
Example:
xctool -project SampleProject.xcodeproj/ -scheme SampleProject -sdk iphonesimulator build -IDEBuildingContinueBuildingAfterErrors=YES
Looks like PBXBuildsContinueAfterErrors isn't supported anymore.
Also you can use defaults write com.apple.dt.Xcode to make this setting permanent. If you want to have a look how you current version of IDE is controlling that setting you can call defaults read com.apple.dt.Xcode and search for "errors" and "continue".

Related

How can I build the Xcode-generated Swift Package Workspace with xcodebuild?

When you open a Package.swift file, Xcode will generate a workspace with the path: .swiftpm/xcode/package.xcworkspace.
I'd like to use xcodebuild to build this but it does not seem to work. The error messages are not helpful, just tells me that clang failed.
The actual command I'm running is:
xcodebuild -workspace .swiftpm/xcode/package.xcworkspace -scheme MyLibrary-Package -sdk iphonesimulator OTHER_SWIFT_FLAGS="-D SWIFT_PACKAGE"
Funny enough, trying to build a scheme that describes an individual target works:
xcodebuild -workspace .swiftpm/xcode/package.xcworkspace -scheme SpecificTarget -sdk iphonesimulator OTHER_SWIFT_FLAGS="-D SWIFT_PACKAGE"
Am I missing some build flags needed to build the combination scheme? Has anyone else struggled with this and have any advice?
Note:
The ultimate goal here is to be able to verify that my Swift Package builds in CI. If there is an easier way to achieve this goal then I'm happy to go another route. (The easier might just be multiple commands to build the individual targets but this is less robust)

xcodebuild equivalent of Xcode's "Product > Build For > Testing"

I'm trying to write a script that submits iOS apps to AppThwack (a 'real device' UI testing service). Their guidance is to use the Xcode GUI and build the app using the Build For > Testing option in the Xcode Product menu. This works, but I haven't been able to translate this into the xcodebuild equivalent.
More generally, how do we determine what arguments Xcode is passing to xcodebuild (assuming it uses that tool).
This is now possible as of Xcode 8 (in beta at time of writing). Use build-for-testing.
Example:
xcodebuild -workspace <workspace> -scheme <scheme> -destination 'generic/platform=iOS' build-for-testing
To switch to a beta version of xcodebuild, use xcode-select:
sudo xcode-select -switch /Applications/Xcode-beta.app/Contents/Developer
xctool has a flag called build-tests that will do just that.
(As of this post, it is not currently Xcode 7 compatible, but they are working on it.)

Xcodebuild is not creating an app

I'm trying to create a simulator app to submit to Facebook for review. I've followed their instructions to the letter, but keep running into problems. I am using CocoaPods and have a workspace instead of a plain old project. Here's the command I'm running:
xcodebuild -arch i386 -sdk iphonesimulator8.1 -workspace [APP].xcworkspace -scheme [APP]
I get a ** BUILD SUCCEEDED ** message, but either one of two things will happen:
No build folder is created, and I can't find where the .App file is.
A .App is created in a build folder, but is 0 bytes in size and crashes when running with ios-sim.
I read that changing the Run scheme to 'Release' might fix it, but that didn't do anything. Any ideas?
So, I had the same problem and solved it by doing the following:
I made my app as release build instead of debug in xcode: Product->Scheme->Edit Scheme and then Build Configuration set to Release.
After doing this I then went back to the command line and added a destination for the build:
xcodebuild -arch i386 -sdk iphonesimulator8.1 -workspace [APP].xcworkspace -scheme [APP] -derivedDataPath /path/to/build
If you are still having problems make sure you clean and build all of your targets (pods included) and try the above steps again.
Hope this works; it did for me.

"You can’t open the application because it is not supported on this type of Mac." xcodebuild

When I try to build my xcode project using the following command:
xcodebuild -workspace "Converse.xcworkspace" -sch
eme "Converse" -configuration “Debug” -sdk iphonesimulator7.1 -arch i386 ONLY_
ACTIVE_ARCH=NO
It builds fine, but when I try to double click on the app it generates, it says: You can’t open the application because it is not supported on this type of Mac. Does anyone know why this is happening?
iOS apps need the simulator to run. You can just, as you said run them from Xcode. If you do not have the project then you need to deploy them like :
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication /Path/ToIso.app/AppName
Use Xcode, not xcodebuild, to run your app on the simulator.

xcconfig option in xcodebuild command

I have created an app in IOS and want to build and run it through command line. The xcodebuild command helps in building the app and its basic syntax is as follows:
xcodebuild -target "${TARGET_NAME}" -sdk "${TARGET_SDK}" -configuration Release -xcconfig "${BUILD_SETTINGS_FILE_PATH}"
Each target will contain its product name and other build settings. Now I don't want to take the product name/build settings specified in xcode target, but rather through some external file which can contain build settings. So, i tried using the -xcconfig option but I am not clear with its implementation. What kind of file it should be and how the path to the file be configured?. The official documentation also doesn't seem to be too clear.
xcodebuild PRODUCT_NAME argument affects all targets
.xcconfig file can be created using Xcode and the format of providing value is:
CUSTOM_CFBundleVersion = 3.0.
CUSTOM_CFBundleShortVersionString = 3.0

Resources