For those wondering if it’s safe to install the Xcode 6 beta on your dev machine; the short answer is: yes. It installs along Xcode 5 and you can switch between and uninstall easily. This is a simple walkthrough to get you started Xcode 6 and the iOS8 SDK with Titanium.
Install Xcode 6 beta
- Download the 2.5GB DMG – Requires login
- Drag the Xcode6-Beta app to Applications – It will not overwrite Xcode
- Open Xcode6-Beta to agree to new terms and install additional tools, or run
$ sudo xcodebuild -licenseto do the first since it seems you don’t need the tools.
Build against Xcode6/iOS8 via CLI
If you don’t specify a SDK version (
--ios-version), the Titanium CLI will default to the latest SDK found in any of the detected Xcode installs and automatically use that Xcode install. So, to build using Xcode6/iOS8 you don’t have to do anything but:
$ ti build -p ios
Which will fail:
.. [INFO] Building using iOS SDK: 8.0 [INFO] Building for iOS iPad Simulator: 8.0 [INFO] Building for device family: ipad [DEBUG] Setting Xcode target to Debug [DEBUG] Setting Xcode build OS to iphonesimulator8.0 [DEBUG] Xcode installation: /Applications/Xcode6-Beta.app/Contents/Developer .. [INFO] Launching application in iOS Simulator [DEBUG] Simulator command: "/Users/fokkezb/Library/Application Support/Titanium/mobilesdk/osx/3.2.3.GA/iphone/ios-sim" launch "/Users/fokkezb/dev/apps/timewax/build/iphone/build/Debug-iphonesimulator/Timewax.app" --xcode-dir "/Applications/Xcode6-Beta.app/Contents/Developer" --sdk 8.0 --family ipad [INFO] Focusing the iOS Simulator [ERROR] Project failed to build after 3s 151ms
But that’s actually just launching the simulator (or deploying to device) that failed. The Xcode project is fine. Just open
build/iphone/*.xcodeproj in Xcode6-Beta, select the right target and simulator/device and let it build and run. This works fine for both simulators and devices. I’ve seen little errors so far, e.g.
Ti.Platform.displayCaps.platformWidth not taking the orientation into account (similar to Android).
Build against Xcode5/iOS7.1 via CLI
To build against Xcode5/iOS7.1 just pass the SDK version and Titanium will automatically use Xcode 5 since Xcode 6 only has the iOS 8 SDK.
$ ti build -p ios -I 7.1
If you don’t want to do this all the time, just install the TiNy CLI and overwrite the default recipe to include the SDK version:
$ sudo npm install -g tn --unsafe-perm $ tn default ios -I 7.1 $ tn
Build against Xcode6/iOS8 via Studio
Studio always passes the SDK (and simulator) version you have selected in the Run Configuration. Studio uses the Xcode install selected via
xcode-select, so if you want to switch to Xcode 6 to be able to select the iOS 8 SDK you’ll need to do the following first:
$ sudo xcode-select -s /Applications/Xcode6-Beta.app/Contents/Developer
Then close and re-open Studio or hit Refresh under Titanium Studio > Preferences > Studio > Platforms > iOS > General.
Now in your Run Configurations you can (must) select 8.0 for the iOS SDK and Simulator Version:
Press Run to build. Now just like via the CLI, this will end saying
Project failed to build after... because Titanium probably cannot deal with the new Simulator profiles in Xcode 6. So again, open
build/iphone/*.xcodeproj in Xcode6-Beta, select the right target and simulator/device and you’re done.
Debugging won’t work of course.
Build against Xcode5/iOS7.1 via Studio
If after switching to Xcode6-Beta you want to build against Xcode5/iOS7.1 again you must again use
xcode-select and restart or refresh Studio:
$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Uninstalling Xcode 6 beta
Just drag the app to Trash.. yep, it’s that simple :)