[TIMOB-28461] iOS: Support running LiveView with Hyperloop
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2021-07-28T15:07:40.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 10.0.1 |
Components | iOS |
Labels | build, hyperloop, iOS, liveview |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2021-05-28T23:15:32.000+0000 |
Updated | 2021-07-28T15:07:40.000+0000 |
Description
*Summary:*
Running an iOS app with LiveView will cause runtime exceptions when modifying a JS file using hyperloop.
_(This works on Android as of Titanium 9.0.0 and we'd like to do the same on iOS.)_
*Cause:*
While the app is being built, hyperloop will string replace all
require
/import
calls which reference a native Objective-C/Swift type with the hyperloop JS file which wraps that native type. This works fine for normal builds since the modified JS file is written to the app bundle. But this require
/import
string replacement does not happen with LiveView, causing the module lookup to fail.
*Recommended Solution:*
Modify the hyperloop build hook to not modify the JS source files anymore. Instead, create a bootstrap script (which is ran before the "app.js") that defines the require/import bindings between native types to the actual hyperloop JS file. The below is how Android handles it.
[generate-sources-task.js](https://github.com/appcelerator/hyperloop.next/blob/f98983db8aa19b73e2ec5458e04589cda900af2e/android/hooks/tasks/generate-sources-task.js#L208-L235)
*Limitations:*
Do the following while LiveView is running still won't be supported. The below requires a native rebuild to integrate them into the app.
* Adding libraries.
* Adding Hyperloop.defineClass()
method calls. _(Involves native code generation.)_
PR (hyperloop.next): https://github.com/appcelerator/hyperloop.next/pull/351 Also below PR fixes regression in above PR... PR (hyperloop.next): https://github.com/appcelerator/hyperloop.next/pull/355
PR (master): https://github.com/appcelerator/titanium_mobile/pull/12905