How to try the Titanium Windows Platform Preview (for free)

Appcelerator recently presented a preview of Titanium for Windows (native), based on the new Titanium core HAL that will power Titanium 4.x or Ti.Next.

Like iOS apps, Windows apps can only be build on a Windows PC. Most Titanium developers use a Mac since Android apps can be build on both platforms.

This how to aims to give a simple, minimal recipe to give the preview a try on a Mac with minimal hassle and budget. The official, longer guide can be found in the Appcelerator Docs. If you have information to improve this guide, please leave a comment.

Requirements

You need a Mac with a i3 processor or higher (which have the required Intel VT-x and SLAT) and at least 4GB of memory (of which the VM will take half). And since installing Visual Studio will take a while, you also need… time.

From Zero to Windows App

  1. Install the free 14-day trail of Parallels.
  2. Install the free Windows 10 Technical Preview Virtual Machine via the Parallels setup.
    • If you have a license, it’s recommended to use Windows 8.1 Pro x64.
    • Windows 8.0 or other versions then Pro x64 are said not to work.
    • Change the VM’s memory to 2048+ MB and select Enable nested virtualization for the Windows Phone OS Emulator to work:

      VM settings Parallels

  3. Install the free Visual Studio Community 2013 with Update 4.

    • The Express versions don’t work due to a cmake bug.
    • In setup only select Windows Phone SDK from the optional features.
    • You don’t need to sign in when you first start Visual Studio.
  4. Install Node.js
    • Restart so npm is in the system path.
  5. Install Git.
    • In the setup change the selection to Use Git from the Windows Command Prompt.
  6. Find PowerShell via the Start screen or Apps view and right-lick to Run as administrator.
    1. Fix a NodeJS for Windows bug if needed:
      > npm
      Error: ENOENT, stat 'C:\Users\fokkezb\AppData\Roaming\npm'
      > mkdir C:\Users\fokkezb\AppData\Roaming\npm
      > npm
      
    2. Install the (3.5.0+) Titanium CLI from master:
      > npm i -g git://github.com/appcelerator/titanium.git#master
      
    3. Install the (3.6.0+) Titanium SDK from master and set it as default:
      > ti sdk install -b master -d
      

      If extracting the SDK hangs, just abort, download the ZIP from the URL displayed and extract it to C:\ProgramData\Titanium, overwriting what’s there.

    4. Fix permissions for the CLI:

      > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
      
  7. Create an app:
    > ti create -t app -p windows -n hello --id tidev.hello -u http://tidev.io -d .
    
  8. Run the app:
    >  ti build -p windows -G 00000000-0000-1000-8000-000000000000 -C 8-1-1
    

    Windows App

That’s it! It is only a preview so many of the Titanium elements are not working, but at least you can see how things will be held together while development of the Windows Mobile platform continues on Appcelerator.

Using a device

To build to an actual Windows Phone follow these additional steps:

  1. Connect the phone and make sure the screen and remains unlocked.
  2. In Windows, go to Start > All Apps > Windows Phone SDK 8.1 > Windows Phone Developer Registration.
  3. Follow the steps to register your phone.
  4. In PowerShell build the app to your phone while making sure it is and remains unlocked:
    > ti build -p windows -G 00000000-0000-1000-8000-000000000000 -T wp-device
    

Available APIs

There’s no documentation yet about which API’s are available. Until there is, explore the Ti. namespaces as shown in the next code fragment. This will tell you ScrollView, View, ImageView, AlertDialog, Window, Slider, TabGroup, Tab, TextField, Button and Label are available in the Ti.UI. namespace.

    var win = Titanium.UI.createWindow({
        backgroundColor: '#fff'
    });

    win.add(Ti.UI.createLabel({
        color: '#000',
        text: (function() {
            var text = '';

            for (var key in Ti.UI) {
                if (key.substr(0, 6) === 'create') {
                    text += key + '\n';
                }
            }

            return text;
        })()
    }));

    win.open();

Feedback

If you have questions, please ask in the public Titanium Contributors Flowdock room. For bugs, please file them in JIRA. For additions to this guide, please leave a comment.

Thanks

Special thanks to Jeff Bonnes, Ingo Muschenetz, Christopher Williams and Shannon Hicks.

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


Comments

  • patrick

    thank you for the tutorial. Example app from above also works with VMware V7.1.0 and Windows 8.1 Enterprise Evaluation – although I ran into the ‘one of the Hyper-V components is not running’ exception. I had to add the following lines to the VMWare configfile as stated in http://docs.appcelerator.com/titanium/3.0/#!/guide/Getting_Started_with_the_Windows_Phone_SDK-section-37538371_GettingStartedwiththeWindowsPhoneSDK-RunningWindows8withVMWare

    hypervisor.cpuid.v0 = “FALSE”
    mce.enable = “TRUE”

    cheers
    patrick

  • Siwei

    Really great news! Hoping Titanium SDK 4.0 release soon!

  • Hans

    Thank you for the tutorial! Everything worked well, except the command “Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser” which was not accepted by the terminal and in consequence the build also throwed an error. Can you help? Thank you!

  • Fokke Zandbergen Post author

    @Hans, in what way was is “not accepted”? What error did you see – if any?

  • Pierre vdev

    Any lead on this ?

    Titanium Command-Line Interface, CLI version 3.6.0-dev, Titanium SDK version 3.6.0.v20150203104834

    C:\Users\Pierre\AppData\Roaming\npm\node_modules\titanium\node_modules\longjohn\dist\longjohn.js:184
    e.stack;
    ^
    processImmediate [as _immediateCallback] (timers.js:358:17)

  • Pierre vdev

    Never mind I’ve done the whole setup again and it worked.
    (Now I understand what you mean by Visual Studio takes a while!)

  • Marc Bender

    PS C:\Users\marc_bender\bendertest> ti build -p windows -G 00000000-0000-1000-8000-000000000000 -C 8-1-1
    Titanium Command-Line Interface, CLI version 3.6.0-dev, Titanium SDK version 4.0.0.v20150213151526
    Copyright (c) 2012-2014, Appcelerator, Inc. All Rights Reserved.

    Please report bugs to http://jira.appcelerator.org/

    C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\longjohn\dist\longjohn.js:184
    e.stack;
    ^
    processImmediate [as _immediateCallback] (timers.js:358:17)

  • Marc Bender

    Any hints? I did install everything as described…

  • Fokke Zandbergen Post author

    @Marc, what is your Node version? The new stable one doesn’t play well with Titanium at the moment.

  • Fokke Zandbergen Post author

    @Marc, yep that’s the one. Should have been fixed by last nights build:
    https://jira.appcelerator.org/browse/TIMOB-18538?jql=text%20~%20%22node%200.12%22

  • Marc Bender

    ok, I will try it now with 0.10.36

  • Marc Bender

    PS C:\Users\marc_bender\bendertest> ti build -p windows -G 00000000-0000-1000-8000-000000000000 -C 8-1-1
    Titanium Command-Line Interface, CLI version 3.6.0-dev, Titanium SDK version 4.0.0.v20150213151526
    Copyright (c) 2012-2014, Appcelerator, Inc. All Rights Reserved.

    Please report bugs to http://jira.appcelerator.org/

    C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\longjohn\dist\longjohn.js:185
    throw e;
    ^
    Error: No Windows Phone emulators found
    at prompt (C:\ProgramData\Titanium\mobilesdk\win32\4.0.0.v20150213151526\windows\cli\commands\_build.js:296:11)
    at opt.prompt (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\lib\cli.js:725:11)
    at CLI. (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\lib\cli.js:979:9)
    at q.process (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.js:731:21)

    at processImmediate (timers.js:354:15)
    ———————————————
    at async.setImmediate (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.j
    s:96:15)
    at C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.js:696:21
    at Array.forEach (native)
    at _each (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.js:32:24)
    at _insert (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.js:681:11)
    at q.push (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.js:708:15)
    at C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\lib\cli.js:1066:9
    at Array.forEach (native)
    ———————————————
    at Object.run (C:\ProgramData\Titanium\mobilesdk\win32\4.0.0.v20150213151526\node_modules\node-appc\lib\subprocess.j
    s:59:8)
    at C:\ProgramData\Titanium\mobilesdk\win32\4.0.0.v20150213151526\node_modules\windowslib\lib\env.js:88:22
    at C:\ProgramData\Titanium\mobilesdk\win32\4.0.0.v20150213151526\node_modules\node-appc\lib\subprocess.js:129:3
    at exithandler (child_process.js:656:7)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:766:16)
    at ChildProcess._handle.onexit (child_process.js:833:5)

  • Marc Bender

    did I missed something?

  • Fokke Zandbergen Post author

    @Marc, no idea. Try a search on JIRA for similar exceptions and create a new ticket if you can’t find one.

  • Stefan Sgorzaly

    Same problem here. I don’t know whats wrong. :-(

  • Fokke Zandbergen Post author

    @Marc @Stefan could you try with “-C ?” instead of “-C 8-1-1”? It should then list all found emulators.

    Also see https://jira.appcelerator.org/browse/TIMOB-18303

  • Marc Bender

    will test that this evening….

  • Marc Bender

    Nope!

    PS C:\Users\marc_bender\hello> ti build -p windows -G 00000000-0000-1000-8000-000000000000 -C
    Titanium Command-Line Interface, CLI version 3.6.0-dev, Titanium SDK version 4.0.0.v20150213151526
    Copyright (c) 2012-2014, Appcelerator, Inc. All Rights Reserved.

    Please report bugs to http://jira.appcelerator.org/

    C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\longjohn\dist\longjohn.js:185
    throw e;
    ^
    Error: No Windows Phone emulators found
    at prompt (C:\ProgramData\Titanium\mobilesdk\win32\4.0.0.v20150213151526\windows\cli\commands\_build.js:296:11)
    at CLI. (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\lib\cli.js:979:9)
    at q.process (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.js:731:21)

    at processImmediate (timers.js:354:15)
    ———————————————
    at async.setImmediate (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.j
    s:96:15)
    at C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.js:696:21
    at Array.forEach (native)
    at _each (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.js:32:24)
    at _insert (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.js:681:11)
    at q.push (C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\node_modules\async\lib\async.js:708:15)
    at C:\Users\marc_bender\AppData\Roaming\npm\node_modules\titanium\lib\cli.js:1066:9
    at Array.forEach (native)
    ———————————————
    at Object.run (C:\ProgramData\Titanium\mobilesdk\win32\4.0.0.v20150213151526\node_modules\node-appc\lib\subprocess.j
    s:59:8)
    at C:\ProgramData\Titanium\mobilesdk\win32\4.0.0.v20150213151526\node_modules\windowslib\lib\env.js:88:22
    at C:\ProgramData\Titanium\mobilesdk\win32\4.0.0.v20150213151526\node_modules\node-appc\lib\subprocess.js:129:3
    at exithandler (child_process.js:656:7)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:766:16)
    at ChildProcess._handle.onexit (child_process.js:833:5)
    PS C:\Users\marc_bender\hello>

  • Fokke Zandbergen Post author

    @Marc, OK.. I think you should create a JIRA ticket ;)

  • Stefan Sgorzaly

    @Marc, try the following:

    Go to:
    C:\ProgramData\Titanium\mobilesdk\win32\4.0.0.v20150213151526\node_modules\windowslib\lib\wptool.js

    and set:
    var deviceListingRE = /^\s*(\d+)\s+([\w \.]+)/mg

    instead of:
    var deviceListingRE = /^\s*(\d+)\s+([\w \.]+)$/mg

  • ajitjati

    I see , ‘[ERROR] Failed to start emulator “8.1-1” [ERROR] The application is not installed ‘ :(((

  • Fokke Zandbergen Post author

    @ajitjati Did you perhaps use “-C 8.1-1” instead of “-C 8-1-1” ?

  • Fokke Zandbergen Post author

    @Marc, could you try Stefan’s fix and confirm if it’s working for you in this PR?

    https://github.com/appcelerator/windowslib/pull/11

    It would be even better if you could also show the result or “console.log(out)” one line later.

  • Marc Bender

    will do later…. at the moment my VM is on the portable HD….at home…

  • Stefan Sgorzaly

    Ok, I found out, that there one more error in wptool.js. This condition only works if the OS language is english:
    if (errmsg == ‘Error: The application is not installed.’) {

    In my case (OS language is german) the variable errmsg will be set to ‘Fehler: The application is not installed.’

    So I think the following condition will be much better:
    if (errmsg.indexOf(‘The application is not installed.’) != -1) {

  • Fokke Zandbergen Post author

    @Stefan, thank you. Fix is here: https://github.com/appcelerator/windowslib/pull/11

    @Marc, any luck yet?

  • Marc Bender

    After applied both patches it works, I can select emulators, it complies and trow an error:
    C:\ProgramData\Titanium\mobilesdk\win32\4.0.0.v20150213151526\node_modules\wrench\lib\wrench.js:2
    if (e.code !== ‘EEXIST’) throw e;
    ^
    Error: ENOENT, no such file or directory ‘C:\Users\marc_bender\hello\build\windows’
    at fs.mkdirSync (fs.js:654:18)

    After adding the missing directories by myself it also installs the app, but the app crashes….

    [ERROR] Failed to install app (code -2146233088)

  • Fokke Zandbergen Post author

    @Marc do you get that (first) error as well after deleting the build directory and then trying again? The issue might be caused by the earlier failing builds.

    For the other one see https://github.com/appcelerator/windowslib/issues/5

  • Marc Bender

    after a “Ti clean” it builds trough. But the install to the emulator fails somehow… The icon is visible in the emulator but on console I get this:
    [ERROR] Failed to install app (code -2146233088)

    Starting the app on emulator shows the Appcelerator splash, then it crashes…

  • Marc Bender

    should I update the SDK to the latest version?

  • fokkezb

    @marc, you can always try updating CLI and SDK from master

  • Kirti Sonawane

    @marc,hey i am facing same problem. Do you got any solution?