@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,543 @@
|
|
|
1
|
+
# Debugging and Profiling
|
|
2
|
+
|
|
3
|
+
Comprehensive guide for debugging Titanium apps, managing memory, finding leaks, and using native debugging tools.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Debugging and Profiling](#debugging-and-profiling)
|
|
8
|
+
- [Table of Contents](#table-of-contents)
|
|
9
|
+
- [Debugging Overview](#debugging-overview)
|
|
10
|
+
- [Essential Elements of Debugging](#essential-elements-of-debugging)
|
|
11
|
+
- [Debugging Techniques](#debugging-techniques)
|
|
12
|
+
- [Memory Management](#memory-management)
|
|
13
|
+
- [How JavaScript Manages Memory](#how-javascript-manages-memory)
|
|
14
|
+
- [How Titanium Manages Memory](#how-titanium-manages-memory)
|
|
15
|
+
- [Releasing Memory Properly](#releasing-memory-properly)
|
|
16
|
+
- [Parent-Child Relationships](#parent-child-relationships)
|
|
17
|
+
- [Platform Memory Limits](#platform-memory-limits)
|
|
18
|
+
- [Memory Leak Detection](#memory-leak-detection)
|
|
19
|
+
- [Common Leak Sources](#common-leak-sources)
|
|
20
|
+
- [Debugging Memory on iOS (Instruments)](#debugging-memory-on-ios-instruments)
|
|
21
|
+
- [Debugging Memory on Android (DDMS)](#debugging-memory-on-android-ddms)
|
|
22
|
+
- [Android Debugging Tools](#android-debugging-tools)
|
|
23
|
+
- [DDMS (Dalvik Debug Monitor Service)](#ddms-dalvik-debug-monitor-service)
|
|
24
|
+
- [Log Output with DDMS](#log-output-with-ddms)
|
|
25
|
+
- [Simulate Network Conditions](#simulate-network-conditions)
|
|
26
|
+
- [Simulate Calls/SMS](#simulate-callssms)
|
|
27
|
+
- [Set GPS Coordinates](#set-gps-coordinates)
|
|
28
|
+
- [File System Exploration](#file-system-exploration)
|
|
29
|
+
- [Memory Monitoring](#memory-monitoring)
|
|
30
|
+
- [ADB (Android Debug Bridge)](#adb-android-debug-bridge)
|
|
31
|
+
- [Log Output](#log-output)
|
|
32
|
+
- [File System](#file-system)
|
|
33
|
+
- [Transfer Files](#transfer-files)
|
|
34
|
+
- [Access SQLite Databases](#access-sqlite-databases)
|
|
35
|
+
- [Creating Emulators](#creating-emulators)
|
|
36
|
+
- [Modifying Emulators](#modifying-emulators)
|
|
37
|
+
- [iOS Debugging Tools](#ios-debugging-tools)
|
|
38
|
+
- [Instruments](#instruments)
|
|
39
|
+
- [Xcode Build Debugging](#xcode-build-debugging)
|
|
40
|
+
- [Console Logs](#console-logs)
|
|
41
|
+
- [6. Automation and UI Testing](#6-automation-and-ui-testing)
|
|
42
|
+
- [Best Practices](#best-practices)
|
|
43
|
+
- [Memory Management](#memory-management-1)
|
|
44
|
+
- [Debugging](#debugging)
|
|
45
|
+
- [Performance](#performance)
|
|
46
|
+
- [Platform-Specific Notes](#platform-specific-notes)
|
|
47
|
+
- [Android](#android)
|
|
48
|
+
- [iOS](#ios)
|
|
49
|
+
- [Resources](#resources)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Debugging Overview
|
|
54
|
+
|
|
55
|
+
### Essential Elements of Debugging
|
|
56
|
+
|
|
57
|
+
1. **Gather Information** - Clear, accurate description of the problem
|
|
58
|
+
2. **Reproduce** - Consistent steps to recreate the issue
|
|
59
|
+
3. **Deduce** - Logical reasoning to isolate the cause
|
|
60
|
+
4. **Experiment** - Try fixes iteratively, track what works
|
|
61
|
+
5. **Be Tenacious** - Methodical persistence wins
|
|
62
|
+
6. **Track Work** - Document bugs and solutions
|
|
63
|
+
|
|
64
|
+
### Debugging Techniques
|
|
65
|
+
|
|
66
|
+
**1. Print Tracing (Logging)**
|
|
67
|
+
```javascript
|
|
68
|
+
Ti.API.info(`Variable value: ${myVar}`);
|
|
69
|
+
Ti.API.warn('Warning message');
|
|
70
|
+
Ti.API.error('Error occurred');
|
|
71
|
+
Ti.API.log('info', 'Custom level message');
|
|
72
|
+
Ti.API.debug('Debug info'); // Only in dev mode
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**2. Crash Log Evaluation**
|
|
76
|
+
- Build logs (compilation errors)
|
|
77
|
+
- Runtime logs (app crashes)
|
|
78
|
+
- Simulator/Emulator logs
|
|
79
|
+
- Device logs
|
|
80
|
+
|
|
81
|
+
**3. Interactive Debugging**
|
|
82
|
+
- Breakpoints in Studio/IDE
|
|
83
|
+
- Variable inspection
|
|
84
|
+
- Step-through execution
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Memory Management
|
|
89
|
+
|
|
90
|
+
### How JavaScript Manages Memory
|
|
91
|
+
|
|
92
|
+
**Garbage Collection:** JavaScript uses automatic "mark and sweep" garbage collection.
|
|
93
|
+
|
|
94
|
+
1. Interpreter scans memory periodically
|
|
95
|
+
2. Marks objects with active references
|
|
96
|
+
3. Destroys unmarked objects
|
|
97
|
+
4. Frees their memory
|
|
98
|
+
|
|
99
|
+
**Implication:** Objects with no references are automatically cleaned up.
|
|
100
|
+
|
|
101
|
+
### How Titanium Manages Memory
|
|
102
|
+
|
|
103
|
+
Titanium is a **bridge** between JavaScript and native OS:
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
// JavaScript object + Native proxy
|
|
107
|
+
const button = Ti.UI.createButton({title: 'Click me'});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Key Rule:** Setting JavaScript object to `null` destroys BOTH the JavaScript object AND the native proxy.
|
|
111
|
+
|
|
112
|
+
### Releasing Memory Properly
|
|
113
|
+
|
|
114
|
+
**Complete cleanup:**
|
|
115
|
+
```javascript
|
|
116
|
+
let view = Ti.UI.createView({backgroundColor: 'white'});
|
|
117
|
+
win.add(view);
|
|
118
|
+
|
|
119
|
+
// Later: remove AND nullify
|
|
120
|
+
win.remove(view);
|
|
121
|
+
view = null; // Critical: destroys native proxy
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Incomplete cleanup (MEMORY LEAK):**
|
|
125
|
+
```javascript
|
|
126
|
+
let view = Ti.UI.createView({backgroundColor: 'white'});
|
|
127
|
+
win.add(view);
|
|
128
|
+
|
|
129
|
+
// Later: only remove
|
|
130
|
+
win.remove(view); // view object STILL EXISTS in memory!
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Parent-Child Relationships
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
// Good: children not referenced elsewhere
|
|
137
|
+
let view = Ti.UI.createView({
|
|
138
|
+
backgroundColor: 'white'
|
|
139
|
+
});
|
|
140
|
+
view.add(Ti.UI.createButton({title: 'Click'})); // Anonymous child
|
|
141
|
+
|
|
142
|
+
win.remove(view);
|
|
143
|
+
view = null; // Destroys view AND button
|
|
144
|
+
|
|
145
|
+
// Bad: children referenced separately
|
|
146
|
+
const button = Ti.UI.createButton({title: 'Click'});
|
|
147
|
+
let view = Ti.UI.createView({backgroundColor: 'white'});
|
|
148
|
+
view.add(button);
|
|
149
|
+
|
|
150
|
+
win.remove(view);
|
|
151
|
+
view = null; // Destroys view, BUT button still exists!
|
|
152
|
+
button = null; // Now button is destroyed
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Platform Memory Limits
|
|
156
|
+
|
|
157
|
+
| Platform | Memory Limit |
|
|
158
|
+
| -------- | -------------------------------------- |
|
|
159
|
+
| iPhone | ~10% of system memory |
|
|
160
|
+
| iPad | 30-50 MB (smaller is better) |
|
|
161
|
+
| Android | 24-32 MB heap (128 MB with large heap) |
|
|
162
|
+
|
|
163
|
+
**iOS Notes:**
|
|
164
|
+
- Apple doesn't publish exact limits
|
|
165
|
+
- "Jetsam" process can terminate your app
|
|
166
|
+
- "Jetsam" in crash logs = memory issue
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Memory Leak Detection
|
|
171
|
+
|
|
172
|
+
### Common Leak Sources
|
|
173
|
+
|
|
174
|
+
**1. Global Event Listeners**
|
|
175
|
+
```javascript
|
|
176
|
+
// LEAK: Listener keeps reference to window
|
|
177
|
+
Ti.App.addEventListener('custom:event', (e) => {
|
|
178
|
+
// Uses window variables
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Fix: Remove listeners when closing window**
|
|
183
|
+
```javascript
|
|
184
|
+
const myHandler = (e) => {
|
|
185
|
+
// Handle event
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
Ti.App.addEventListener('custom:event', myHandler);
|
|
189
|
+
|
|
190
|
+
win.addEventListener('close', () => {
|
|
191
|
+
Ti.App.removeEventListener('custom:event', myHandler);
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**2. Objects in Closures**
|
|
196
|
+
```javascript
|
|
197
|
+
// LEAK: Closure retains object reference
|
|
198
|
+
function createWindow() {
|
|
199
|
+
const data = []; // Large array
|
|
200
|
+
return Ti.UI.createWindow({
|
|
201
|
+
listener: () => {
|
|
202
|
+
data.push('more'); // Closure reference
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Fix:** Pass data as argument instead of closure reference.
|
|
209
|
+
|
|
210
|
+
**3. Hidden Views**
|
|
211
|
+
```javascript
|
|
212
|
+
// LEAK: Hidden view still consumes memory
|
|
213
|
+
view.visible = false; // Not enough!
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Fix:** Remove and nullify when not needed
|
|
217
|
+
```javascript
|
|
218
|
+
view.visible = false;
|
|
219
|
+
parent.remove(view);
|
|
220
|
+
view = null;
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Debugging Memory on iOS (Instruments)
|
|
224
|
+
|
|
225
|
+
**Setup:**
|
|
226
|
+
1. Open app in iOS Simulator
|
|
227
|
+
2. Xcode → Open Developer Tool → Instruments
|
|
228
|
+
3. Choose **Allocations** template
|
|
229
|
+
4. Choose Target → Your App
|
|
230
|
+
5. Click Record
|
|
231
|
+
|
|
232
|
+
**Key Columns:**
|
|
233
|
+
| Column | What it Shows |
|
|
234
|
+
| --------------------------------- | ------------------------ |
|
|
235
|
+
| **Persistent Bytes** (Live Bytes) | Memory currently in use |
|
|
236
|
+
| **#Persistent** (#Living) | Active object count |
|
|
237
|
+
| **#Transient** (#Transitory) | Ready to garbage collect |
|
|
238
|
+
|
|
239
|
+
**Identifying Leaks:**
|
|
240
|
+
1. Filter for `Ti` prefix (Titanium objects)
|
|
241
|
+
2. Watch **#Living** as you use app
|
|
242
|
+
3. If it grows continuously = leak
|
|
243
|
+
4. **#Transitory** growing is OK (will be GC'd)
|
|
244
|
+
|
|
245
|
+
**Example Workflow:**
|
|
246
|
+
```
|
|
247
|
+
1. Filter: "TiUITableView" (table views)
|
|
248
|
+
2. Open/close a table view screen
|
|
249
|
+
3. Click "Cause GC" (garbage collection)
|
|
250
|
+
4. Check if #Living returns to previous value
|
|
251
|
+
5. If not = leak in that screen
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Debugging Memory on Android (DDMS)
|
|
255
|
+
|
|
256
|
+
**Setup:**
|
|
257
|
+
1. Add to tiapp.xml:
|
|
258
|
+
```xml
|
|
259
|
+
<android xmlns:android="http://schemas.android.com/apk/res/android">
|
|
260
|
+
<manifest>
|
|
261
|
+
<application android:debuggable="true">
|
|
262
|
+
</application>
|
|
263
|
+
</manifest>
|
|
264
|
+
</android>
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
2. Build app for emulator
|
|
268
|
+
3. Open DDMS (Android Device Monitor)
|
|
269
|
+
|
|
270
|
+
**Monitoring:**
|
|
271
|
+
1. Select your app process
|
|
272
|
+
2. Click **Update Heap** button
|
|
273
|
+
3. Click **Cause GC** to force garbage collection
|
|
274
|
+
4. Watch **Allocated** and **# Objects** values
|
|
275
|
+
|
|
276
|
+
**Identifying Leaks:**
|
|
277
|
+
1. Note initial values after GC
|
|
278
|
+
2. Exercise app (open/close screens)
|
|
279
|
+
3. Click **Cause GC** again
|
|
280
|
+
4. If values don't return to baseline = leak
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Android Debugging Tools
|
|
285
|
+
|
|
286
|
+
### DDMS (Dalvik Debug Monitor Service)
|
|
287
|
+
|
|
288
|
+
**Features:**
|
|
289
|
+
- View log output
|
|
290
|
+
- Explore file system
|
|
291
|
+
- Simulate network conditions
|
|
292
|
+
- Simulate calls/SMS
|
|
293
|
+
- Set GPS coordinates
|
|
294
|
+
- Monitor memory
|
|
295
|
+
|
|
296
|
+
#### Log Output with DDMS
|
|
297
|
+
|
|
298
|
+
1. Open DDMS
|
|
299
|
+
2. Select device/emulator
|
|
300
|
+
3. View log in lower pane
|
|
301
|
+
4. Add filter: Log Tag = `TiAPI`
|
|
302
|
+
|
|
303
|
+
#### Simulate Network Conditions
|
|
304
|
+
|
|
305
|
+
**Emulator Control** panel:
|
|
306
|
+
- Voice/Data state (home, roaming)
|
|
307
|
+
- Data speed and latency
|
|
308
|
+
- Test app behavior in poor conditions
|
|
309
|
+
|
|
310
|
+
#### Simulate Calls/SMS
|
|
311
|
+
|
|
312
|
+
**Emulator Control** → Telephony Actions:
|
|
313
|
+
- Incoming voice call
|
|
314
|
+
- Incoming SMS message
|
|
315
|
+
- Test app interruption handling
|
|
316
|
+
|
|
317
|
+
#### Set GPS Coordinates
|
|
318
|
+
|
|
319
|
+
**Emulator Control** → Location Controls:
|
|
320
|
+
- Enter latitude/longitude
|
|
321
|
+
- Click Send
|
|
322
|
+
- Emulator uses these as "current location"
|
|
323
|
+
|
|
324
|
+
#### File System Exploration
|
|
325
|
+
|
|
326
|
+
**Device** → File Explorer:
|
|
327
|
+
- Browse entire file system
|
|
328
|
+
- Pull files (copy to computer)
|
|
329
|
+
- Push files (copy to device)
|
|
330
|
+
- Delete files
|
|
331
|
+
|
|
332
|
+
#### Memory Monitoring
|
|
333
|
+
|
|
334
|
+
Less useful for Titanium (JavaScript runs in one process), but can show overall memory trends.
|
|
335
|
+
|
|
336
|
+
### ADB (Android Debug Bridge)
|
|
337
|
+
|
|
338
|
+
#### Log Output
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
# View all logs
|
|
342
|
+
adb logcat
|
|
343
|
+
|
|
344
|
+
# Device only
|
|
345
|
+
adb -d logcat
|
|
346
|
+
|
|
347
|
+
# Emulator only
|
|
348
|
+
adb -e logcat
|
|
349
|
+
|
|
350
|
+
# Specific device
|
|
351
|
+
adb -s emulator-5556 logcat
|
|
352
|
+
|
|
353
|
+
# Filter for Titanium
|
|
354
|
+
adb logcat -s TiAPI
|
|
355
|
+
# or
|
|
356
|
+
adb logcat | grep TiAPI
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
#### File System
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
# Open shell
|
|
363
|
+
adb shell
|
|
364
|
+
|
|
365
|
+
# List files
|
|
366
|
+
ls -la
|
|
367
|
+
cd /some/path
|
|
368
|
+
|
|
369
|
+
# Exit shell
|
|
370
|
+
exit
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
#### Transfer Files
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# Copy file TO device
|
|
377
|
+
adb push local.txt /sdcard/local.txt
|
|
378
|
+
|
|
379
|
+
# Copy file FROM device
|
|
380
|
+
adb pull /sdcard/remote.txt local.txt
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
#### Access SQLite Databases
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
adb shell
|
|
387
|
+
|
|
388
|
+
# List databases
|
|
389
|
+
ls /data/data/com.example.app/databases/
|
|
390
|
+
|
|
391
|
+
# Open database
|
|
392
|
+
sqlite3 /data/data/com.example.app/databases/mydb.sqlite
|
|
393
|
+
|
|
394
|
+
# Query
|
|
395
|
+
SELECT * FROM tablename;
|
|
396
|
+
|
|
397
|
+
# Exit
|
|
398
|
+
.exit
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### Creating Emulators
|
|
402
|
+
|
|
403
|
+
**Command Line:**
|
|
404
|
+
```bash
|
|
405
|
+
# List available targets
|
|
406
|
+
android list targets
|
|
407
|
+
|
|
408
|
+
# Create AVD
|
|
409
|
+
android create avd -n my_emulator -t 1 -s WVGA800 --abi x86
|
|
410
|
+
|
|
411
|
+
# Launch emulator
|
|
412
|
+
emulator -avd my_emulator
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
**AVD Manager (GUI):**
|
|
416
|
+
```bash
|
|
417
|
+
android avd
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
1. Click **New**
|
|
421
|
+
2. Enter name, select device/target
|
|
422
|
+
3. Choose x86 ABI if available
|
|
423
|
+
4. Click **OK**
|
|
424
|
+
|
|
425
|
+
### Modifying Emulators
|
|
426
|
+
|
|
427
|
+
**Increase disk space:**
|
|
428
|
+
Edit `~/.android/avd/<NAME>.avd/config.ini`:
|
|
429
|
+
```
|
|
430
|
+
disk.dataPartition.size=1024m
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
**Resize emulator:**
|
|
434
|
+
1. Close emulator
|
|
435
|
+
2. AVD Manager → Select emulator → Edit
|
|
436
|
+
3. Change resolution
|
|
437
|
+
4. Save
|
|
438
|
+
|
|
439
|
+
**Scale on-the-fly:**
|
|
440
|
+
```bash
|
|
441
|
+
# Get emulator port
|
|
442
|
+
adb devices
|
|
443
|
+
# emulator-5560
|
|
444
|
+
|
|
445
|
+
# Connect with telnet
|
|
446
|
+
telnet localhost 5560
|
|
447
|
+
|
|
448
|
+
# Scale to 75%
|
|
449
|
+
window scale 0.75
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## iOS Debugging Tools
|
|
455
|
+
|
|
456
|
+
### Instruments
|
|
457
|
+
|
|
458
|
+
**Common Templates:**
|
|
459
|
+
- **Allocations** - Memory usage
|
|
460
|
+
- **Leaks** - Detect memory leaks
|
|
461
|
+
- **Time Profiler** - CPU usage
|
|
462
|
+
- **System Trace** - System-level events
|
|
463
|
+
|
|
464
|
+
### Xcode Build Debugging
|
|
465
|
+
|
|
466
|
+
For native debugging, open Xcode project in `build/iphone`:
|
|
467
|
+
1. Product → Profile
|
|
468
|
+
2. Choose Instruments template
|
|
469
|
+
3. More accurate than attaching to running process
|
|
470
|
+
|
|
471
|
+
### Console Logs
|
|
472
|
+
|
|
473
|
+
**Viewing in Studio:**
|
|
474
|
+
- Console panel shows build/run output
|
|
475
|
+
|
|
476
|
+
**Viewing separately:**
|
|
477
|
+
```bash
|
|
478
|
+
# For running apps
|
|
479
|
+
tail -f ~/Library/Logs/CoreSimulator/<SIMULATOR_ID>/system.log
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
## 6. Automation and UI Testing
|
|
485
|
+
|
|
486
|
+
For continuous integration (CI/CD) pipelines, automated deployment, and functional testing, see:
|
|
487
|
+
|
|
488
|
+
- [Automation with Fastlane and Appium](./automation-fastlane-appium.md): Lane configuration, testing with Mocha/WebdriverIO, and store submission.
|
|
489
|
+
|
|
490
|
+
## Best Practices
|
|
491
|
+
|
|
492
|
+
### Memory Management
|
|
493
|
+
|
|
494
|
+
1. **Always nullify objects** after removing from view hierarchy
|
|
495
|
+
2. **Remove event listeners** when closing windows
|
|
496
|
+
3. **Avoid global variables** - use namespaces/CommonJS
|
|
497
|
+
4. **Use single execution context** - not multiple url-based windows
|
|
498
|
+
5. **Be careful with closures** - they retain references
|
|
499
|
+
6. **Hide vs Remove** - hide for temporary, remove/nullify for permanent
|
|
500
|
+
|
|
501
|
+
### Debugging
|
|
502
|
+
|
|
503
|
+
1. **Log strategically** - remove sensitive logs before production
|
|
504
|
+
2. **Use descriptive log messages** - include variable values
|
|
505
|
+
3. **Test on real devices** - simulators can miss issues
|
|
506
|
+
4. **Profile early and often** - don't wait until crash
|
|
507
|
+
5. **Reproduce consistently** - can't fix what you can't reproduce
|
|
508
|
+
6. **Keep track of bugs** - use issue tracker
|
|
509
|
+
|
|
510
|
+
### Performance
|
|
511
|
+
|
|
512
|
+
1. **Avoid excessive polling** - use events when possible
|
|
513
|
+
2. **Defer loading** - load data as needed, not all at once
|
|
514
|
+
3. **Optimize images** - compress and use appropriate sizes
|
|
515
|
+
4. **Minimize bridge crossings** - cache platform checks
|
|
516
|
+
5. **Test on slow networks** - simulate poor conditions
|
|
517
|
+
6. **Profile before optimizing** - measure first, then fix hotspots
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
## Platform-Specific Notes
|
|
522
|
+
|
|
523
|
+
### Android
|
|
524
|
+
|
|
525
|
+
- **debuggable flag** - Required for native debugging
|
|
526
|
+
- **Large heap** - Enable in tiapp.xml if needed
|
|
527
|
+
- **ProGuard** - Can obfuscate and optimize code
|
|
528
|
+
- **Multidex** - May be needed for very large apps
|
|
529
|
+
|
|
530
|
+
### iOS
|
|
531
|
+
|
|
532
|
+
- **Instruments** - Most powerful tool for iOS profiling
|
|
533
|
+
- **Zombies** - Instruments tool to find over-released objects
|
|
534
|
+
- **Allocation tracker** - Shows object creation/lifecycle
|
|
535
|
+
- **Time Profiler** - Identifies CPU bottlenecks
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
## Resources
|
|
540
|
+
|
|
541
|
+
- **Video:** Your Apps are Leaking (Codestrong 2011)
|
|
542
|
+
- **Android DDMS Docs** - https://minimum-viable-product.github.io/marshmallow-docs/tools/debugging/ddms.html
|
|
543
|
+
- **iOS Instruments Guide** - Apple Developer Documentation
|