Using Xcode 6 for Titanium

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

  1. Download the 2.5GB DMG – Requires login
  2. Drag the Xcode6-Beta app to Applications – It will not overwrite Xcode
  3. Open Xcode6-Beta to agree to new terms and install additional tools, or run $ sudo xcodebuild -license to 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 (-I or --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).

running

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.

refresh

Now in your Run Configurations you can (must) select 8.0 for the iOS SDK and Simulator Version:

Screen Shot 2014-06-03 at 10.58.49

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 :)

App imagineer: Imagining, Engineering & Speaking about Native mobile Apps with Appcelerator Titanium & Alloy • Meetup organizer • Certified Expert • Titan


Comments

  • Alexey

    Thanks a bunch!

  • heedoo

    Thank brave man!

  • Rainer Schleevoigt

    Hi Fooke,

    awseome article and I tried to install the new xcode from apple. Following you link I logged in successful – but apple show me an “Access Denied”. I have a individual developer licence. I think it is enough.

  • jayesh

    build/iphone/

    Above path where . xcodeproj remain shows empty
    Below is log .

    Alloy compiled in 4.32175s
    [INFO] : Alloy compiler completed successfully
    [INFO] : Initiating Xcode pre-compile phase
    [INFO] : Processing JavaScript files
    [INFO] : Compiling localization files
    [INFO] : Checking for Splash Screen localization
    [INFO] : Skipping xcodebuild
    [INFO] : Finished building the application in 6s 433ms
    [INFO] : Running application in iOS Simulator
    [INFO] : Launching application in iOS Simulator
    [INFO] : Focusing the iOS Simulator
    [ERROR] : Project failed to build after 6s 786ms

  • patrick

    Thanks a lot!

  • Jeff

    Ignore the link, just log into https://developer.apple.com/devcenter/ios with your account.

  • sirhcle

    thank you!!! you saved my life!!

  • Aaron

    Thanks for putting this together. Very helpful.

  • Chetan

    Hi Fokke,

    Really nice article.
    I would like to discuss one problem with you. I was working with SDK 3.3.0 and xcode5.1 on mavericks. Everything was working fine. Today morning i received update for xcode5.1 to xcode 6.
    And i have installed it. Now my apps give same response as you mentioned above. The titanium Studio & sdk not properly communicating with new xcode 6.

    Now
    Can you suggest me some patch to get it worked for now.???? till the time it gets fixed in new titanium update.
    So i can continue my work.

    I tried to download the 7.1 simulator and that too failed.

    Your reply is highly appreciable.


    Thanks
    Chetan

  • Amar

    Hi Fokke,
    I am also facing same issues mentioned by Chetan. Please suggest something.

    Thanks,
    Amar

  • ajit

    Hi Fokke,

    Its good to always read your blogs on different Ti related stuffs.
    Anyway is it possible to run iOS simulator 7.1 on iOS SD 8.2 Titanium 3.5.1 ?

    Accepted values:
    8.2
    [ERROR] : Invalid “–sim-version” value “7.1”
    For help, run: titanium help build

  • Fokke Zandbergen Post author

    @ajit, under Xcode > Preferences > Downloads you can download the 7.1 Simulator.

  • Rich

    Fokke, re: the above exchange, I am in the same situation. I have already downloaded the 7.1 simulator, it appears as an option within the simulator, as well as in Device Profile in TiStudio Run Configurations menu. However, I always get the same error as @ajit. In Run Configurations, the only option in the Simulator Version menu is 8.2. I’ve spent hours on this and am really frustrated.

  • fokkezb

    @Rich I can reproduce part of this. That is, in CLI when I use “ti build -p ios -I 7.1” it indeed says I only have 8.3 (my latest). But I do see and can select the simulators directly via “ti build -p ios -C ?”

    I’ll create a ticket.