Archive for the 'Appcelerator Titanium' Category

Appcelerator Titanium :: Upgrading tiapp.xml to the newer format, and define custom Info.plist values

Friday, August 3rd, 2012

If you are using Appcelerator Titanium there was an interesting entry I noted in the version 2.1.0 changelog:

Support for custom Info.plist values in tiapp.xml. Many of the existing iOS-specific tiapp.xml values are deprecated in favor of the new values

There are two items of interest here:

  1. Many existing tiapp.xml values are now deprecated.
  2. I can now set custom key/value pairs in the tiapp.xml file and they will be inserted into the projects Info.plist automatically when the project is built. I no longer need to manually maintain a custom Info.plist file in my project to set key/values that Titanium did not officially support. Yay!

The problem is that there is no example of exactly what these entries should look like in a final working tiapp.xml file. A new project created in Titanium Studio still creates the tiapp.xml file using the older / deprecated format. Even the latest KitchenSink sample project, that has just majorly reworked for the 2.1.1 release, is still using the deprecated format.

Here is an example of a now deprecated style tiapp.xml file, which most developers are still using:

<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <id>com.appcelerator.helloWorld</id>
    <name>helloWorld</name>
    <version>1.0</version>
    <publisher>not specified</publisher>
    <url>not specified</url>
    <description>not specified</description>
    <copyright>not specified</copyright>
    <icon>appicon.png</icon>
    <persistent-wifi>false</persistent-wifi>
    <prerendered-icon>false</prerendered-icon>
    <statusbar-style>default</statusbar-style>
    <statusbar-hidden>false</statusbar-hidden>
    <fullscreen>false</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>true</analytics>
    <guid></guid>
    <iphone>
        <orientations device="iphone">
            <orientation>Ti.UI.PORTRAIT</orientation>
        </orientations>
        <orientations device="ipad">
            <orientation>Ti.UI.PORTRAIT</orientation>
            <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
            <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
            <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
        </orientations>
    </iphone>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
    </android>
    <modules>
    </modules>
</ti:app>

Note the following issues here:

  • The persistent-wifi section is deprecated in 2.1
  • The prerendered-icon section is deprecated in 2.1
  • The statusbar-style section is deprecated in 2.1
  • The statusbar-hidden section is deprecated in 2.1
  • The iphone section with the orientation settings is deprecated in 2.1

So what should this look like? And how do we set custom key/value entries to be included in the Info.plist?

Here is a working tiapp.xml file using the newer format:

<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <deployment-targets>
        <target device="mobileweb">false</target>
        <target device="iphone">true</target>
        <target device="ipad">true</target>
        <target device="android">true</target>
        <target device="blackberry">false</target>
    </deployment-targets>
    <sdk-version>2.1.1.GA</sdk-version>
    <id>com.imattsolutions.equipd</id>
    <name>Equipd Beta</name>
    <version>1.3.0</version>
    <publisher>iMatt Solutions</publisher>
    <url>http://www.imattsolutions.com</url>
    <description>Mobile App for Ministry and Bible Study</description>
    <copyright>2012 iMatt Solutions</copyright>
    <icon>Icon.png</icon>
    <fullscreen>false</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>false</analytics>
    <guid>0fcd52a3-02b0-4b6a-aed6-we234522sf</guid>
    <android xmlns:android="http://schemas.android.com/apk/res/android"/>
    <modules>
        <module platform="iphone" version="0.1.22">zipfile</module>
    </modules>
    <ios>
        <plist>
            <dict>
                <key>UIRequiresPersistentWiFi</key>
                    <false/>
                <key>UIPrerenderedIcon</key>
                    <true/>
                <key>UIStatusBarHidden</key>
                    <false/>
                <key>UIStatusBarStyle</key>
                    <string>UIStatusBarStyleBlackTranslucent</string>
                <key>UISupportedInterfaceOrientations</key>
                    <array>
                        <string>UIInterfaceOrientationPortrait</string>
                        <string>UIInterfaceOrientationPortraitUpsideDown</string>
                        <string>UIInterfaceOrientationLandscapeLeft</string>
                        <string>UIInterfaceOrientationLandscapeRight</string>
                    </array>
                <key>UIBackgroundModes</key>
                    <array>
                        <string>audio</string>
                    </array>
            </dict>
        </plist>
    </ios>
</ti:app>

Notice that all of the deprecated settings are now migrated to the new ios > plist > dict section, including an example of a custom key UIBackgroundModes that will be included in the generated Info.plist.

For a detailed description of all Info.plist keys, see the iOS Info.plist Key Reference on the iOS Developer Center.

You can read more about the specifics of the tiapp.xml file here.

I hope this helps developers convert their projects over to the new format – it certainly makes more sense long term to use this approach to setting custom key/value pairs in the Info.plist file that drives our projects.