[TIMOB-20131] iOS: Ti.UI.iOS.ApplicationShortcuts does not work on device with LiveView enabled
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2016-11-16T18:48:36.000+0000 |
Affected Version/s | Release 5.1.1 |
Fix Version/s | n/a |
Components | iOS, LiveView, Tooling |
Labels | ios, liveview |
Reporter | Jason Kneen |
Assignee | Eric Merriman |
Created | 2015-12-11T12:35:21.000+0000 |
Updated | 2017-03-27T20:46:16.000+0000 |
Description
Running the following code on device fails if liveview is enabled. The result is:
TypeError: undefined is not a function (evaluating 'Ti.UI.iOS.createApplicationShortcuts()')
Running with LiveView off works.
if (OS_IOS && Ti.UI.iOS.forceTouchSupported) {
var appShortcuts = Ti.UI.iOS.createApplicationShortcuts();
appShortcuts.addDynamicShortcut({
itemtype: "post_text",
title: "Text",
subtitle: "Tap to post text",
icon: Ti.UI.iOS.SHORTCUT_ICON_TYPE_COMPOSE,
userInfo: {
post: {
type: "text"
}
}
});
appShortcuts.addDynamicShortcut({
itemtype: "post_photo",
title: "Photo",
subtitle: "Tap to post a photo",
icon: Ti.UI.iOS.SHORTCUT_ICON_TYPE_CAPTURE_PHOTO,
userInfo: {
post: {
type: "photo"
}
}
});
appShortcuts.addDynamicShortcut({
itemtype: "post_video",
title: "Video",
subtitle: "Tap to post a video",
icon: Ti.UI.iOS.SHORTCUT_ICON_TYPE_CAPTURE_VIDEO,
userInfo: {
post: {
type: "video"
}
}
});
}
Looks like when you've enabled LiveView the define isn't set: https://github.com/appcelerator/titanium_mobile/search?utf8=✓&q=USE_TI_UIIOSAPPLICATIONSHORTCUTS We scan the code here: https://github.com/appcelerator/titanium_mobile/blob/master/node_modules/titanium-sdk/lib/jsanalyze.js#L102-L145 And set the defines here: https://github.com/appcelerator/titanium_mobile/blob/master/iphone/cli/commands/_build.js#L5440 Could it be that since LiveView replaces the app's
app.js
it doesn't find these? Then we'd need to fix this by copying in the originalapp.js
(as_app.js
) as well with LiveView enabled.[~jasonkneen] did you try with our 5.2.0.RC? I tried to reproduce here but I don't see the error.
Just pinged Jason via mail. Maybe the
<run-on-main-thread/>
flag was enabled?This happens to Ti.UI.create* apis too, i.e
Ti.UI.createWindow, Ti.UI.iOS.createNavigationWindow, Ti.UI.createLabel
Create a classic titanium app, doti build -p ios -T device --liveview
, launch the app, it fails with similar error:This seems like a SDK issue.
Thanks [~fmiao] this is a good reproducible case. The problem lies where the command call has to include the flag --deploy-type development in order for this to work, because by default, if you target device, it's --deploy-type test I'm not sure if this was by design but leaving a note here first until we decide the best approach to fixing this. Also, if you do this in studio, the flag is --deploy-type development so there won't be an issue.
So this is device-only? I know that we include [all defines](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/defines.h) when running a sim-build and generate the symbols manually for device-builds (see _build.js above). So if this issue affects all
Ti.UI
namespaces, I'm wondering how this ever worked before then.Just tested with 6.0.0.GA and I'm not able to reproduce this issue anymore. To be validated by the QE team. Thx!
Closing ticket as the issue cannot be reproduced, with reference to the above comments.