1# Titanium {#titanium} 2 3The Nixpkgs repository contains facilities to deploy a variety of versions of 4the [Titanium SDK](https://www.appcelerator.com) versions, a cross-platform 5mobile app development framework using JavaScript as an implementation language, 6and includes a function abstraction making it possible to build Titanium 7applications for Android and iOS devices from source code. 8 9Not all Titanium features supported -- currently, it can only be used to build 10Android and iOS apps. 11 12## Building a Titanium app {#building-a-titanium-app} 13 14We can build a Titanium app from source for Android or iOS and for debugging or 15release purposes by invoking the `titaniumenv.buildApp {}` function: 16 17```nix 18titaniumenv.buildApp { 19 name = "myapp"; 20 src = ./myappsource; 21 22 preBuild = ""; 23 target = "android"; # or 'iphone' 24 tiVersion = "7.1.0.GA"; 25 release = true; 26 27 androidsdkArgs = { 28 platformVersions = [ "25" "26" ]; 29 }; 30 androidKeyStore = ./keystore; 31 androidKeyAlias = "myfirstapp"; 32 androidKeyStorePassword = "secret"; 33 34 xcodeBaseDir = "/Applications/Xcode.app"; 35 xcodewrapperArgs = { 36 version = "9.3"; 37 }; 38 iosMobileProvisioningProfile = ./myprovisioning.profile; 39 iosCertificateName = "My Company"; 40 iosCertificate = ./mycertificate.p12; 41 iosCertificatePassword = "secret"; 42 iosVersion = "11.3"; 43 iosBuildStore = false; 44 45 enableWirelessDistribution = true; 46 installURL = "/installipa.php"; 47} 48``` 49 50The `titaniumenv.buildApp {}` function takes the following parameters: 51 52* The `name` parameter refers to the name in the Nix store. 53* The `src` parameter refers to the source code location of the app that needs 54 to be built. 55* `preRebuild` contains optional build instructions that are carried out before 56 the build starts. 57* `target` indicates for which device the app must be built. Currently only 58 'android' and 'iphone' (for iOS) are supported. 59* `tiVersion` can be used to optionally override the requested Titanium version 60 in `tiapp.xml`. If not specified, it will use the version in `tiapp.xml`. 61* `release` should be set to true when building an app for submission to the 62 Google Playstore or Apple Appstore. Otherwise, it should be false. 63 64When the `target` has been set to `android`, we can configure the following 65parameters: 66 67* The `androidSdkArgs` parameter refers to an attribute set that propagates all 68 parameters to the `androidenv.composeAndroidPackages {}` function. This can 69 be used to install all relevant Android plugins that may be needed to perform 70 the Android build. If no parameters are given, it will deploy the platform 71 SDKs for API-levels 25 and 26 by default. 72 73When the `release` parameter has been set to true, you need to provide 74parameters to sign the app: 75 76* `androidKeyStore` is the path to the keystore file 77* `androidKeyAlias` is the key alias 78* `androidKeyStorePassword` refers to the password to open the keystore file. 79 80When the `target` has been set to `iphone`, we can configure the following 81parameters: 82 83* The `xcodeBaseDir` parameter refers to the location where Xcode has been 84 installed. When none value is given, the above value is the default. 85* The `xcodewrapperArgs` parameter passes arbitrary parameters to the 86 `xcodeenv.composeXcodeWrapper {}` function. This can, for example, be used 87 to adjust the default version of Xcode. 88 89When `release` has been set to true, you also need to provide the following 90parameters: 91 92* `iosMobileProvisioningProfile` refers to a mobile provisioning profile needed 93 for signing. 94* `iosCertificateName` refers to the company name in the P12 certificate. 95* `iosCertificate` refers to the path to the P12 file. 96* `iosCertificatePassword` contains the password to open the P12 file. 97* `iosVersion` refers to the iOS SDK version to use. It defaults to the latest 98 version. 99* `iosBuildStore` should be set to `true` when building for the Apple Appstore 100 submission. For enterprise or ad-hoc builds it should be set to `false`. 101 102When `enableWirelessDistribution` has been enabled, you must also provide the 103path of the PHP script (`installURL`) (that is included with the iOS build 104environment) to enable wireless ad-hoc installations. 105 106## Emulating or simulating the app {#emulating-or-simulating-the-app} 107 108It is also possible to simulate the correspond iOS simulator build by using 109`xcodeenv.simulateApp {}` and emulate an Android APK by using 110`androidenv.emulateApp {}`.