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.
The Extensions and WatchKit support was been broken down into two phases:
- Support including and shipping Extensions and WatchKit (built natively in Xcode) in Titanium apps
- Support building Extensions and WatchKit apps using the Titanium APIs.
The first stage is currently in beta and ready to be tested.
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.
Download the latest Titanium SDK build from the 3_5_X branch.
Create an extension in Xcode.
tiapp.xmlof your Titanium app, add an extensions tag (next to the modules tag).
extensionstag, add an
Add an attribute named
extensiontag. The value of the attribute should be the path to the folder containing the Xcode project with your extension.
The content of the
extensiontag should be the target name of the the extension in the Xcode project.
- Build your Titanium application like normal for simulator or device. Once the extensions tag is added to the
tiapp.xmlwith an extension as its target, the Titanium app will build the extension and include it in the resulting app.
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.xmland requires its create method to be called with a
suiteNameto get an instance.
- Ti.Filesystem.directoryForSuite: (Method) Takes a
suiteNameas 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.