TiShadow for Titanium Development - Part 3

In Part 2 of this series on TiShadow, we covered the basic usage of TiShadow for accelerated Titanium development. In this post we will dig somewhat further into the usage of TiShadow to support native modules and appified apps.

Customizing TiShadow app with Additional Native Modules

In the last post we learned how to build the TiShadow app which runs on connected devices, simulators and emulators, with it’s default native plugins, permissions and features.

This will work fine unless the application uses additional native modules. If you attempt to run an application bundle that requires a native module that is not supported by the TiShadow app you will get a runtime error similar to the one shown here:

native_err

To see this, you can extend the ShadowTest app by adding the Titanium canvas module to the project (install the module under ShadowTest/modules and add the module reference in tiapp.xml). Then add some code in the index.js controller to instantiate a canvas view, add the canvas view to View 1 below the buttons which were added in Part 2 and then draw some lines and curves onto the canvas.  Attempting to build and deploy the modified ShadowTest application bundle to the TiShadow app will yield the error shown above.

native_canvasThis is easily corrected by ensuring that all native modules that your application requires are also built into the TiShadow app.

Follow the same process as with ShadowTest to add the Titanium canvas module to the TiShadow app and then build and deploy that in the normal manner to the target device/simulator/emulator. Start the updated TiShadow app and connect to the TiShadow server. You can now use TiShadow to build and deploy the ShadowTest application bundle to the TiShadow app and see the bundle running as expected and matching the image shown on the right.

Creating and Using an Appified App

An appified app is the standard TiShadow app with the addition of an embedded application bundle to launch and a designated TiShadow server to connect with upon startup.

Here is another place where TiShadow helps accelerate the development process. As a developer you simply launch an appified app and it will immediately start running it’s embedded application bundle and connect to the TiShadow server. It really gets interesting when the TiShadow server has been launched in managed versions mode so that when the appified app connects it will automatically get and execute the latest version of the application bundle cached on the server.

Another situation where this capability shines is when you use it as part of your application’s beta test program. You deliver an initial version of your application beta as an appified app through the traditional distribution channels (e.g. TestFlight) and then you can push out updates at will to the beta test program TiShadow server.  Whenever a beta tester runs the appified app it will receive the latest version of the application bundle from the server.

Because an appified app is connected with the TiShadow server, you also have the ability to interact with the application in real-time.  You can send code snippets, inspect and modify application objects on the fly using spies, and run Jasmine tests. These will be covered in some detail in a later post.

Creating the Appified App

To create an appified app you should start out in the top directory of a Titanium project (e.g. ShadowTest). You need to create a directory where the appified app will be placed. You should also decide what TiShadow server and room (optional) you want the appified app to connect with on startup. The format of the command to create the appified app is tishadow appify -d -o -p -r . For this example we will create the appified app in ShadowTest/Appified using the default host, port and no room: *tishadow appify -d Appified*.

The appified app should now have been created in the ShadowTest/Appified directory. You can now build and deploy this Titanium app using the standard methods to your target devices, simulators and/or emulators.

Using the Appified App

Having deployed the appified app to the target device/simulator/emulator, the application can be started and should immediately launch the embedded application bundle and connect to the configured TiShadow server.

At this point you can interact with the TiShadow appified app in the same way as when you used TiShadow to build and deploy to the standard TiShadow app. You can update your application, run alloy compile (if necessary) and then use tishadow to build and deploy the updated application bundle to the target. One difference is that any deployments to the appified app are retained. The next time the appified app is started the last deployed application bundle is run – Nice.

It was previously mentioned that the TiShadow server caches application bundles when started in managed versions mode (e.g. tishadow server –manage-versions). We can use this to decouple deployment of new versions of application bundles to the server from their push to the appified app on the targets. You deploy using tishadow deploy, assuming that the default configuration is correct, otherwise use tishadow deploy -o -p -r . The next time the appified app is started it will connect to the configured TiShadow server and will be pushed the latest version of the application bundle.

We will explore more advanced interactions with appified apps in future posts.

Summary

In this post we further explored the use of TiShadow including customization of the TiShadow app to support applications using native modules and creating/using TiShadow appified apps.

Resources

joliva

0

Subscribe to Oliva Labs Blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!