@maccesar/titools 5.2.5 → 5.4.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/CONTRIBUTING.md +1 -1
- package/README.md +58 -97
- package/agents/ti-pro.md +4 -2
- package/commands/ti-audit.md +7 -5
- package/docs/examples.md +24 -13
- package/docs/knowledge-index.md +2 -1
- package/lib/config.js +1 -0
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +18 -179
- package/skills/alloy-guides/references/CLI_TASKS.md +17 -216
- package/skills/alloy-guides/references/CONCEPTS.md +27 -162
- package/skills/alloy-guides/references/CONTROLLERS.md +38 -236
- package/skills/alloy-guides/references/MODELS.md +47 -723
- package/skills/alloy-guides/references/MODELS_ADVANCED.md +21 -482
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +12 -222
- package/skills/alloy-guides/references/VIEWS_STYLES.md +39 -358
- package/skills/alloy-guides/references/VIEWS_XML.md +36 -552
- package/skills/alloy-guides/references/WIDGETS.md +49 -127
- package/skills/alloy-howtos/SKILL.md +14 -169
- package/skills/alloy-howtos/references/best_practices.md +9 -113
- package/skills/alloy-howtos/references/cli_reference.md +18 -223
- package/skills/alloy-howtos/references/config_files.md +50 -133
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +19 -63
- package/skills/alloy-howtos/references/samples.md +21 -138
- package/skills/ti-api/SKILL.md +10 -2
- package/skills/ti-api/references/api-android.md +36 -2
- package/skills/ti-api/references/api-app-platform.md +39 -3
- package/skills/ti-api/references/api-core.md +50 -18
- package/skills/ti-api/references/api-data-network.md +49 -35
- package/skills/ti-api/references/api-media.md +45 -27
- package/skills/ti-api/references/api-services.md +39 -9
- package/skills/ti-api/references/api-ui-android.md +33 -13
- package/skills/ti-api/references/api-ui-extras.md +41 -15
- package/skills/ti-api/references/api-ui-ios-animator.md +42 -26
- package/skills/ti-api/references/api-ui-ios.md +74 -2
- package/skills/ti-api/references/api-ui-lists.md +32 -16
- package/skills/ti-api/references/api-ui-text-input.md +34 -17
- package/skills/ti-api/references/api-ui-views.md +27 -1
- package/skills/ti-api/references/api-ui-windows-navigation.md +32 -18
- package/skills/ti-api/references/api-xml-global.md +66 -16
- package/skills/ti-create-release/SKILL.md +98 -0
- package/skills/ti-create-release/references/module-discovery.md +69 -0
- package/skills/ti-expert/references/adaptive-layouts.md +1 -1
- package/skills/ti-guides/SKILL.md +37 -76
- package/skills/ti-guides/references/advanced-data-and-images.md +122 -126
- package/skills/ti-guides/references/android-manifest.md +24 -83
- package/skills/ti-guides/references/app-distribution.md +31 -377
- package/skills/ti-guides/references/application-frameworks.md +127 -335
- package/skills/ti-guides/references/cli-reference.md +184 -633
- package/skills/ti-guides/references/commonjs-advanced.md +81 -231
- package/skills/ti-guides/references/compatibility-matrix.md +36 -75
- package/skills/ti-guides/references/hello-world.md +95 -70
- package/skills/ti-guides/references/hyperloop-native-access.md +52 -448
- package/skills/ti-guides/references/resources.md +174 -142
- package/skills/ti-guides/references/sdk-release-notes.md +28 -71
- package/skills/ti-guides/references/tiapp-config.md +222 -598
- package/skills/ti-howtos/SKILL.md +23 -123
- package/skills/ti-howtos/references/cross-platform-development.md +119 -324
- package/skills/ti-howtos/references/debugging-profiling.md +77 -445
- package/skills/ti-howtos/references/extending-titanium.md +199 -673
- package/skills/ti-howtos/references/local-data-sources.md +87 -300
- package/skills/ti-howtos/references/location-and-maps.md +86 -213
- package/skills/ti-howtos/references/media-apis.md +103 -223
- package/skills/ti-howtos/references/notification-services.md +86 -506
- package/skills/ti-howtos/references/remote-data-sources.md +97 -316
- package/skills/ti-howtos/references/using-modules.md +77 -133
- package/skills/ti-synthengine/SKILL.md +62 -111
- package/skills/ti-synthengine/assets/example/README.md +50 -59
- package/skills/ti-synthengine/assets/example/app.js +67 -65
- package/skills/ti-synthengine/assets/example/lib/sequenceOwner.js +39 -40
- package/skills/ti-synthengine/assets/example/lib/soundPreset.js +34 -0
- package/skills/ti-synthengine/assets/index.d.ts +122 -2
- package/skills/ti-synthengine/references/advanced-examples.md +4 -4
- package/skills/ti-synthengine/references/api.md +40 -18
- package/skills/ti-synthengine/references/audio-engine.md +15 -57
- package/skills/ti-synthengine/references/examples.md +63 -6
- package/skills/ti-synthengine/references/guide.md +61 -57
- package/skills/ti-synthengine/references/instruments-and-effects.md +15 -15
- package/skills/ti-synthengine/references/native-variation.md +53 -14
- package/skills/ti-synthengine/references/recipes-interaction.md +25 -20
- package/skills/ti-synthengine/references/recipes.md +19 -16
- package/skills/ti-synthengine/references/recommendations.md +12 -12
- package/skills/ti-synthengine/references/sound-api.md +197 -0
- package/skills/ti-synthengine/references/sound-design.md +7 -7
- package/skills/ti-synthengine/references/source-notes.md +62 -172
- package/skills/ti-synthengine/references/troubleshooting.md +17 -19
- package/skills/ti-synthengine/references/upgrade-2.0.0.md +40 -0
- package/skills/ti-ui/SKILL.md +28 -143
- package/skills/ti-ui/references/icons-and-splash-screens.md +74 -403
- package/skills/ti-ui/references/layouts-and-positioning.md +175 -402
- package/skills/ti-ui/references/listviews-and-performance.md +100 -703
- package/skills/ti-ui/references/platform-conventions.md +180 -0
- package/skills/ti-ui/references/user-interface.md +43 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +0 -102
- package/skills/alloy-howtos/references/custom_tags.md +0 -148
- package/skills/ti-guides/references/coding-best-practices.md +0 -149
- package/skills/ti-guides/references/javascript-primer.md +0 -414
- package/skills/ti-guides/references/reserved-words.md +0 -36
- package/skills/ti-guides/references/style-and-conventions.md +0 -103
- package/skills/ti-howtos/references/android-platform-deep-dives.md +0 -624
- package/skills/ti-howtos/references/automation-fastlane-appium.md +0 -96
- package/skills/ti-howtos/references/buffer-codec-streams.md +0 -162
- package/skills/ti-howtos/references/google-maps-v2.md +0 -172
- package/skills/ti-howtos/references/ios-map-kit.md +0 -149
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +0 -611
- package/skills/ti-howtos/references/tutorials.md +0 -565
- package/skills/ti-howtos/references/web-content-integration.md +0 -287
- package/skills/ti-howtos/references/webpack-build-pipeline.md +0 -124
- package/skills/ti-synthengine/references/android-sim80-correction-evidence.zip +0 -0
- package/skills/ti-synthengine/references/android-sim80-correction.json +0 -162
- package/skills/ti-synthengine/references/audio-pipeline-validation.md +0 -19
- package/skills/ti-synthengine/references/bypass-physical-recheck-evidence.zip +0 -0
- package/skills/ti-synthengine/references/frontier-android-evidence.zip +0 -0
- package/skills/ti-synthengine/references/frontier-ipad-evidence.zip +0 -0
- package/skills/ti-synthengine/references/frontier-physical-validation.json +0 -1918
- package/skills/ti-synthengine/references/native-tone-repetition-validation.md +0 -59
- package/skills/ti-synthengine/references/native-variation-proposal.md +0 -182
- package/skills/ti-synthengine/references/native-variation-validation.md +0 -63
- package/skills/ti-synthengine/references/performance-review-evidence.zip +0 -0
- package/skills/ti-synthengine/references/performance-review.json +0 -1146
- package/skills/ti-synthengine/references/physical-validation.json +0 -1457
- package/skills/ti-synthengine/references/source-snapshot.json +0 -542
- package/skills/ti-synthengine/references/stats-performance.json +0 -2992
- package/skills/ti-synthengine/references/stats-performance.md +0 -82
- package/skills/ti-synthengine/references/studio-validation.json +0 -6202
- package/skills/ti-synthengine/references/unified-bypass-performance.json +0 -22425
- package/skills/ti-synthengine/references/unified-validation.json +0 -314
- package/skills/ti-ui/references/accessibility-deep-dive.md +0 -288
- package/skills/ti-ui/references/animation-and-matrices.md +0 -569
- package/skills/ti-ui/references/application-structures.md +0 -626
- package/skills/ti-ui/references/custom-fonts-styling.md +0 -549
- package/skills/ti-ui/references/event-handling.md +0 -401
- package/skills/ti-ui/references/gestures.md +0 -448
- package/skills/ti-ui/references/orientation.md +0 -374
- package/skills/ti-ui/references/platform-ui-android.md +0 -727
- package/skills/ti-ui/references/platform-ui-ios.md +0 -576
- package/skills/ti-ui/references/scrolling-views.md +0 -288
- package/skills/ti-ui/references/tableviews.md +0 -542
|
@@ -1,479 +1,83 @@
|
|
|
1
|
-
# Hyperloop
|
|
1
|
+
# Hyperloop
|
|
2
2
|
|
|
3
|
-
Hyperloop lets you access native APIs (iOS Objective-C/Swift and Android Java/Kotlin) directly from JavaScript. It ships with the Titanium SDK and works as a native module.
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
Hyperloop lets JavaScript call native classes directly. Instead of writing a
|
|
5
|
+
module to wrap `UIImpactFeedbackGenerator`, you require it and use it.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- [3. Framework namespace conventions](#3-framework-namespace-conventions)
|
|
11
|
-
- [4. iOS (Objective-C)](#4-ios-objective-c)
|
|
12
|
-
- [5. iOS: creating custom classes](#5-ios-creating-custom-classes)
|
|
13
|
-
- [6. iOS: CocoaPods support](#6-ios-cocoapods-support)
|
|
14
|
-
- [7. iOS: Swift support](#7-ios-swift-support)
|
|
15
|
-
- [8. iOS: XIB and Storyboards](#8-ios-xib-and-storyboards)
|
|
16
|
-
- [9. iOS: customizing the Xcode build](#9-ios-customizing-the-xcode-build)
|
|
17
|
-
- [10. Android (Java)](#10-android-java)
|
|
18
|
-
- [11. Android: native XML layouts](#11-android-native-xml-layouts)
|
|
19
|
-
- [12. Android: third-party libraries](#12-android-third-party-libraries)
|
|
20
|
-
- [13. Debugging Hyperloop](#13-debugging-hyperloop)
|
|
21
|
-
- [14. Performance tips](#14-performance-tips)
|
|
22
|
-
- [15. Sample projects](#15-sample-projects)
|
|
7
|
+
```js
|
|
8
|
+
const UIImpactFeedbackGenerator = require('UIKit/UIImpactFeedbackGenerator');
|
|
23
9
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## 1. Requirements
|
|
27
|
-
|
|
28
|
-
- Titanium SDK: 9.0.0+
|
|
29
|
-
- Titanium CLI: 7.0.0+
|
|
30
|
-
- Alloy (optional): 1.8.0+
|
|
31
|
-
- CocoaPods (optional, iOS only): 1.0.0+
|
|
32
|
-
- Xcode location: must be at `/Applications/Xcode.app`. Hyperloop uses a bundled Xcode library to inspect native APIs. If Xcode is in a non-default location while another installation exists in the default folder, metadata errors can occur.
|
|
33
|
-
|
|
34
|
-
## 2. Enabling Hyperloop
|
|
35
|
-
|
|
36
|
-
Add the Hyperloop module to your `tiapp.xml`:
|
|
37
|
-
|
|
38
|
-
```xml
|
|
39
|
-
<modules>
|
|
40
|
-
<module>hyperloop</module>
|
|
41
|
-
</modules>
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
The `run-on-main-thread` property should already be in `tiapp.xml` by default:
|
|
45
|
-
```xml
|
|
46
|
-
<property name="run-on-main-thread" type="bool">true</property>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Do not name your app "Hyperloop" in `tiapp.xml`. It is a reserved word and will cause build failures.
|
|
50
|
-
|
|
51
|
-
## 3. Framework namespace conventions
|
|
52
|
-
|
|
53
|
-
Each platform uses different `require()` conventions.
|
|
54
|
-
|
|
55
|
-
iOS: use `Framework/Class` with a forward slash:
|
|
56
|
-
```javascript
|
|
57
|
-
const UIView = require('UIKit/UIView');
|
|
58
|
-
const NSBundle = require('Foundation/NSBundle');
|
|
59
|
-
const UIColor = require('UIKit/UIColor');
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Android: use the full Java package with dots:
|
|
63
|
-
```javascript
|
|
64
|
-
const View = require('android.view.View');
|
|
65
|
-
const Activity = require('android.app.Activity');
|
|
66
|
-
const Context = require('android.content.Context');
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## 4. iOS (Objective-C)
|
|
70
|
-
|
|
71
|
-
### Instantiation: `new` vs `alloc().init()`
|
|
72
|
-
|
|
73
|
-
- `new Class()` is equivalent to `alloc().init()`. It only calls the default initializer (`init`).
|
|
74
|
-
- `Class.alloc().initWith*()` is for special initializers that take arguments.
|
|
75
|
-
|
|
76
|
-
```javascript
|
|
77
|
-
const UIView = require('UIKit/UIView');
|
|
78
|
-
|
|
79
|
-
// Default initializer (both are equivalent)
|
|
80
|
-
const view1 = new UIView();
|
|
81
|
-
const view2 = UIView.alloc().init();
|
|
82
|
-
|
|
83
|
-
// Special initializer with arguments
|
|
84
|
-
const CGRectMake = require('CoreGraphics').CGRectMake;
|
|
85
|
-
const view3 = UIView.alloc().initWithFrame(CGRectMake(0, 0, 100, 100));
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Named methods (selector concatenation)
|
|
89
|
-
|
|
90
|
-
Selectors with multiple parameters are camel-cased and colons are removed. Arguments are passed in the same order as in Objective-C.
|
|
91
|
-
|
|
92
|
-
Selector `addAttribute:value:range:` becomes `addAttributeValueRange(attr, val, range)`.
|
|
93
|
-
|
|
94
|
-
```javascript
|
|
95
|
-
// Objective-C: [myView insertSubview:anotherView atIndex:0]
|
|
96
|
-
myView.insertSubviewAtIndex(anotherView, 0);
|
|
97
|
-
|
|
98
|
-
// Objective-C: [UIView animateWithDuration:1.0 animations:^{} completion:^(BOOL){}]
|
|
99
|
-
UIView.animateWithDurationAnimationsCompletion(1.0, () => {
|
|
100
|
-
view.layer.opacity = 0.0;
|
|
101
|
-
}, (finished) => {
|
|
102
|
-
// Animation completed
|
|
103
|
-
});
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Properties
|
|
107
|
-
|
|
108
|
-
Objective-C properties map to JavaScript property accessors. Auto-generated setters are also available:
|
|
109
|
-
```javascript
|
|
110
|
-
view.backgroundColor = UIColor.redColor;
|
|
111
|
-
// or
|
|
112
|
-
view.setBackgroundColor(UIColor.redColor);
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Casting
|
|
116
|
-
|
|
117
|
-
Use `Class.cast(object)` to convert a generic return type (`NSObject` / `id`) or a Titanium proxy to a native view:
|
|
118
|
-
```javascript
|
|
119
|
-
const UIView = require('UIKit/UIView');
|
|
120
|
-
|
|
121
|
-
// Cast a generic object
|
|
122
|
-
const view = UIView.cast(someObject);
|
|
123
|
-
|
|
124
|
-
// Cast a Titanium view to its native equivalent
|
|
125
|
-
const tiView = Ti.UI.createView({ backgroundColor: 'red' });
|
|
126
|
-
const nativeView = UIView.cast(tiView);
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
Be careful with casting. Casting to the wrong type can crash.
|
|
130
|
-
|
|
131
|
-
### Blocks
|
|
132
|
-
|
|
133
|
-
Blocks are translated to JavaScript callback functions:
|
|
134
|
-
```javascript
|
|
135
|
-
const UIView = require('UIKit/UIView');
|
|
136
|
-
|
|
137
|
-
UIView.animateWithDurationAnimationsCompletion(1.0, () => {
|
|
138
|
-
view.layer.opacity = 0.0;
|
|
139
|
-
}, (done) => {
|
|
140
|
-
// Animation completed
|
|
141
|
-
});
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### Constants, enumerations, and functions
|
|
145
|
-
|
|
146
|
-
Framework-level constants and enums are accessed by requiring the framework itself:
|
|
147
|
-
```javascript
|
|
148
|
-
const UIKit = require('UIKit');
|
|
149
|
-
const unspecified = UIKit.UISemanticContentAttributeUnspecified;
|
|
150
|
-
view.semanticContentAttribute = unspecified;
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### TiApp utility class
|
|
154
|
-
|
|
155
|
-
Access Titanium's app instance for the app delegate, key window, and app-level properties:
|
|
156
|
-
```javascript
|
|
157
|
-
const TiApp = require('TiApp/TiApp');
|
|
158
|
-
const app = TiApp.app();
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
## 5. iOS: creating custom classes
|
|
162
|
-
|
|
163
|
-
Use `Hyperloop.defineClass()` to create Objective-C classes at runtime:
|
|
164
|
-
|
|
165
|
-
```javascript
|
|
166
|
-
// defineClass(className, superClass, protocolsArray)
|
|
167
|
-
const MyView = Hyperloop.defineClass('MyView', 'UIView', ['UIAppearance']);
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
Add methods with `addMethod()`:
|
|
171
|
-
```javascript
|
|
172
|
-
MyView.addMethod({
|
|
173
|
-
selector: 'drawRect:',
|
|
174
|
-
instance: true,
|
|
175
|
-
arguments: ['CGRect'],
|
|
176
|
-
callback: function(rect) {
|
|
177
|
-
// Called when drawRect: is invoked
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
Methods with multiple arguments and return types:
|
|
183
|
-
```javascript
|
|
184
|
-
MyView.addMethod({
|
|
185
|
-
selector: 'foo:bar:hello:',
|
|
186
|
-
instance: true,
|
|
187
|
-
returnType: 'void',
|
|
188
|
-
arguments: ['int', 'float', 'id'],
|
|
189
|
-
callback: function(a, b, c) {
|
|
190
|
-
// Invoked when the method is called
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
`addMethod` properties:
|
|
196
|
-
- `selector`: Objective-C selector string
|
|
197
|
-
- `instance`: `true` for instance methods, `false` for class methods
|
|
198
|
-
- `arguments`: array or string of argument types (Objective-C encoding types or general types like `float`, `int`, `id`)
|
|
199
|
-
- `returnType`: string return type (omit for `void`)
|
|
200
|
-
- `callback`: JavaScript implementation
|
|
201
|
-
|
|
202
|
-
Instantiate the custom class normally:
|
|
203
|
-
```javascript
|
|
204
|
-
const myView = new MyView();
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## 6. iOS: CocoaPods support
|
|
208
|
-
|
|
209
|
-
### Installation
|
|
210
|
-
|
|
211
|
-
Install CocoaPods if needed:
|
|
212
|
-
```bash
|
|
213
|
-
sudo gem install cocoapods
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Podfile configuration
|
|
217
|
-
|
|
218
|
-
Create a `Podfile` in your Titanium project root:
|
|
219
|
-
```ruby
|
|
220
|
-
# Required for CocoaPods 1.x
|
|
221
|
-
install! 'cocoapods',
|
|
222
|
-
:integrate_targets => false
|
|
223
|
-
|
|
224
|
-
platform :ios, '12.0'
|
|
225
|
-
target 'YourProjectName' do
|
|
226
|
-
pod 'SomeLibrary'
|
|
227
|
-
end
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
Replace `YourProjectName` with your Titanium project name.
|
|
231
|
-
|
|
232
|
-
### Using the pod
|
|
233
|
-
|
|
234
|
-
```javascript
|
|
235
|
-
const JBBarChartView = require('JBChartView/JBBarChartView');
|
|
236
|
-
const chart = new JBBarChartView();
|
|
237
|
-
chart.minimumValue = 1;
|
|
238
|
-
chart.maximumValue = 100;
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Bitcode handling for Ad Hoc builds
|
|
242
|
-
|
|
243
|
-
If your build fails due to mixed Bitcode frameworks, disable Bitcode in your Podfile:
|
|
244
|
-
```ruby
|
|
245
|
-
post_install do |installer|
|
|
246
|
-
installer.pods_project.targets.each do |target|
|
|
247
|
-
target.build_configurations.each do |config|
|
|
248
|
-
config.build_settings['ENABLE_BITCODE'] = 'NO'
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
### Custom frameworks (without CocoaPods)
|
|
255
|
-
|
|
256
|
-
Drop native iOS frameworks (static or dynamic) into `app/platform/ios` (Alloy) or `platform/ios` (Classic). They will be detected and linked.
|
|
257
|
-
|
|
258
|
-
## 7. iOS: Swift support
|
|
259
|
-
|
|
260
|
-
Hyperloop supports Swift classes alongside Objective-C:
|
|
261
|
-
- Swift and Objective-C classes can be mixed in the same app
|
|
262
|
-
- Use the same `require()` syntax for Swift classes
|
|
263
|
-
- For Swift frameworks via CocoaPods, use the `use_frameworks!` flag in your Podfile
|
|
264
|
-
|
|
265
|
-
## 8. iOS: XIB and Storyboards
|
|
266
|
-
|
|
267
|
-
XIB files and Storyboards must be loaded programmatically. Place them in `app/assets/iphone` (Alloy) or `Resources/iphone` (Classic) and they will be compiled automatically.
|
|
268
|
-
|
|
269
|
-
```javascript
|
|
270
|
-
const NSBundle = require('Foundation/NSBundle');
|
|
271
|
-
const UINib = require('UIKit/UINib');
|
|
272
|
-
|
|
273
|
-
const nib = UINib.nibWithNibNameBundle('MyView', NSBundle.mainBundle);
|
|
274
|
-
const objects = nib.instantiateWithOwnerOptions(null, null);
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
The following resources are compiled automatically: `*.storyboard`, `*.xcdatamodel`, `*.xcdatamodeld`, `*.xcmappingmodel`, `*.xib`.
|
|
278
|
-
|
|
279
|
-
## 9. iOS: customizing the Xcode build
|
|
280
|
-
|
|
281
|
-
> **⚠️ Legacy: `appc.js`**
|
|
282
|
-
> The `appc.js` file was an Appcelerator/AMPLIFY Platform hook. It is no longer supported. For modern Titanium projects, use `tiapp.xml` or native Xcode project settings for build customization.
|
|
283
|
-
|
|
284
|
-
For historical reference, `appc.js` at the project root passed custom flags to `xcodebuild`:
|
|
285
|
-
```javascript
|
|
286
|
-
module.exports = {
|
|
287
|
-
hyperloop: {
|
|
288
|
-
ios: {
|
|
289
|
-
xcodebuild: {
|
|
290
|
-
flags: {
|
|
291
|
-
GCC_PREPROCESSOR_DEFINITIONS: 'foo=bar'
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
## 10. Android (Java)
|
|
300
|
-
|
|
301
|
-
### Activity context
|
|
302
|
-
|
|
303
|
-
Most Android view constructors require an Activity context:
|
|
304
|
-
```javascript
|
|
305
|
-
const Activity = require('android.app.Activity');
|
|
306
|
-
const activity = new Activity(Ti.Android.currentActivity);
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
### Methods and fields
|
|
310
|
-
|
|
311
|
-
Java methods map to JavaScript functions. Java fields map to JavaScript property accessors. Static methods and constants are attached to the class type:
|
|
312
|
-
```javascript
|
|
313
|
-
const View = require('android.view.View');
|
|
314
|
-
const generatedId = View.generateViewId();
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
### Method overloading
|
|
318
|
-
|
|
319
|
-
Hyperloop selects the matching overload based on parameter types. It is slightly more liberal with numeric primitives because JavaScript numbers are all `Number`.
|
|
320
|
-
|
|
321
|
-
### Casting
|
|
322
|
-
|
|
323
|
-
Pass the object to the constructor of the target type:
|
|
324
|
-
```javascript
|
|
325
|
-
const View = require('android.view.View');
|
|
326
|
-
|
|
327
|
-
// Cast a generic Object to a View
|
|
328
|
-
const view = new View(someObject);
|
|
329
|
-
|
|
330
|
-
// Cast a Titanium view to native
|
|
331
|
-
const tiView = Ti.UI.createView({ backgroundColor: 'red' });
|
|
332
|
-
const nativeView = new View(tiView);
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### Interfaces
|
|
336
|
-
|
|
337
|
-
Implement Java interfaces by passing a JavaScript object with matching method names:
|
|
338
|
-
```javascript
|
|
339
|
-
const OnTouchListener = require('android.view.View.OnTouchListener');
|
|
340
|
-
const listener = new OnTouchListener({
|
|
341
|
-
onTouch: (v, event) => {
|
|
342
|
-
// Handle touch
|
|
343
|
-
return true;
|
|
344
|
-
}
|
|
345
|
-
});
|
|
10
|
+
const generator = UIImpactFeedbackGenerator.alloc().init();
|
|
11
|
+
generator.impactOccurred();
|
|
346
12
|
```
|
|
347
13
|
|
|
348
|
-
|
|
14
|
+
```js
|
|
15
|
+
const Toast = require('android.widget.Toast');
|
|
16
|
+
const Activity = Ti.Android.currentActivity;
|
|
349
17
|
|
|
350
|
-
|
|
351
|
-
```javascript
|
|
352
|
-
const Activity = require('android.app.Activity');
|
|
353
|
-
const View = require('android.view.View');
|
|
354
|
-
const activity = new Activity(Ti.Android.currentActivity);
|
|
355
|
-
|
|
356
|
-
const MyView = View.extend({
|
|
357
|
-
onDraw: function(canvas) {
|
|
358
|
-
this.super.onDraw(canvas);
|
|
359
|
-
// Custom drawing implementation
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
const customView = new MyView(activity);
|
|
18
|
+
Toast.makeText(Activity, 'Saved', Toast.LENGTH_SHORT).show();
|
|
363
19
|
```
|
|
364
20
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
### Creating the layout
|
|
21
|
+
It is a module, maintained by TiDev, and still current: 8.0.1 is the release
|
|
22
|
+
against SDK 13.4.
|
|
368
23
|
|
|
369
|
-
|
|
24
|
+
## Install
|
|
370
25
|
|
|
371
|
-
Example `main_content.xml`:
|
|
372
26
|
```xml
|
|
373
|
-
<
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
android:layout_width="match_parent"
|
|
378
|
-
android:layout_height="match_parent">
|
|
379
|
-
|
|
380
|
-
<ListView
|
|
381
|
-
android:id="@+id/lvToDoList"
|
|
382
|
-
android:layout_width="match_parent"
|
|
383
|
-
android:layout_height="match_parent" />
|
|
384
|
-
|
|
385
|
-
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
386
|
-
android:layout_width="wrap_content"
|
|
387
|
-
android:layout_height="wrap_content"
|
|
388
|
-
android:layout_gravity="bottom|right"
|
|
389
|
-
android:layout_margin="16dp" />
|
|
390
|
-
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
### Inflating the layout
|
|
394
|
-
|
|
395
|
-
```javascript
|
|
396
|
-
const Activity = require('android.app.Activity');
|
|
397
|
-
const Context = require('android.content.Context');
|
|
398
|
-
const Inflater = require('android.view.LayoutInflater');
|
|
399
|
-
|
|
400
|
-
const activity = new Activity(Ti.Android.currentActivity);
|
|
401
|
-
const inflater = Inflater.cast(
|
|
402
|
-
activity.getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)
|
|
403
|
-
);
|
|
404
|
-
|
|
405
|
-
// getIdentifier(name, defType, defPackage) retrieves the R.layout.* ID
|
|
406
|
-
const resId = activity.getResources().getIdentifier('main_content', 'layout', activity.getPackageName());
|
|
407
|
-
const view = inflater.inflate(resId, null);
|
|
408
|
-
|
|
409
|
-
// Add to a Titanium view
|
|
410
|
-
$.myView.add(view);
|
|
27
|
+
<modules>
|
|
28
|
+
<module platform="android">hyperloop</module>
|
|
29
|
+
<module platform="iphone">hyperloop</module>
|
|
30
|
+
</modules>
|
|
411
31
|
```
|
|
412
32
|
|
|
413
|
-
|
|
33
|
+
The module is unpacked like any other - see
|
|
34
|
+
[using modules](https://titaniumsdk.com/docs/build/modules).
|
|
414
35
|
|
|
415
|
-
##
|
|
36
|
+
## How the require works
|
|
416
37
|
|
|
417
|
-
|
|
38
|
+
The path is the native type's own name.
|
|
418
39
|
|
|
419
|
-
|
|
40
|
+
| Platform | Form | Example |
|
|
41
|
+
| -------- | --------------------- | --------------------------------- |
|
|
42
|
+
| iOS | `Framework/Class` | `require('UIKit/UIView')` |
|
|
43
|
+
| Android | Fully-qualified class | `require('android.widget.Toast')` |
|
|
420
44
|
|
|
421
|
-
|
|
45
|
+
Hyperloop generates a JavaScript wrapper for each type you require, at build
|
|
46
|
+
time, by reading the platform's own metadata. That is why a type you have not
|
|
47
|
+
required costs nothing.
|
|
422
48
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
```groovy
|
|
426
|
-
dependencies {
|
|
427
|
-
implementation 'com.google.android.material:material:1.1.0'
|
|
428
|
-
}
|
|
429
|
-
```
|
|
49
|
+
## Hyperloop or a module
|
|
430
50
|
|
|
431
|
-
|
|
51
|
+
**Hyperloop** for a handful of calls, for something a single app needs, and for
|
|
52
|
+
trying an API out. No native toolchain knowledge and no separate build.
|
|
432
53
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
54
|
+
**A module** for something several apps need, for anything with real native
|
|
55
|
+
logic behind it, and when you want to ship a versioned artifact. See
|
|
56
|
+
[native modules](https://titaniumsdk.com/docs/extend/modules).
|
|
436
57
|
|
|
437
|
-
|
|
58
|
+
The wrong choice in one direction is a module for three lines. In the other, it
|
|
59
|
+
is the same Hyperloop code pasted into four apps.
|
|
438
60
|
|
|
439
|
-
|
|
440
|
-
// After adding the AAR to app/platform/android/
|
|
441
|
-
const Activity = require('android.app.Activity');
|
|
442
|
-
const ParkedTextView = require('com.goka.parkedtextview.ParkedTextView');
|
|
61
|
+
## What it costs
|
|
443
62
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
parkedView.setParkedText('.slack.com');
|
|
447
|
-
parkedView.setHintText('your-team');
|
|
448
|
-
|
|
449
|
-
// Listen to events via interfaces
|
|
450
|
-
const TextWatcher = require('android.text.TextWatcher');
|
|
451
|
-
const watcher = new TextWatcher({
|
|
452
|
-
onTextChanged: () => { console.log('Changed'); },
|
|
453
|
-
afterTextChanged: (s) => { console.log('After:', s); },
|
|
454
|
-
beforeTextChanged: () => { console.log('Before'); }
|
|
455
|
-
});
|
|
456
|
-
parkedView.addTextChangedListener(watcher);
|
|
457
|
-
|
|
458
|
-
$.myView.add(parkedView);
|
|
459
|
-
```
|
|
63
|
+
**Build time.** Hyperloop scans your JavaScript for requires and generates
|
|
64
|
+
wrappers for each. A build with many is measurably slower.
|
|
460
65
|
|
|
461
|
-
|
|
66
|
+
**Every call crosses the bridge.** Native code called in a loop from JavaScript
|
|
67
|
+
pays per iteration. Keep native work on the native side.
|
|
462
68
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
- No source maps are available for processed Alloy controllers
|
|
69
|
+
**You are using the platform API directly**, so there is no cross-platform
|
|
70
|
+
shape and no Titanium safety net. Guard with `OS_IOS` and `OS_ANDROID`, or
|
|
71
|
+
`Ti.Platform.osname`.
|
|
467
72
|
|
|
468
|
-
|
|
73
|
+
**The API is the platform's**, so its documentation is Apple's and Google's.
|
|
74
|
+
Titanium's reference does not describe it.
|
|
469
75
|
|
|
470
|
-
|
|
471
|
-
- Use it for specialized APIs: custom UI components, hardware access not covered by modules, or native third-party library integration.
|
|
472
|
-
- Existing Titanium modules (Java for Android, Objective-C for iOS) continue to be supported alongside Hyperloop.
|
|
76
|
+
## Next
|
|
473
77
|
|
|
474
|
-
|
|
78
|
+
[CLI plugins](https://titaniumsdk.com/docs/extend/cli-plugins) is the other extension point: changing
|
|
79
|
+
the build rather than the app.
|
|
475
80
|
|
|
476
|
-
|
|
81
|
+
## Platform guards in Classic and Alloy
|
|
477
82
|
|
|
478
|
-
-
|
|
479
|
-
- Community modules: https://github.com/hyperloop-modules (JavaScript wrappers around native APIs such as Speech, Mapbox, Snackbar)
|
|
83
|
+
Use Alloy compile-time constants only in Alloy source. In Classic use `Ti.Platform.osname` or a supported platform directory; otherwise `OS_IOS`/`OS_ANDROID` are undefined. Native method availability is controlled by the installed OS/framework, so check platform documentation and guard optional APIs. SDK 14-only changes remain outside this released baseline.
|