xcodebuild doesn't work when specifying -sdk option - ios

I'm trying to manually compile an xcode project and I can't manage to compile it using xcodebuild when I specify an SDK through the -sdk option.
This fails:
/usr/bin/xcodebuild -project "libjpeg.xcodeproj" -configuration "Release" -sdk iphonesimulator -arch i386 CONFIGURATION_BUILD_DIR=build build
and this works:
/usr/bin/xcodebuild -project "libjpeg.xcodeproj" -configuration "Release" -arch i386 CONFIGURATION_BUILD_DIR=build build
I have installed XCode 4.3.3 and Command line tools from the Apple's developer page, and everything else it's working without problems. If I build this project using XCode, it works without problems too. There's no other xcode version in my system.
I should have something really broken in my env, but I can't manage to find it. I'd appreciate any hints you could give me.

You need to specify something like -sdk iphonesimulator6.0
See this answer: parameter for xcodebuild for using latest sdk.

Related

Universal Framework Binaries: Why Build Simulator and Archive Device?

I am using a script provided by Greg Brown to successfully build a universal framework binary. Here are the two lines that invoke xcodebuild:
xcodebuild archive -project $FRAMEWORK_DIR/$FRAMEWORK.xcodeproj -scheme $FRAMEWORK -sdk iphoneos SYMROOT=$BUILD
xcodebuild build -project $FRAMEWORK_DIR/$FRAMEWORK.xcodeproj -target $FRAMEWORK -sdk iphonesimulator SYMROOT=$BUILD
Note that the archive action is being used to produce the device (arm64 architecture) whereas the build action is being used to produce the simulator (x86_64 architecture).
In a different article entitled iOS 9 Universal Cocoa Touch Frameworks the author remarks: "Note that you will both have to build with your Simulator and Archive with your device to get a universal."
So, what's up with build vs archive? Why not build both?
So, what's up with build vs archive? Why not build both?
The way it works is that Apple doesn't allow simulator binaries (x86_64 and i386) to be uploaded to the app store. If your frameworks contain those binaries, then you won't be able to upload the containing app to the app store.
You would distribute your framework with all the possible binaries so that it can run on Simulators and devices alike. But would like to strip off those Simulator binaries before uploading to the app store.
P.S. I've explained this in detail in another answer here. The answer also explains as to why the issue doesn't exist when using frameworks via Cocoapods.
Edit:
The difference between build vs archive is that archive accepts a scheme to run.
An Xcode scheme defines a collection of targets to build, a configuration to use when building, and a collection of tests to execute.
Also,
You cannot use archive option for the iOS Simulator platform.
You could essentially use xcodebuild build for both of the platforms. You will essentially get the same result. The commands that I use to build my framework are as follows (both commands use the build action):
xcodebuild -target ${PROJECT_NAME} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target ${PROJECT_NAME} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build

Building project using xcodebuild fails with Xcode 7.2

I just moved to Xcode 7.2 and am trying to compile a dynamic framework using xcodebuild and lipo
xcodebuild -project ProjectName.xcodeproj -scheme ProjectName -sdk iphonesimulator
This command fails with strange errors like Unsupported architecture (in frameworks like CoreText). The issue has also been discussed here but I don't see a solution which would work. Any help?
This is due to a bug in Xcode 7.2 (and 7.2.1).
A workaround suggestion has been provided in the supplied link since this question was asked. To sum up, you can add the parameter PLATFORM_NAME=iphonesimulator, and then it magically works. For example:
xcodebuild -project ProjectName.xcodeproj -scheme ProjectName -sdk iphonesimulator -arch i386 PLATFORM_NAME=iphonesimulator build
See also my answer here (where there is also another suggestion for a workaround)

Aggregate Script for iOS framework with Bitcode

I have a iOS framework and I want to generate a universal target full bitcode support, right now I create an aggregate script and I'm using the xcodebuild command to generate the different versions (device and simulator) but when we try to generate the archive we always receive the error because the library doesn't have full bitcode support.
This is how I'm using the xcodebuild command:
xcodebuild -fembed-bitcode -project ${PROJECT_NAME}.xcodeproj -sdk iphonesimulator -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator 2>&1
xcodebuild -fembed-bitcode -project ${PROJECT_NAME}.xcodeproj -sdk iphoneos -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos 2>&1
At the end the only way that I found to achieve this is first, generating the device build with Product -> Archive (Make sure to select on "Skip Installs" to NO on "Build Settings", to get the device framework) then create a package manually using the lipo command using the two builds: the Device's framework and the Simulator's framework.
The bitcode is only generated when you use the Archive command, if you use a build command Xcode won't generate the bitcode

Terminal Command build xcode project for 64 bit with all other also

I am using below command :
xcodebuild -project $PROJECT_NAME.xcodeproj -scheme $PROJECT_NAME -sdk iphonesimulator -configuration Debug
xcodebuild -project $PROJECT_NAME.xcodeproj -scheme $PROJECT_NAME -sdk iphoneos -configuration Debug
for building the application it's working but I need to build our application with iphone/ipad retina 64 bit but it' not working.
for combining
lipo -create "${WS_DIR}/Build/Debug-iphoneos/libRPCCore.a" "${WS_DIR}/Build/Debug-iphonesimulator/libCore.a" -output "${WS_DIR}/Build/RPCLib/libCore.a"
I am not able to build the application for ipad/ipahone retina 64 bit application using terminal command. please help to create the build script.
I suspect this is because you have Build Active Architecture Only set for Debug mode, which is the default setting I believe. This is because there is no need to build for all architectures during debugging as the build is expected to run only on the device being used for debugging.
This is normally turned off for release and you can test this from the command line by using -configuration Release.
BTW I don't believe you need to specify the -sdk option to xcodebuild as the build settings should have that covered.

Using jenkins to build mulitple versions of an IOS app with a single target

I have an ios app that will have two versions (using preprocessor directives to determine what code to use for which version). I would like to automatically build each version of the app using Jenkins. I would also like to use a single target in the xcode project if possible. Is the possible using a multiple-configuration project in Jenkins; and if so, I would I go about accomplishing this?
You need to change the XCode scheme in your build script.
For example, if you had two schemes on for testing, say staging and production, you would need to have to build scripts that look similar to this.
xcodebuild -configuration Debug -scheme "Test Staging" -sdk iphonesimulator5.1 -arch i386 build
xcodebuild -configuration Debug -scheme "Test Prod" -sdk iphonesimulator5.1 -arch i386 build
Your schemes can then be configured in XCode to match the preprocessor directives.

Resources