@maccesar/titools 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS-TEMPLATE.md +173 -0
- package/README.md +867 -0
- package/agents/ti-researcher.md +108 -0
- package/bin/titools.js +53 -0
- package/lib/commands/agents.js +126 -0
- package/lib/commands/install.js +188 -0
- package/lib/commands/uninstall.js +215 -0
- package/lib/commands/update.js +159 -0
- package/lib/config.js +119 -0
- package/lib/downloader.js +153 -0
- package/lib/installer.js +253 -0
- package/lib/platform.js +108 -0
- package/lib/symlink.js +142 -0
- package/lib/utils.js +270 -0
- package/package.json +67 -0
- package/skills/alloy-expert/SKILL.md +247 -0
- package/skills/alloy-expert/assets/ControllerAutoCleanup.js +182 -0
- package/skills/alloy-expert/references/alloy-structure.md +381 -0
- package/skills/alloy-expert/references/anti-patterns.md +133 -0
- package/skills/alloy-expert/references/code-conventions.md +469 -0
- package/skills/alloy-expert/references/contracts.md +280 -0
- package/skills/alloy-expert/references/controller-patterns.md +520 -0
- package/skills/alloy-expert/references/error-handling.md +484 -0
- package/skills/alloy-expert/references/examples.md +735 -0
- package/skills/alloy-expert/references/migration-patterns.md +298 -0
- package/skills/alloy-expert/references/patterns.md +448 -0
- package/skills/alloy-expert/references/performance-patterns.md +855 -0
- package/skills/alloy-expert/references/security-patterns.md +847 -0
- package/skills/alloy-expert/references/state-management.md +779 -0
- package/skills/alloy-expert/references/testing.md +872 -0
- package/skills/alloy-guides/SKILL.md +214 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +243 -0
- package/skills/alloy-guides/references/CONCEPTS.md +191 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +298 -0
- package/skills/alloy-guides/references/MODELS.md +1028 -0
- package/skills/alloy-guides/references/PURGETSS.md +56 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +242 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +388 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +109 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +558 -0
- package/skills/alloy-guides/references/WIDGETS.md +176 -0
- package/skills/alloy-howtos/SKILL.md +203 -0
- package/skills/alloy-howtos/references/best_practices.md +138 -0
- package/skills/alloy-howtos/references/cli_reference.md +253 -0
- package/skills/alloy-howtos/references/config_files.md +87 -0
- package/skills/alloy-howtos/references/custom_tags.md +147 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +101 -0
- package/skills/alloy-howtos/references/samples.md +167 -0
- package/skills/purgetss/SKILL.md +442 -0
- package/skills/purgetss/assets/purgetss.config.cjs +17 -0
- package/skills/purgetss/references/EXAMPLES.md +247 -0
- package/skills/purgetss/references/animation-system.md +1294 -0
- package/skills/purgetss/references/apply-directive.md +375 -0
- package/skills/purgetss/references/arbitrary-values.md +612 -0
- package/skills/purgetss/references/class-index.md +1350 -0
- package/skills/purgetss/references/cli-commands.md +948 -0
- package/skills/purgetss/references/configurable-properties.md +654 -0
- package/skills/purgetss/references/custom-rules.md +161 -0
- package/skills/purgetss/references/customization-deep-dive.md +722 -0
- package/skills/purgetss/references/dynamic-component-creation.md +489 -0
- package/skills/purgetss/references/grid-layout.md +455 -0
- package/skills/purgetss/references/icon-fonts.md +609 -0
- package/skills/purgetss/references/installation-setup.md +366 -0
- package/skills/purgetss/references/opacity-modifier.md +291 -0
- package/skills/purgetss/references/platform-modifiers.md +479 -0
- package/skills/purgetss/references/smart-mappings.md +42 -0
- package/skills/purgetss/references/titanium-resets.md +359 -0
- package/skills/purgetss/references/ui-ux-design.md +1526 -0
- package/skills/ti-guides/SKILL.md +94 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +19 -0
- package/skills/ti-guides/references/alloy-cli-advanced.md +84 -0
- package/skills/ti-guides/references/alloy-data-mastery.md +29 -0
- package/skills/ti-guides/references/alloy-widgets-and-themes.md +19 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +258 -0
- package/skills/ti-guides/references/application-frameworks.md +377 -0
- package/skills/ti-guides/references/cli-reference.md +402 -0
- package/skills/ti-guides/references/coding-best-practices.md +102 -0
- package/skills/ti-guides/references/commonjs-advanced.md +134 -0
- package/skills/ti-guides/references/hello-world.md +100 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +62 -0
- package/skills/ti-guides/references/javascript-primer.md +411 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +183 -0
- package/skills/ti-guides/references/style-and-conventions.md +48 -0
- package/skills/ti-guides/references/tiapp-config.md +609 -0
- package/skills/ti-howtos/SKILL.md +174 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +658 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +95 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +140 -0
- package/skills/ti-howtos/references/cross-platform-development.md +348 -0
- package/skills/ti-howtos/references/debugging-profiling.md +543 -0
- package/skills/ti-howtos/references/extending-titanium.md +723 -0
- package/skills/ti-howtos/references/google-maps-v2.md +169 -0
- package/skills/ti-howtos/references/ios-map-kit.md +143 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +783 -0
- package/skills/ti-howtos/references/local-data-sources.md +301 -0
- package/skills/ti-howtos/references/location-and-maps.md +252 -0
- package/skills/ti-howtos/references/media-apis.md +210 -0
- package/skills/ti-howtos/references/notification-services.md +599 -0
- package/skills/ti-howtos/references/remote-data-sources.md +349 -0
- package/skills/ti-howtos/references/tutorials.md +502 -0
- package/skills/ti-howtos/references/using-modules.md +237 -0
- package/skills/ti-howtos/references/web-content-integration.md +307 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +78 -0
- package/skills/ti-ui/SKILL.md +179 -0
- package/skills/ti-ui/references/accessibility-deep-dive.md +242 -0
- package/skills/ti-ui/references/animation-and-matrices.md +599 -0
- package/skills/ti-ui/references/application-structures.md +655 -0
- package/skills/ti-ui/references/custom-fonts-styling.md +579 -0
- package/skills/ti-ui/references/event-handling.md +393 -0
- package/skills/ti-ui/references/gestures.md +473 -0
- package/skills/ti-ui/references/icons-and-splash-screens.md +409 -0
- package/skills/ti-ui/references/layouts-and-positioning.md +462 -0
- package/skills/ti-ui/references/listviews-and-performance.md +619 -0
- package/skills/ti-ui/references/orientation.md +362 -0
- package/skills/ti-ui/references/platform-ui-android.md +635 -0
- package/skills/ti-ui/references/platform-ui-ios.md +469 -0
- package/skills/ti-ui/references/scrolling-views.md +252 -0
- package/skills/ti-ui/references/tableviews.md +568 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
# Titanium CLI Reference
|
|
2
|
+
|
|
3
|
+
Complete reference for Titanium CLI commands, options, and configuration.
|
|
4
|
+
|
|
5
|
+
## Environment Setup
|
|
6
|
+
|
|
7
|
+
### Check Environment
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ti setup check
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Reports configured tools and potential issues.
|
|
14
|
+
|
|
15
|
+
### Get System Info
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
ti info
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Detailed environment info (SDKs, certificates, provisioning profiles).
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ti info -p android # Android-specific info
|
|
25
|
+
ti info -p ios # iOS-specific info
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Configure CLI
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Display current config
|
|
32
|
+
ti config
|
|
33
|
+
|
|
34
|
+
# Set option
|
|
35
|
+
ti config cli.logLevel info
|
|
36
|
+
|
|
37
|
+
# Append to path
|
|
38
|
+
ti config -a paths.hooks "/path/to/hook"
|
|
39
|
+
|
|
40
|
+
# Remove all Android options
|
|
41
|
+
ti config -r android
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Alternative methods:**
|
|
45
|
+
```bash
|
|
46
|
+
# Pass JSON string
|
|
47
|
+
ti build -p ios --config "{ paths: { hooks: '/path/to/hook' } }"
|
|
48
|
+
|
|
49
|
+
# Pass JSON file
|
|
50
|
+
ti build -p ios --config-file "/Users/me/customConfig.json"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Project Commands
|
|
56
|
+
|
|
57
|
+
### Create Project
|
|
58
|
+
|
|
59
|
+
**For Alloy projects (recommended):**
|
|
60
|
+
```bash
|
|
61
|
+
ti create -t app --alloy --id <APP_ID> -n <APP_NAME> -p <PLATFORMS> -d <WORKSPACE> -u <URL>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Example (Alloy):**
|
|
65
|
+
```bash
|
|
66
|
+
ti create -t app --alloy --id com.titaniumsdk.sample -n SampleProject -p android,ios -d ~/Documents/workspace -u https://titaniumsdk.com
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**For Classic Titanium projects:**
|
|
70
|
+
```bash
|
|
71
|
+
ti create -t app --id <APP_ID> -n <APP_NAME> -p <PLATFORMS> -d <WORKSPACE> -u <URL>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Parameters:**
|
|
75
|
+
- `--alloy`: Create an Alloy project (recommended for new projects)
|
|
76
|
+
- `-t, --type`: Project type (`app`)
|
|
77
|
+
- `--id`: App ID (reverse domain notation)
|
|
78
|
+
- `-n, --name`: App name
|
|
79
|
+
- `-p, --platforms`: Comma-separated platforms (`android`, `ios`, `ipad`, `iphone`)
|
|
80
|
+
- `-d, --dir`: Workspace directory
|
|
81
|
+
- `-u, --url`: App URL
|
|
82
|
+
|
|
83
|
+
> **Note:** Always use the `--alloy` flag when creating new projects. The Alloy framework provides MVC structure, data binding, and modern development patterns. Use Classic (`--classic` or omitting `--alloy`) only when maintaining legacy projects.
|
|
84
|
+
|
|
85
|
+
### Build Project
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
ti build -p <PLATFORM> [OPTIONS]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Build Commands
|
|
94
|
+
|
|
95
|
+
### Android Emulator
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
ti build -p android [-C <EMULATOR_NAME>]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Example:**
|
|
102
|
+
```bash
|
|
103
|
+
ti build -p android -C "Google Nexus 7 - 4.4.2 - API 19 - 800x1280"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
List emulators: `ti info -p android`
|
|
107
|
+
|
|
108
|
+
### Android Device
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
ti build -p android -T device -C <DEVICE_ID>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Example:**
|
|
115
|
+
```bash
|
|
116
|
+
ti build -p android -T device -C deadbeef
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Omit `-C` if only one device connected.
|
|
120
|
+
|
|
121
|
+
### iOS Simulator
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
ti build -p ios [-C <SIMULATOR_NAME>]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Example:**
|
|
128
|
+
```bash
|
|
129
|
+
ti build -p ios -C "iPad Retina"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### iOS Device
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
ti build -p ios -T device -C <DEVICE_UDID> [-V "<CERT_NAME>" -P <PROFILE_UUID>]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Example:**
|
|
139
|
+
```bash
|
|
140
|
+
ti build -p ios -T device -C itunes -V "Loretta Martin (GE7BAC5)" -P "11111111-2222-3333-4444-555555555555"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Omit `-V` and `-P` to be prompted.
|
|
144
|
+
|
|
145
|
+
### Clean Build
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
ti clean [-p <PLATFORM>]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Examples:**
|
|
152
|
+
```bash
|
|
153
|
+
ti clean # All platforms
|
|
154
|
+
ti clean -p ios # iOS only
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Module Management
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
ti module [TASK] [OPTIONS]
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Tasks:**
|
|
164
|
+
- `create`: Create a new Titanium module.
|
|
165
|
+
|
|
166
|
+
### Project Management
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
ti project [TASK] [OPTIONS]
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Tasks:**
|
|
173
|
+
- `scan`: Scan directory for Titanium projects.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Distribution Commands
|
|
178
|
+
|
|
179
|
+
### Google Play (Android)
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
ti build -p android -T dist-playstore [-K <KEYSTORE> -P <PASSWORD> -L <ALIAS> -O <OUTPUT>]
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Example:**
|
|
186
|
+
```bash
|
|
187
|
+
ti build -p android -T dist-playstore -K ~/android.keystore -P secret -L foo -O ./dist/
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**If key password differs from keystore password:**
|
|
191
|
+
```bash
|
|
192
|
+
--key-password <KEYPASS>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Ad Hoc (iOS)
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
ti build -p ios -T dist-adhoc [-R <CERT_NAME> -P <PROFILE_UUID> -O <OUTPUT>]
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Example:**
|
|
202
|
+
```bash
|
|
203
|
+
ti build -p ios -T dist-adhoc -R "Pseudo, Inc." -P "FFFFFFFF-EEEE-DDDD-CCCC-BBBBBBBBBBBB" -O ./dist/
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### App Store (iOS)
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
ti build -p ios -T dist-appstore [-R <CERT_NAME> -P <PROFILE_UUID>]
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Example:**
|
|
213
|
+
```bash
|
|
214
|
+
ti build -p ios -T dist-appstore -R "Pseudo, Inc." -P "AAAAAAAA-0000-9999-8888-777777777777"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Installs package to Xcode Organizer.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## SDK Management
|
|
222
|
+
|
|
223
|
+
### List SDKs
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
ti sdk list
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Select SDK
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
ti sdk select
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Interactive selection of default SDK.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Configuration Options
|
|
240
|
+
|
|
241
|
+
### Android Options
|
|
242
|
+
|
|
243
|
+
| Option | Default | Description |
|
|
244
|
+
| ------------------------------------ | ----------- | -------------------------------- |
|
|
245
|
+
| `android.sdkPath` | auto | Android SDK path |
|
|
246
|
+
| `android.ndkPath` | auto | Android NDK path |
|
|
247
|
+
| `android.adb.port` | 5037 | ADB port number |
|
|
248
|
+
| `android.autoSelectDevice` | true | Auto-select device/emulator |
|
|
249
|
+
| `android.symlinkResources` | true (OS X) | Symlink vs copy resources |
|
|
250
|
+
| `android.buildTools.selectedVersion` | max | Build tools version |
|
|
251
|
+
| `android.javac.maxmemory` | "1024M" | JVM heap size |
|
|
252
|
+
| `android.javac.source` | "1.6" | Java source version |
|
|
253
|
+
| `android.javac.target` | "1.6" | Java target version |
|
|
254
|
+
| `android.mergeCustomAndroidManifest` | false | Merge custom AndroidManifest.xml |
|
|
255
|
+
|
|
256
|
+
### iOS Options
|
|
257
|
+
|
|
258
|
+
| Option | Default | Description |
|
|
259
|
+
| ---------------------- | ----------- | ------------------------------------- |
|
|
260
|
+
| `ios.developerName` | - | Developer certificate name |
|
|
261
|
+
| `ios.distributionName` | - | Distribution certificate name |
|
|
262
|
+
| `ios.autoSelectDevice` | true | Auto-select device/simulator |
|
|
263
|
+
| `ios.symlinkResources` | true (OS X) | Symlink vs copy resources |
|
|
264
|
+
| `ios.keychain` | - | Specific keychain to search for certs |
|
|
265
|
+
| `ios.xcodePath` | auto | Path to Xcode installation |
|
|
266
|
+
|
|
267
|
+
### CLI Options
|
|
268
|
+
|
|
269
|
+
| Option | Default | Description |
|
|
270
|
+
| ------------------------ | ------- | --------------------------------------------- |
|
|
271
|
+
| `cli.logLevel` | trace | Log level: error, warning, info, debug, trace |
|
|
272
|
+
| `cli.colors` | true | Color output |
|
|
273
|
+
| `cli.progressBars` | true | Show progress bars |
|
|
274
|
+
| `cli.prompt` | true | Prompt for missing info |
|
|
275
|
+
| `cli.quiet` | false | Suppress all output |
|
|
276
|
+
| `cli.rejectUnauthorized` | true | Reject bad SSL certs |
|
|
277
|
+
| `cli.width` | 100 | Text wrap width |
|
|
278
|
+
| `cli.failOnWrongSDK` | false | Fail on SDK mismatch |
|
|
279
|
+
| `cli.hideCharEncWarning` | false | Hide encoding warnings |
|
|
280
|
+
| `cli.httpProxyServer` | - | Proxy server URL |
|
|
281
|
+
|
|
282
|
+
### SDK Options
|
|
283
|
+
|
|
284
|
+
| Option | Description |
|
|
285
|
+
| ---------------------------- | ---------------------------------- |
|
|
286
|
+
| `sdk.defaultInstallLocation` | SDK install location (OS-specific) |
|
|
287
|
+
| `sdk.selected` | Selected SDK version (REQUIRED) |
|
|
288
|
+
|
|
289
|
+
### Paths
|
|
290
|
+
|
|
291
|
+
| Option | Description |
|
|
292
|
+
| ---------------- | ------------------------------ |
|
|
293
|
+
| `paths.commands` | Additional CLI command scripts |
|
|
294
|
+
| `paths.hooks` | CLI hook scripts |
|
|
295
|
+
| `paths.modules` | Module search paths |
|
|
296
|
+
| `paths.plugins` | Plugin search paths |
|
|
297
|
+
| `paths.sdks` | SDK search paths |
|
|
298
|
+
| `paths.xcode` | Xcode installation paths |
|
|
299
|
+
|
|
300
|
+
### Java Options
|
|
301
|
+
|
|
302
|
+
| Option | Description |
|
|
303
|
+
| ---------------------------- | ------------------------- |
|
|
304
|
+
| `java.home` | JDK directory |
|
|
305
|
+
| `java.executables.java` | java executable path |
|
|
306
|
+
| `java.executables.javac` | javac executable path |
|
|
307
|
+
| `java.executables.jarsigner` | jarsigner executable path |
|
|
308
|
+
| `java.executables.keytool` | keytool executable path |
|
|
309
|
+
|
|
310
|
+
### Genymotion Options
|
|
311
|
+
|
|
312
|
+
| Option | Description |
|
|
313
|
+
| ----------------------------------- | ------------------------- |
|
|
314
|
+
| `genymotion.enabled` | Enable Genymotion support |
|
|
315
|
+
| `genymotion.path` | Genymotion app directory |
|
|
316
|
+
| `genymotion.executables.genymotion` | genymotion executable |
|
|
317
|
+
| `genymotion.executables.player` | player executable |
|
|
318
|
+
| `genymotion.executables.vboxmanage` | vboxmanage executable |
|
|
319
|
+
|
|
320
|
+
### Application Options
|
|
321
|
+
|
|
322
|
+
| Option | Description |
|
|
323
|
+
| --------------------------- | --------------------------- |
|
|
324
|
+
| `app.idprefix` | Prefix for new app IDs |
|
|
325
|
+
| `app.publisher` | Default publisher |
|
|
326
|
+
| `app.url` | Default company URL |
|
|
327
|
+
| `app.workspace` | Default workspace directory |
|
|
328
|
+
| `app.skipAppIdValidation` | Skip app ID validation |
|
|
329
|
+
| `app.skipVersionValidation` | Skip version validation |
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## Common Issues
|
|
334
|
+
|
|
335
|
+
### Android SDK Not Found
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
! sdk Android SDK not found
|
|
339
|
+
! targets no targets found
|
|
340
|
+
! avds no avds found
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**Solution:**
|
|
344
|
+
```bash
|
|
345
|
+
ti config android.sdkPath /path/to/android-sdk
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Xcode Too Old
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
! Xcode 4.3 is too old and is no longer supported by Titanium SDK 3.3.0
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
**Solution:** Install newer Xcode from Mac App Store.
|
|
355
|
+
|
|
356
|
+
### Clean Build Issues
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
ti clean -p ios
|
|
360
|
+
ti clean -p android
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### ADB Device Issues
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
adb kill-server
|
|
367
|
+
adb start-server
|
|
368
|
+
adb devices
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## Command Quick Reference
|
|
374
|
+
|
|
375
|
+
| Command | Description |
|
|
376
|
+
| ----------------------- | ----------------------- |
|
|
377
|
+
| `ti setup check` | Check environment setup |
|
|
378
|
+
| `ti info` | Display system info |
|
|
379
|
+
| `ti info -p <PLATFORM>` | Platform-specific info |
|
|
380
|
+
| `ti config` | Display/set config |
|
|
381
|
+
| `ti create` | Create new project |
|
|
382
|
+
| `ti build` | Build project |
|
|
383
|
+
| `ti clean` | Clean build folder |
|
|
384
|
+
| `ti sdk list` | List installed SDKs |
|
|
385
|
+
| `ti sdk select` | Select default SDK |
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## SDK Version Precedence
|
|
390
|
+
|
|
391
|
+
1. `tiapp.xml` `<sdk-version>` tag
|
|
392
|
+
2. `--sdk` CLI option
|
|
393
|
+
3. `app.sdk` config setting
|
|
394
|
+
4. Selected SDK (`ti sdk select`)
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## References
|
|
399
|
+
|
|
400
|
+
- [Titanium CLI GitHub](https://github.com/tidev/titanium-cli)
|
|
401
|
+
- [Android SDK Manager](http://developer.android.com/sdk)
|
|
402
|
+
- [Xcode Downloads](https://apps.apple.com/us/app/xcode/id497799835?mt=12/)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Coding Best Practices
|
|
2
|
+
|
|
3
|
+
## 1. Scope Management
|
|
4
|
+
- **Avoid Global Scope**: Global variables are not automatically garbage collected and can cause naming conflicts.
|
|
5
|
+
- **Always use `let` or `const`**: (Original guide says `var`, but modernization rules apply). Omitting declarations places variables in the global scope.
|
|
6
|
+
|
|
7
|
+
## 2. Memory Leak Prevention
|
|
8
|
+
- **Global Event Listeners**: Listeners on `Ti.App`, `Ti.Geolocation`, etc., will leak memory if they reference locally scoped objects unless explicitly removed.
|
|
9
|
+
```javascript
|
|
10
|
+
// ANTI-PATTERN
|
|
11
|
+
Ti.App.addEventListener('data:sync', (e) => {
|
|
12
|
+
localView.text = e.text // localView is now leaked
|
|
13
|
+
})
|
|
14
|
+
```
|
|
15
|
+
- **Rule**: Global events should only handle global objects. Always `removeEventListener` during cleanup.
|
|
16
|
+
|
|
17
|
+
## 3. Event Naming Conventions
|
|
18
|
+
- **No Spaces in Event Names**: Using spaces in custom event names causes issues with Backbone.js and other libraries that use spaces as delimiters.
|
|
19
|
+
```javascript
|
|
20
|
+
// ❌ WRONG - may fire multiple times
|
|
21
|
+
Ti.App.fireEvent('my event')
|
|
22
|
+
|
|
23
|
+
// ✅ CORRECT - use colon or underscore
|
|
24
|
+
Ti.App.fireEvent('my:event')
|
|
25
|
+
Ti.App.fireEvent('my_event')
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 4. Performance
|
|
29
|
+
- **Defer Script Loading**: Evaluate JavaScript only when needed. Don't `require` modules at startup if they are only for specific screens.
|
|
30
|
+
|
|
31
|
+
**Lazy script loading example:**
|
|
32
|
+
```javascript
|
|
33
|
+
// must be loaded at launch
|
|
34
|
+
const WindowOne = require('ui/WindowOne').WindowOne;
|
|
35
|
+
const win1 = new WindowOne();
|
|
36
|
+
win1.open();
|
|
37
|
+
|
|
38
|
+
win1.addEventListener('click', () => {
|
|
39
|
+
// load window two JavaScript only when needed
|
|
40
|
+
const WindowTwo = require('ui/WindowTwo').WindowTwo;
|
|
41
|
+
const win2 = new WindowTwo();
|
|
42
|
+
win2.open();
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- **Bridge Efficiency**: Minimize requests for device properties like `Ti.Platform.osname`. Store them in a local variable once.
|
|
47
|
+
- **Avoid Extending Ti Namespace**: Never add properties to `Ti.*` as it's a proxy system and leads to instability.
|
|
48
|
+
|
|
49
|
+
## 5. App Architecture Recommendations
|
|
50
|
+
|
|
51
|
+
### Modular Components with CommonJS (Recommended)
|
|
52
|
+
Titanium's primary recommended architecture. Discrete and independent building blocks that eliminate global variables.
|
|
53
|
+
|
|
54
|
+
**MyModule.js**
|
|
55
|
+
```javascript
|
|
56
|
+
// Private variable
|
|
57
|
+
const defaultMessage = "Hello world";
|
|
58
|
+
|
|
59
|
+
exports.sayHello = (msg) => {
|
|
60
|
+
Ti.API.info('Hello ' + msg);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
exports.helloWorld = () => {
|
|
64
|
+
Ti.API.info(defaultMessage);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**app.js**
|
|
69
|
+
```javascript
|
|
70
|
+
const myModule = require('/MyModule');
|
|
71
|
+
myModule.sayHello('User');
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Custom Objects as Components
|
|
75
|
+
Popular for rapid deployment. Uses a namespace hierarchy.
|
|
76
|
+
```javascript
|
|
77
|
+
const myapp = {};
|
|
78
|
+
(() => {
|
|
79
|
+
myapp.ui = {};
|
|
80
|
+
myapp.ui.createApplicationWindow = () => {
|
|
81
|
+
const win = Ti.UI.createWindow({ backgroundColor:'white' });
|
|
82
|
+
return win;
|
|
83
|
+
};
|
|
84
|
+
})();
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Classical-based Patterns
|
|
88
|
+
Not recommended as JavaScript is not a class-based language. It confuses classes and objects and is slower to implement in rapid prototyping.
|
|
89
|
+
|
|
90
|
+
## 6. Security Best Practices
|
|
91
|
+
- **No Sensitive Data in Non-JS Files**: JavaScript files are minified and obfuscated during build, but images, JSON files, SQLite databases, and other non-.js files are packaged as-is. APK and IPA files are essentially ZIP files that can be extracted.
|
|
92
|
+
```javascript
|
|
93
|
+
// ❌ WRONG - API keys visible in app/assets/config.json
|
|
94
|
+
const config = require('assets/config.json')
|
|
95
|
+
|
|
96
|
+
// ✅ CORRECT - Store in code or use secure storage
|
|
97
|
+
const API_KEY = Ti.App.Properties.getString('api_key')
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 7. Multiplatform Strategies
|
|
101
|
+
- **Code Branching**: Use for small differences.
|
|
102
|
+
- **Platform Files**: Use `.ios.js` or `.android.js` for major logic differences to keep code readable.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# CommonJS Advanced Patterns
|
|
2
|
+
|
|
3
|
+
## 1. Stateful Modules (Singleton Pattern)
|
|
4
|
+
|
|
5
|
+
Modules in Titanium are created once per JavaScript context and then passed by reference on subsequent `require()` calls. This makes them ideal for maintaining application state.
|
|
6
|
+
|
|
7
|
+
### Example: Stateful Counter Module
|
|
8
|
+
```javascript
|
|
9
|
+
// app/lib/counter.js
|
|
10
|
+
let _count = 0
|
|
11
|
+
|
|
12
|
+
exports.increment = () => {
|
|
13
|
+
_count++
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.getCount = () => {
|
|
17
|
+
return _count
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.reset = () => {
|
|
21
|
+
_count = 0
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Usage**: Multiple controllers requiring this module share the same `_count` state.
|
|
26
|
+
|
|
27
|
+
### Critical Note
|
|
28
|
+
A module is created once **per Titanium JavaScript context**. Additional contexts create new module instances.
|
|
29
|
+
|
|
30
|
+
## 2. Caching Behavior
|
|
31
|
+
|
|
32
|
+
Titanium caches the object returned by `require()` and provides the same reference without re-evaluating the code.
|
|
33
|
+
|
|
34
|
+
**Implication**: If you think you need code evaluated multiple times, create a module with a callable function instead.
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
// Good - factory pattern
|
|
38
|
+
exports.createView = (args) => {
|
|
39
|
+
return Ti.UI.createView(args)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Bad - expecting re-evaluation
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 3. ES6+ Support (SDK 7.1.0+)
|
|
46
|
+
|
|
47
|
+
Since Titanium SDK 7.1.0, you can use ES6+ module syntax. Code is transpiled to ES5 for all platforms.
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
// MyClass.js
|
|
51
|
+
export default class MyClass {
|
|
52
|
+
constructor(name) {
|
|
53
|
+
this.name = name
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
greet() {
|
|
57
|
+
return `Hello, ${this.name}`
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Usage in controller
|
|
62
|
+
import MyClass from 'MyClass'
|
|
63
|
+
const instance = new MyClass('World')
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## 4. Module Composition Patterns
|
|
67
|
+
|
|
68
|
+
### Exports Object Pattern
|
|
69
|
+
```javascript
|
|
70
|
+
exports.sayHello = (name) => {
|
|
71
|
+
Ti.API.info(`Hello ${name}`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
exports.version = 1.4
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Constructor Pattern (module.exports)
|
|
78
|
+
```javascript
|
|
79
|
+
class Person {
|
|
80
|
+
constructor(firstName, lastName) {
|
|
81
|
+
this.firstName = firstName
|
|
82
|
+
this.lastName = lastName
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
fullName() {
|
|
86
|
+
return `${this.firstName} ${this.lastName}`
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = Person
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 5. Antipatterns to Avoid
|
|
94
|
+
|
|
95
|
+
### Don't Assign Directly to exports
|
|
96
|
+
```javascript
|
|
97
|
+
// ❌ WRONG - won't work
|
|
98
|
+
function Person() {}
|
|
99
|
+
exports = Person
|
|
100
|
+
|
|
101
|
+
// ✅ CORRECT
|
|
102
|
+
module.exports = Person
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Don't Mix module.exports and exports.*
|
|
106
|
+
```javascript
|
|
107
|
+
// ❌ DISCOURAGED
|
|
108
|
+
module.exports = Person
|
|
109
|
+
exports.foo = 'bar'
|
|
110
|
+
|
|
111
|
+
// ✅ Use one consistently
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### No Global Variables Across Modules
|
|
115
|
+
Any data a module needs must be passed during construction or initialization. Never rely on globals shared across modules.
|
|
116
|
+
|
|
117
|
+
## 6. Security and Scope
|
|
118
|
+
|
|
119
|
+
All modules have private scope. Variables declared within the module are private unless added to `exports`.
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
const _privateVar = 'secret' // Not accessible outside
|
|
123
|
+
|
|
124
|
+
exports.publicMethod = () => {
|
|
125
|
+
// Can access _privateVar
|
|
126
|
+
return _privateVar
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 7. Node.js Compatibility
|
|
131
|
+
|
|
132
|
+
Titanium supports Node.js module patterns and `require()` resolution. Node.js modules can often be used directly.
|
|
133
|
+
|
|
134
|
+
For detailed Node.js support information, refer to the official Titanium Node.js guide.
|