@maccesar/titools 2.2.3 → 2.2.8
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/README.md +28 -27
- package/lib/commands/update.js +80 -101
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +31 -31
- package/skills/alloy-guides/references/CONCEPTS.md +3 -3
- package/skills/alloy-guides/references/CONTROLLERS.md +1 -1
- package/skills/alloy-guides/references/MODELS.md +6 -6
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +1 -1
- package/skills/alloy-guides/references/VIEWS_XML.md +1 -1
- package/skills/alloy-guides/references/WIDGETS.md +1 -1
- package/skills/alloy-howtos/SKILL.md +27 -27
- package/skills/alloy-howtos/references/best_practices.md +9 -9
- package/skills/alloy-howtos/references/cli_reference.md +14 -14
- package/skills/alloy-howtos/references/config_files.md +16 -16
- package/skills/alloy-howtos/references/custom_tags.md +16 -16
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +11 -15
- package/skills/alloy-howtos/references/samples.md +19 -19
- package/skills/purgetss/SKILL.md +11 -1
- package/skills/purgetss/references/animation-system.md +1 -1
- package/skills/purgetss/references/cli-commands.md +3 -3
- package/skills/purgetss/references/customization-deep-dive.md +1 -1
- package/skills/purgetss/references/dynamic-component-creation.md +1 -1
- package/skills/purgetss/references/icon-fonts.md +4 -0
- package/skills/purgetss/references/installation-setup.md +8 -1
- package/skills/purgetss/references/migration-guide.md +4 -0
- package/skills/purgetss/references/tikit-components.md +193 -204
- package/skills/purgetss/references/ui-ux-design.md +1 -1
- package/skills/ti-expert/SKILL.md +78 -118
- package/skills/ti-expert/references/alloy-builtins.md +18 -18
- package/skills/ti-expert/references/alloy-structure.md +21 -21
- package/skills/ti-expert/references/anti-patterns.md +15 -15
- package/skills/ti-expert/references/cli-expert.md +15 -15
- package/skills/ti-expert/references/code-conventions.md +38 -38
- package/skills/ti-expert/references/contracts.md +8 -8
- package/skills/ti-expert/references/controller-patterns.md +14 -14
- package/skills/ti-expert/references/error-handling.md +11 -11
- package/skills/ti-expert/references/examples.md +12 -12
- package/skills/ti-expert/references/migration-patterns.md +24 -24
- package/skills/ti-expert/references/patterns.md +10 -10
- package/skills/ti-expert/references/performance-listview.md +16 -16
- package/skills/ti-expert/references/performance-optimization.md +41 -41
- package/skills/ti-expert/references/security-device.md +22 -22
- package/skills/ti-expert/references/security-fundamentals.md +19 -19
- package/skills/ti-expert/references/state-management.md +33 -33
- package/skills/ti-expert/references/testing-e2e-ci.md +25 -25
- package/skills/ti-expert/references/testing-unit.md +24 -24
- package/skills/ti-expert/references/theming.md +15 -15
- package/skills/ti-guides/SKILL.md +58 -60
- package/skills/ti-guides/references/advanced-data-and-images.md +33 -33
- package/skills/ti-guides/references/android-manifest.md +15 -15
- package/skills/ti-guides/references/app-distribution.md +70 -166
- package/skills/ti-guides/references/application-frameworks.md +96 -114
- package/skills/ti-guides/references/cli-reference.md +294 -294
- package/skills/ti-guides/references/coding-best-practices.md +42 -33
- package/skills/ti-guides/references/commonjs-advanced.md +57 -51
- package/skills/ti-guides/references/hello-world.md +36 -36
- package/skills/ti-guides/references/hyperloop-native-access.md +66 -66
- package/skills/ti-guides/references/javascript-primer.md +83 -101
- package/skills/ti-guides/references/reserved-words.md +9 -9
- package/skills/ti-guides/references/resources.md +75 -83
- package/skills/ti-guides/references/style-and-conventions.md +35 -28
- package/skills/ti-guides/references/tiapp-config.md +110 -74
- package/skills/ti-howtos/SKILL.md +88 -92
- package/skills/ti-howtos/references/android-platform-deep-dives.md +104 -104
- package/skills/ti-howtos/references/automation-fastlane-appium.md +39 -39
- package/skills/ti-howtos/references/buffer-codec-streams.md +60 -60
- package/skills/ti-howtos/references/cross-platform-development.md +115 -136
- package/skills/ti-howtos/references/debugging-profiling.md +167 -181
- package/skills/ti-howtos/references/extending-titanium.md +121 -121
- package/skills/ti-howtos/references/google-maps-v2.md +84 -82
- package/skills/ti-howtos/references/ios-map-kit.md +65 -60
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +123 -123
- package/skills/ti-howtos/references/local-data-sources.md +79 -78
- package/skills/ti-howtos/references/location-and-maps.md +116 -120
- package/skills/ti-howtos/references/media-apis.md +87 -86
- package/skills/ti-howtos/references/notification-services.md +250 -260
- package/skills/ti-howtos/references/remote-data-sources.md +98 -93
- package/skills/ti-howtos/references/tutorials.md +226 -216
- package/skills/ti-howtos/references/using-modules.md +73 -102
- package/skills/ti-howtos/references/web-content-integration.md +101 -103
- package/skills/ti-howtos/references/webpack-build-pipeline.md +52 -44
- package/skills/ti-ui/SKILL.md +85 -85
- package/skills/ti-ui/references/accessibility-deep-dive.md +57 -57
- package/skills/ti-ui/references/animation-and-matrices.md +79 -79
- package/skills/ti-ui/references/application-structures.md +96 -99
- package/skills/ti-ui/references/custom-fonts-styling.md +99 -99
- package/skills/ti-ui/references/event-handling.md +58 -58
- package/skills/ti-ui/references/gestures.md +62 -64
- package/skills/ti-ui/references/icons-and-splash-screens.md +88 -88
- package/skills/ti-ui/references/layouts-and-positioning.md +87 -97
- package/skills/ti-ui/references/listviews-and-performance.md +107 -107
- package/skills/ti-ui/references/orientation.md +87 -88
- package/skills/ti-ui/references/platform-ui-android.md +87 -81
- package/skills/ti-ui/references/platform-ui-ios.md +63 -61
- package/skills/ti-ui/references/scrolling-views.md +29 -29
- package/skills/ti-ui/references/tableviews.md +56 -56
|
@@ -1,214 +1,210 @@
|
|
|
1
|
-
# Debugging and
|
|
1
|
+
# Debugging and profiling
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Guide to debugging Titanium apps, managing memory, finding leaks, and using native tools.
|
|
4
4
|
|
|
5
|
-
## Debugging
|
|
5
|
+
## Debugging overview
|
|
6
6
|
|
|
7
|
-
### Essential
|
|
7
|
+
### Essential elements of debugging
|
|
8
8
|
|
|
9
|
-
1.
|
|
10
|
-
2.
|
|
11
|
-
3.
|
|
12
|
-
4.
|
|
13
|
-
5.
|
|
14
|
-
6.
|
|
9
|
+
1. Gather information: clear, accurate description of the problem
|
|
10
|
+
2. Reproduce: consistent steps to recreate the issue
|
|
11
|
+
3. Deduce: logical reasoning to isolate the cause
|
|
12
|
+
4. Experiment: try fixes iteratively, track what works
|
|
13
|
+
5. Be tenacious: methodical persistence wins
|
|
14
|
+
6. Track work: document bugs and solutions
|
|
15
15
|
|
|
16
|
-
### Debugging
|
|
16
|
+
### Debugging techniques
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
1. Print tracing (logging)
|
|
19
19
|
```javascript
|
|
20
20
|
Ti.API.info(`Variable value: ${myVar}`);
|
|
21
21
|
Ti.API.warn('Warning message');
|
|
22
22
|
Ti.API.error('Error occurred');
|
|
23
23
|
Ti.API.log('info', 'Custom level message');
|
|
24
|
-
Ti.API.debug('Debug info');
|
|
24
|
+
Ti.API.debug('Debug info'); // Only in dev mode
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
2. Crash log evaluation
|
|
28
28
|
- Build logs (compilation errors)
|
|
29
29
|
- Runtime logs (app crashes)
|
|
30
30
|
- Simulator/Emulator logs
|
|
31
31
|
- Device logs
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
3. Interactive debugging
|
|
34
34
|
- Breakpoints in Studio/IDE
|
|
35
35
|
- Variable inspection
|
|
36
36
|
- Step-through execution
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
## Memory management
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
### How JavaScript manages memory
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
**Garbage Collection:** JavaScript uses automatic "mark and sweep" garbage collection.
|
|
42
|
+
Garbage collection: JavaScript uses automatic mark-and-sweep.
|
|
45
43
|
|
|
46
44
|
1. Interpreter scans memory periodically
|
|
47
45
|
2. Marks objects with active references
|
|
48
46
|
3. Destroys unmarked objects
|
|
49
47
|
4. Frees their memory
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
Implication: objects with no references are cleaned up automatically.
|
|
52
50
|
|
|
53
|
-
### How Titanium
|
|
51
|
+
### How Titanium manages memory
|
|
54
52
|
|
|
55
|
-
Titanium
|
|
53
|
+
Titanium bridges JavaScript and native OS objects:
|
|
56
54
|
|
|
57
55
|
```javascript
|
|
58
56
|
// JavaScript object + Native proxy
|
|
59
|
-
const button = Ti.UI.createButton({title: 'Click me'});
|
|
57
|
+
const button = Ti.UI.createButton({ title: 'Click me' });
|
|
60
58
|
```
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
Key rule: setting a JavaScript object to `null` destroys both the JavaScript object and the native proxy.
|
|
63
61
|
|
|
64
|
-
### Releasing
|
|
62
|
+
### Releasing memory properly
|
|
65
63
|
|
|
66
|
-
|
|
64
|
+
Complete cleanup:
|
|
67
65
|
```javascript
|
|
68
|
-
let view = Ti.UI.createView({backgroundColor: 'white'});
|
|
66
|
+
let view = Ti.UI.createView({ backgroundColor: 'white' });
|
|
69
67
|
win.add(view);
|
|
70
68
|
|
|
71
|
-
// Later: remove
|
|
69
|
+
// Later: remove and nullify
|
|
72
70
|
win.remove(view);
|
|
73
|
-
view = null;
|
|
71
|
+
view = null; // Destroys native proxy
|
|
74
72
|
```
|
|
75
73
|
|
|
76
|
-
|
|
74
|
+
Incomplete cleanup (memory leak):
|
|
77
75
|
```javascript
|
|
78
|
-
let view = Ti.UI.createView({backgroundColor: 'white'});
|
|
76
|
+
let view = Ti.UI.createView({ backgroundColor: 'white' });
|
|
79
77
|
win.add(view);
|
|
80
78
|
|
|
81
79
|
// Later: only remove
|
|
82
|
-
win.remove(view);
|
|
80
|
+
win.remove(view); // view object still exists in memory
|
|
83
81
|
```
|
|
84
82
|
|
|
85
|
-
### Parent-
|
|
83
|
+
### Parent-child relationships
|
|
86
84
|
|
|
87
85
|
```javascript
|
|
88
86
|
// Good: children not referenced elsewhere
|
|
89
87
|
let view = Ti.UI.createView({
|
|
90
|
-
|
|
88
|
+
backgroundColor: 'white'
|
|
91
89
|
});
|
|
92
|
-
view.add(Ti.UI.createButton({title: 'Click'}));
|
|
90
|
+
view.add(Ti.UI.createButton({ title: 'Click' })); // Anonymous child
|
|
93
91
|
|
|
94
92
|
win.remove(view);
|
|
95
|
-
view = null;
|
|
93
|
+
view = null; // Destroys view and button
|
|
96
94
|
|
|
97
95
|
// Bad: children referenced separately
|
|
98
|
-
const button = Ti.UI.createButton({title: 'Click'});
|
|
99
|
-
let view = Ti.UI.createView({backgroundColor: 'white'});
|
|
96
|
+
const button = Ti.UI.createButton({ title: 'Click' });
|
|
97
|
+
let view = Ti.UI.createView({ backgroundColor: 'white' });
|
|
100
98
|
view.add(button);
|
|
101
99
|
|
|
102
100
|
win.remove(view);
|
|
103
|
-
view = null;
|
|
104
|
-
button = null;
|
|
101
|
+
view = null; // Destroys view, but button still exists
|
|
102
|
+
button = null; // Now button is destroyed
|
|
105
103
|
```
|
|
106
104
|
|
|
107
|
-
### Platform
|
|
105
|
+
### Platform memory limits
|
|
108
106
|
|
|
109
|
-
| Platform | Memory
|
|
107
|
+
| Platform | Memory limit |
|
|
110
108
|
| -------- | -------------------------------------- |
|
|
111
109
|
| iPhone | ~10% of system memory |
|
|
112
110
|
| iPad | 30-50 MB (smaller is better) |
|
|
113
111
|
| Android | 24-32 MB heap (128 MB with large heap) |
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
- Apple
|
|
117
|
-
-
|
|
118
|
-
- "Jetsam" in crash logs
|
|
119
|
-
|
|
120
|
-
> **Important**: Memory ≠ storage. A 16GB device doesn't mean 16GB for your app. These limits may be higher on newer devices but always optimize for the lowest common denominator.
|
|
113
|
+
Notes for iOS:
|
|
114
|
+
- Apple does not publish exact limits
|
|
115
|
+
- The jetsam process can terminate your app
|
|
116
|
+
- "Jetsam" in crash logs often means a memory issue
|
|
121
117
|
|
|
122
|
-
|
|
118
|
+
Important: memory is not storage. A 16GB device does not mean 16GB for your app. Limits may be higher on newer devices, but optimize for the lowest common denominator.
|
|
123
119
|
|
|
124
|
-
## Memory
|
|
120
|
+
## Memory leak detection
|
|
125
121
|
|
|
126
|
-
### Common
|
|
122
|
+
### Common leak sources
|
|
127
123
|
|
|
128
|
-
|
|
124
|
+
1. Global event listeners
|
|
129
125
|
```javascript
|
|
130
|
-
//
|
|
126
|
+
// Leak: listener keeps reference to window
|
|
131
127
|
Ti.App.addEventListener('custom:event', (e) => {
|
|
132
|
-
|
|
128
|
+
// Uses window variables
|
|
133
129
|
});
|
|
134
130
|
```
|
|
135
131
|
|
|
136
|
-
|
|
132
|
+
Fix: remove listeners when closing window
|
|
137
133
|
```javascript
|
|
138
134
|
const myHandler = (e) => {
|
|
139
|
-
|
|
135
|
+
// Handle event
|
|
140
136
|
};
|
|
141
137
|
|
|
142
138
|
Ti.App.addEventListener('custom:event', myHandler);
|
|
143
139
|
|
|
144
140
|
win.addEventListener('close', () => {
|
|
145
|
-
|
|
141
|
+
Ti.App.removeEventListener('custom:event', myHandler);
|
|
146
142
|
});
|
|
147
143
|
```
|
|
148
144
|
|
|
149
|
-
|
|
145
|
+
2. Objects in closures
|
|
150
146
|
```javascript
|
|
151
|
-
//
|
|
147
|
+
// Leak: closure retains object reference
|
|
152
148
|
function createWindow() {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
149
|
+
const data = []; // Large array
|
|
150
|
+
return Ti.UI.createWindow({
|
|
151
|
+
listener: () => {
|
|
152
|
+
data.push('more'); // Closure reference
|
|
153
|
+
}
|
|
154
|
+
});
|
|
159
155
|
}
|
|
160
156
|
```
|
|
161
157
|
|
|
162
|
-
|
|
158
|
+
Fix: pass data as an argument instead of keeping it in a closure.
|
|
163
159
|
|
|
164
|
-
|
|
160
|
+
3. Hidden views
|
|
165
161
|
```javascript
|
|
166
|
-
//
|
|
167
|
-
view.visible = false;
|
|
162
|
+
// Leak: hidden view still consumes memory
|
|
163
|
+
view.visible = false; // Not enough
|
|
168
164
|
```
|
|
169
165
|
|
|
170
|
-
|
|
166
|
+
Fix: remove and nullify when not needed
|
|
171
167
|
```javascript
|
|
172
168
|
view.visible = false;
|
|
173
169
|
parent.remove(view);
|
|
174
170
|
view = null;
|
|
175
171
|
```
|
|
176
172
|
|
|
177
|
-
### Debugging
|
|
173
|
+
### Debugging memory on iOS (Instruments)
|
|
178
174
|
|
|
179
|
-
|
|
175
|
+
Setup:
|
|
180
176
|
1. Open app in iOS Simulator
|
|
181
177
|
2. Xcode → Open Developer Tool → Instruments
|
|
182
|
-
3. Choose
|
|
178
|
+
3. Choose Allocations template
|
|
183
179
|
4. Choose Target → Your App
|
|
184
180
|
5. Click Record
|
|
185
181
|
|
|
186
|
-
|
|
187
|
-
| Column | What it
|
|
188
|
-
| --------------------------------- |
|
|
189
|
-
|
|
|
190
|
-
|
|
|
191
|
-
|
|
|
182
|
+
Key columns:
|
|
183
|
+
| Column | What it shows |
|
|
184
|
+
| --------------------------------- | ----------------------- |
|
|
185
|
+
| Persistent Bytes (Live Bytes) | Memory currently in use |
|
|
186
|
+
| #Persistent (#Living) | Active object count |
|
|
187
|
+
| #Transient (#Transitory) | Ready to garbage collect |
|
|
192
188
|
|
|
193
|
-
|
|
189
|
+
Identifying leaks:
|
|
194
190
|
1. Filter for `Ti` prefix (Titanium objects)
|
|
195
|
-
2. Watch
|
|
196
|
-
3. If it grows continuously
|
|
197
|
-
4.
|
|
191
|
+
2. Watch #Living as you use the app
|
|
192
|
+
3. If it grows continuously, you have a leak
|
|
193
|
+
4. #Transitory growing is fine (will be GC'd)
|
|
198
194
|
|
|
199
|
-
|
|
195
|
+
Example workflow:
|
|
200
196
|
```
|
|
201
197
|
1. Filter: "TiUITableView" (table views)
|
|
202
198
|
2. Open/close a table view screen
|
|
203
199
|
3. Click "Cause GC" (garbage collection)
|
|
204
200
|
4. Check if #Living returns to previous value
|
|
205
|
-
5. If not
|
|
201
|
+
5. If not, the leak is in that screen
|
|
206
202
|
```
|
|
207
203
|
|
|
208
|
-
### Debugging
|
|
204
|
+
### Debugging memory on Android (DDMS)
|
|
209
205
|
|
|
210
|
-
|
|
211
|
-
1. Add to tiapp.xml
|
|
206
|
+
Setup:
|
|
207
|
+
1. Add to `tiapp.xml`:
|
|
212
208
|
```xml
|
|
213
209
|
<android xmlns:android="http://schemas.android.com/apk/res/android">
|
|
214
210
|
<manifest>
|
|
@@ -221,25 +217,23 @@ view = null;
|
|
|
221
217
|
2. Build app for emulator
|
|
222
218
|
3. Open DDMS (Android Device Monitor)
|
|
223
219
|
|
|
224
|
-
|
|
220
|
+
Monitoring:
|
|
225
221
|
1. Select your app process
|
|
226
|
-
2. Click
|
|
227
|
-
3. Click
|
|
228
|
-
4. Watch
|
|
222
|
+
2. Click Update Heap
|
|
223
|
+
3. Click Cause GC to force garbage collection
|
|
224
|
+
4. Watch Allocated and # Objects values
|
|
229
225
|
|
|
230
|
-
|
|
226
|
+
Identifying leaks:
|
|
231
227
|
1. Note initial values after GC
|
|
232
228
|
2. Exercise app (open/close screens)
|
|
233
|
-
3. Click
|
|
234
|
-
4. If values
|
|
229
|
+
3. Click Cause GC again
|
|
230
|
+
4. If values do not return to baseline, there is a leak
|
|
235
231
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
## Android Debugging Tools
|
|
232
|
+
## Android debugging tools
|
|
239
233
|
|
|
240
234
|
### DDMS (Dalvik Debug Monitor Service)
|
|
241
235
|
|
|
242
|
-
|
|
236
|
+
Features:
|
|
243
237
|
- View log output
|
|
244
238
|
- Explore file system
|
|
245
239
|
- Simulate network conditions
|
|
@@ -247,49 +241,49 @@ view = null;
|
|
|
247
241
|
- Set GPS coordinates
|
|
248
242
|
- Monitor memory
|
|
249
243
|
|
|
250
|
-
#### Log
|
|
244
|
+
#### Log output with DDMS
|
|
251
245
|
|
|
252
246
|
1. Open DDMS
|
|
253
247
|
2. Select device/emulator
|
|
254
248
|
3. View log in lower pane
|
|
255
249
|
4. Add filter: Log Tag = `TiAPI`
|
|
256
250
|
|
|
257
|
-
#### Simulate
|
|
251
|
+
#### Simulate network conditions
|
|
258
252
|
|
|
259
|
-
|
|
253
|
+
Emulator Control panel:
|
|
260
254
|
- Voice/Data state (home, roaming)
|
|
261
255
|
- Data speed and latency
|
|
262
256
|
- Test app behavior in poor conditions
|
|
263
257
|
|
|
264
|
-
#### Simulate
|
|
258
|
+
#### Simulate calls/SMS
|
|
265
259
|
|
|
266
|
-
|
|
260
|
+
Emulator Control → Telephony Actions:
|
|
267
261
|
- Incoming voice call
|
|
268
262
|
- Incoming SMS message
|
|
269
263
|
- Test app interruption handling
|
|
270
264
|
|
|
271
|
-
#### Set GPS
|
|
265
|
+
#### Set GPS coordinates
|
|
272
266
|
|
|
273
|
-
|
|
267
|
+
Emulator Control → Location Controls:
|
|
274
268
|
- Enter latitude/longitude
|
|
275
269
|
- Click Send
|
|
276
|
-
- Emulator uses these as
|
|
270
|
+
- Emulator uses these as current location
|
|
277
271
|
|
|
278
|
-
#### File
|
|
272
|
+
#### File system exploration
|
|
279
273
|
|
|
280
|
-
|
|
274
|
+
Device → File Explorer:
|
|
281
275
|
- Browse entire file system
|
|
282
276
|
- Pull files (copy to computer)
|
|
283
277
|
- Push files (copy to device)
|
|
284
278
|
- Delete files
|
|
285
279
|
|
|
286
|
-
#### Memory
|
|
280
|
+
#### Memory monitoring
|
|
287
281
|
|
|
288
|
-
Less useful for Titanium (JavaScript runs in one process), but can show overall memory trends.
|
|
282
|
+
Less useful for Titanium (JavaScript runs in one process), but it can show overall memory trends.
|
|
289
283
|
|
|
290
284
|
### ADB (Android Debug Bridge)
|
|
291
285
|
|
|
292
|
-
#### Log
|
|
286
|
+
#### Log output
|
|
293
287
|
|
|
294
288
|
```bash
|
|
295
289
|
# View all logs
|
|
@@ -310,7 +304,7 @@ adb logcat -s TiAPI
|
|
|
310
304
|
adb logcat | grep TiAPI
|
|
311
305
|
```
|
|
312
306
|
|
|
313
|
-
#### File
|
|
307
|
+
#### File system
|
|
314
308
|
|
|
315
309
|
```bash
|
|
316
310
|
# Open shell
|
|
@@ -324,7 +318,7 @@ cd /some/path
|
|
|
324
318
|
exit
|
|
325
319
|
```
|
|
326
320
|
|
|
327
|
-
#### Transfer
|
|
321
|
+
#### Transfer files
|
|
328
322
|
|
|
329
323
|
```bash
|
|
330
324
|
# Copy file TO device
|
|
@@ -334,7 +328,7 @@ adb push local.txt /sdcard/local.txt
|
|
|
334
328
|
adb pull /sdcard/remote.txt local.txt
|
|
335
329
|
```
|
|
336
330
|
|
|
337
|
-
#### Access SQLite
|
|
331
|
+
#### Access SQLite databases
|
|
338
332
|
|
|
339
333
|
```bash
|
|
340
334
|
adb shell
|
|
@@ -352,9 +346,9 @@ SELECT * FROM tablename;
|
|
|
352
346
|
.exit
|
|
353
347
|
```
|
|
354
348
|
|
|
355
|
-
### Creating
|
|
349
|
+
### Creating emulators
|
|
356
350
|
|
|
357
|
-
|
|
351
|
+
Command line:
|
|
358
352
|
```bash
|
|
359
353
|
# List available targets
|
|
360
354
|
android list targets
|
|
@@ -366,31 +360,31 @@ android create avd -n my_emulator -t 1 -s WVGA800 --abi x86
|
|
|
366
360
|
emulator -avd my_emulator
|
|
367
361
|
```
|
|
368
362
|
|
|
369
|
-
|
|
363
|
+
AVD Manager (GUI):
|
|
370
364
|
```bash
|
|
371
365
|
android avd
|
|
372
366
|
```
|
|
373
367
|
|
|
374
|
-
1. Click
|
|
368
|
+
1. Click New
|
|
375
369
|
2. Enter name, select device/target
|
|
376
370
|
3. Choose x86 ABI if available
|
|
377
|
-
4. Click
|
|
371
|
+
4. Click OK
|
|
378
372
|
|
|
379
|
-
### Modifying
|
|
373
|
+
### Modifying emulators
|
|
380
374
|
|
|
381
|
-
|
|
375
|
+
Increase disk space:
|
|
382
376
|
Edit `~/.android/avd/<NAME>.avd/config.ini`:
|
|
383
377
|
```
|
|
384
378
|
disk.dataPartition.size=1024m
|
|
385
379
|
```
|
|
386
380
|
|
|
387
|
-
|
|
381
|
+
Resize emulator:
|
|
388
382
|
1. Close emulator
|
|
389
383
|
2. AVD Manager → Select emulator → Edit
|
|
390
384
|
3. Change resolution
|
|
391
385
|
4. Save
|
|
392
386
|
|
|
393
|
-
|
|
387
|
+
Scale on-the-fly:
|
|
394
388
|
```bash
|
|
395
389
|
# Get emulator port
|
|
396
390
|
adb devices
|
|
@@ -403,96 +397,88 @@ telnet localhost 5560
|
|
|
403
397
|
window scale 0.75
|
|
404
398
|
```
|
|
405
399
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
## iOS Debugging Tools
|
|
400
|
+
## iOS debugging tools
|
|
409
401
|
|
|
410
402
|
### Instruments
|
|
411
403
|
|
|
412
|
-
|
|
413
|
-
-
|
|
414
|
-
-
|
|
415
|
-
-
|
|
416
|
-
-
|
|
417
|
-
-
|
|
404
|
+
Key templates for Titanium debugging:
|
|
405
|
+
- Allocations: track object creation and live object counts. Look at Persistent Bytes (Live Bytes) and #Persistent (#Living).
|
|
406
|
+
- Leaks: detect memory leaks in real time. Shows objects that are allocated but never released.
|
|
407
|
+
- Time Profiler: identify CPU-intensive operations and bottlenecks.
|
|
408
|
+
- System Trace: system-level events and thread activity.
|
|
409
|
+
- Zombies: detect messages sent to deallocated objects (debug builds only). Useful for over-released objects.
|
|
418
410
|
|
|
419
|
-
### Xcode
|
|
411
|
+
### Xcode build debugging
|
|
420
412
|
|
|
421
|
-
For native debugging, open Xcode project in `build/iphone`:
|
|
413
|
+
For native debugging, open the Xcode project in `build/iphone`:
|
|
422
414
|
1. Product → Profile
|
|
423
415
|
2. Choose Instruments template
|
|
424
|
-
3. More accurate than attaching to running process
|
|
416
|
+
3. More accurate than attaching to a running process
|
|
425
417
|
|
|
426
|
-
### Console
|
|
418
|
+
### Console logs
|
|
427
419
|
|
|
428
|
-
|
|
420
|
+
Viewing in Studio:
|
|
429
421
|
- Console panel shows build/run output
|
|
430
422
|
|
|
431
|
-
|
|
423
|
+
Viewing separately:
|
|
432
424
|
```bash
|
|
433
425
|
# For running apps
|
|
434
426
|
tail -f ~/Library/Logs/CoreSimulator/<SIMULATOR_ID>/system.log
|
|
435
427
|
```
|
|
436
428
|
|
|
437
|
-
|
|
429
|
+
## 6. Automation and UI testing
|
|
438
430
|
|
|
439
|
-
|
|
431
|
+
For CI/CD pipelines, automated deployment, and functional testing, see:
|
|
440
432
|
|
|
441
|
-
|
|
433
|
+
- Automation with Fastlane and Appium: `automation-fastlane-appium.md`
|
|
442
434
|
|
|
443
|
-
|
|
435
|
+
## Best practices
|
|
444
436
|
|
|
445
|
-
|
|
437
|
+
### Memory management
|
|
446
438
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
5. **Be careful with closures** - they retain references
|
|
454
|
-
6. **Hide vs Remove** - hide for temporary, remove/nullify for permanent
|
|
439
|
+
1. Always nullify objects after removing them from the view hierarchy.
|
|
440
|
+
2. Remove event listeners when closing windows.
|
|
441
|
+
3. Avoid global variables; use namespaces or CommonJS.
|
|
442
|
+
4. Use a single execution context, not multiple URL-based windows.
|
|
443
|
+
5. Be careful with closures; they retain references.
|
|
444
|
+
6. Hide vs remove: hide for temporary, remove/nullify for permanent.
|
|
455
445
|
|
|
456
446
|
### Debugging
|
|
457
447
|
|
|
458
|
-
1.
|
|
459
|
-
2.
|
|
460
|
-
3.
|
|
461
|
-
4.
|
|
462
|
-
5.
|
|
463
|
-
6.
|
|
448
|
+
1. Log strategically and remove sensitive logs before production.
|
|
449
|
+
2. Use descriptive log messages and include variable values.
|
|
450
|
+
3. Test on real devices; simulators miss issues.
|
|
451
|
+
4. Profile early and often; do not wait for crashes.
|
|
452
|
+
5. Reproduce consistently; you cannot fix what you cannot reproduce.
|
|
453
|
+
6. Keep track of bugs; use an issue tracker.
|
|
464
454
|
|
|
465
455
|
### Performance
|
|
466
456
|
|
|
467
|
-
1.
|
|
468
|
-
2.
|
|
469
|
-
3.
|
|
470
|
-
4.
|
|
471
|
-
5.
|
|
472
|
-
6.
|
|
473
|
-
|
|
474
|
-
---
|
|
457
|
+
1. Avoid excessive polling; use events when possible.
|
|
458
|
+
2. Defer loading; load data as needed.
|
|
459
|
+
3. Optimize images; compress and use appropriate sizes.
|
|
460
|
+
4. Minimize bridge crossings; cache platform checks.
|
|
461
|
+
5. Test on slow networks; simulate poor conditions.
|
|
462
|
+
6. Profile before optimizing; measure first, then fix hotspots.
|
|
475
463
|
|
|
476
|
-
## Platform-
|
|
464
|
+
## Platform-specific notes
|
|
477
465
|
|
|
478
466
|
### Android
|
|
479
467
|
|
|
480
|
-
-
|
|
481
|
-
-
|
|
482
|
-
-
|
|
483
|
-
-
|
|
468
|
+
- Debuggable flag: required for native debugging
|
|
469
|
+
- Large heap: enable in `tiapp.xml` if needed
|
|
470
|
+
- ProGuard: can obfuscate and optimize code
|
|
471
|
+
- Multidex: may be needed for very large apps
|
|
484
472
|
|
|
485
473
|
### iOS
|
|
486
474
|
|
|
487
|
-
-
|
|
488
|
-
-
|
|
489
|
-
-
|
|
490
|
-
-
|
|
491
|
-
|
|
492
|
-
---
|
|
475
|
+
- Instruments: most powerful tool for iOS profiling
|
|
476
|
+
- Zombies: Instruments tool to find over-released objects
|
|
477
|
+
- Allocation tracker: shows object creation and lifecycle
|
|
478
|
+
- Time Profiler: identifies CPU bottlenecks
|
|
493
479
|
|
|
494
480
|
## Resources
|
|
495
481
|
|
|
496
|
-
-
|
|
497
|
-
-
|
|
498
|
-
-
|
|
482
|
+
- Video: Your Apps are Leaking (Codestrong 2011)
|
|
483
|
+
- Android DDMS docs: https://minimum-viable-product.github.io/marshmallow-docs/tools/debugging/ddms.html
|
|
484
|
+
- iOS Instruments guide: Apple Developer Documentation
|