Helium icon indicating copy to clipboard operation
Helium copied to clipboard

Titanium UI components are ignored at compile time when loaded with Helium

Open craigmarvelley opened this issue 14 years ago • 7 comments

The docs suggest it should be possible to use Helium to create Appcelerator core components within custom component constructors, e.g.

he.register('MyView', function(args) {
    var v = he.create('View');
    var l1 = he.create('Label',{text:'logged out'});
    (snip)
    return v;
});

This works fine when using the simulator (the iPhone simulator, specifically) - because the simulator includes all core modules automatically. However when I build the application for the device, the defines.h file is missing defines for the core components - because the compiler.py file is searching for tokens in the Titanium.UI.create or Ti.UI.create mould. So if an application only creates core components using he.create(), none of those components are available in the build; obviously the application then fails to work.

I can work around this issue by only using the Titanium constructors for core components, but I think functionality like presets will be broken without either patching the complier script to pick up on custom constructors, or allowing custom constructors to be defined on a per-project basis. It'd be nice to keep things consistent, too.

craigmarvelley avatar Jan 17 '11 17:01 craigmarvelley

d'oh! You're right, of course, the build scripts do indeed look at the contents of your project and omit unused namespaces. I guess all of my Helium projects to date have also included Ti.UI default constructors. I will look into ways to address this, thanks for the report.

kwhinnery avatar Jan 17 '11 17:01 kwhinnery

I've also discovered this issue, i've made a workaround which basically involves adding all the Ti.UI.create* methods to the end of the helium.js file, when titanium compiles the project it checks all files for the presence of those methods and includes the modules based on usage, so this makes sure everything is included..

Here's a Gist showing what i've done to make it work, hopefully you can include this in future releases to help anyone else...

https://gist.github.com/823294

mattlanham avatar Feb 11 '11 23:02 mattlanham

Hi,

We've got the same issue and swanify's fix works for us. Please update this ticket if something is changed in Helium to "fix" that ;-)

aurels avatar Mar 04 '11 16:03 aurels

Recently i've been messing around with android and some of the namespaces i outlined before are not supported for Android, so the code should be adjusted to:

// Titanium doesn't like it if you done use their standard way of creating objects, // this keeps Titanium nice and happy Ti.UI.create2DMatrix(); Ti.UI.create3DMatrix(); Ti.UI.createActivityIndicator(); Ti.UI.createAlertDialog(); Ti.UI.createAnimation(); Ti.UI.createButton(); Ti.UI.createButtonBar(); Ti.UI.createEmailDialog(); Ti.UI.createImageView(); Ti.UI.createLabel(); Ti.UI.createOptionDialog(); Ti.UI.createPicker(); Ti.UI.createPickerColumn(); Ti.UI.createPickerRow(); Ti.UI.createProgressBar(); Ti.UI.createScrollView(); Ti.UI.createScrollableView(); Ti.UI.createSearchBar(); Ti.UI.createSlider(); Ti.UI.createSwitch(); Ti.UI.createTab(); Ti.UI.createTabGroup(); Ti.UI.createTableView(); Ti.UI.createTableViewRow(); Ti.UI.createTableViewSection(); Ti.UI.createTextArea(); Ti.UI.createTextField(); Ti.UI.createToolbar(); Ti.UI.createView(); Ti.UI.createWebView(); Ti.UI.createWindow(); Ti.Facebook.createLoginButton();

if(Ti.Platform.osname != "android"){ Ti.UI.createTabbedBar(); Ti.UI.createDashboardView(); Ti.UI.createDashboardItem(); Ti.UI.createCoverFlowView(); }

mattlanham avatar Mar 15 '11 16:03 mattlanham

I can't thank you guys enough for these instructions. It was painful just getting to the point of figuring out why my app was running on all emulators and the Android device, but nothing on the iPod Touch. Luckily I found that by installing a debug version on the iPod Touch, while connected to the computer and watching the verbose output scrolling in my XCode/Organizer/Device/Console (think Android DDMS output), did I finally see the relationship/connection/misbehaviour between Titanium and helium.js!

IrisHofle avatar Aug 31 '11 05:08 IrisHofle

No problem glad you got it working!

mattlanham avatar Sep 24 '11 07:09 mattlanham

Matt good work on the solution for this, saved me some pain!

cjmyles avatar Mar 20 '12 03:03 cjmyles