Appcelerator Blog

The Leading Resource for All Things Mobile

Extensions and Apple WatchKit Support

48 Flares 48 Flares ×

Earlier today, Apple announced their updated product line, and with it, the much anticipated Apple Watch. Amongst other things, you’ll be able to use this watch to receive notifications, answer phone calls and talk to Siri, as well as use it as a fitness activity tracker. If you missed the event, you can catch the recording at http://www.apple.com/live/2015-mar-event/.

With all these new hardware capabilities, comes new developer opportunities, and you guessed it, we have updated our SDK for extensions support. Here’s how you can start building today.

Extensions support

The Extensions and WatchKit support was been broken down into two phases:

  1. Support including and shipping Extensions and WatchKit (built natively in Xcode) in Titanium apps
  2. Support building Extensions and WatchKit apps using the Titanium APIs.

The first stage is currently in beta and ready to be tested.

Getting Started

Note: The following steps are intended to show how to include natively-built extensions in Titanium and not how to create or build native extensions.

  1. Download the latest Titanium SDK build from the 3_5_X branch.

  2. Create an extension in Xcode.

  3. In the tiapp.xml of your Titanium app, add an extensions tag (next to the modules tag).

  4. In the extensions tag, add an extension tag.

  5. Add an attribute named projectPath to the extension tag. The value of the attribute should be the path to the folder containing the Xcode project with your extension.

  6. The content of the extension tag should be the target name of the the extension in the Xcode project.

  7. 
    
        TestToday
    
    
  8. Build your Titanium application like normal for simulator or device. Once the extensions tag is added to the tiapp.xml with an extension as its target, the Titanium app will build the extension and include it in the resulting app.

New APIs

A number of new APIs have been added to the Titanium SDK to facilitate communications with extensions. These APIs allow Titanium apps to share data using App Groups.

  • Ti.App.iOS.UserDefaults: (Object) Essentially the same as Ti.App.Properties, but it does not read from the tiapp.xml and requires its create method to be called with a suiteName to get an instance.
  • Ti.Filesystem.directoryForSuite: (Method) Takes a suiteName as a string and returns the path to that suite’s shared directory
  • Ti.Database.open/install: Now accept a complete path to the database.

For more information checkout TIMOB-18337.

48 Flares Twitter 0 Facebook 0 Google+ 7 LinkedIn 41 Email -- 48 Flares ×

8 Comments

  1. How do we get into the Beta Program? I am ready to start deploying to Apple Watch.

    Tony

  2. Brian McBride

    First, great work. I love the quick support of new features!

    I’d like to ask where the Android love is though. It’s been a few months and still no material design support. And it would be great to see Android Wear to match watchkit.

    Again, LOVE the new features. As a Titanium developer, I need to make that other side of the coin sparkle!

  3. Martijn

    I have created an empty Xcode project and added a new WatchApp target to it. Edited the tiapp.xml as explained and tried to run my app.
    Nothing but the error below, what am I doing wrong?

    Do I need to set the bundle id so something else? Provisioning? Signing? Help!

    MyAppWatch

    [ERROR] : ** BUILD FAILED **
    [ERROR] : The following build commands failed:
    [ERROR] : ValidateEmbeddedBinary build/Debug-iphonesimulator/MyApp.app/PlugIns/MyAppWatchKit.appex
    [ERROR] : (1 failure)

  4. Martijn

    The bundle id you give youur WatchApp target must start with the application id of your Titanium App. So if you have set “nl.martijn.myapp” in your Titanium project/tiapp.xml, than you must use “nl.martijn.myapp” as your organization identifier when creating the watchapp target in Xcode.
    If you forget you will get an ugly and not understandable build error…

  5. Hello,
    it’s possible provide some real world examples, by chance?

  6. Keith Tucci

    Is there an ETA for stage 2 (via Ti API)…?

  7. Sebastian Klaus

    How to interact between Titanium and a Today Extension?

Comments are closed.

Sign up for updates!

Become a mobile leader. Take the first step to scale mobile innovation throughout your enterprise.
Get in touch
computer and tablet showing Appcelerator software
Start free, grow from there.
48 Flares Twitter 0 Facebook 0 Google+ 7 LinkedIn 41 Email -- 48 Flares ×