TiShadow icon indicating copy to clipboard operation
TiShadow copied to clipboard

ReferenceError: Can't find variable: Alloy

Open Astrovic opened this issue 5 years ago • 5 comments

Hi, I'm using TiShadow 2.10.1 and Ti 8.0.1.GA on iOS alloy project, but receive this error when I run. I have to add Alloy = require('alloy') to solve. It's normal?

Astrovic avatar Jul 03 '19 10:07 Astrovic

No, not normal. Once had that and needed to a clean build. I'm mostly still using 7.X so I haven't run it to it.

dbankier avatar Jul 12 '19 07:07 dbankier

OK. Obviously I did the clean of the build. I also did ts clear and ts close and restarted the server.

I also encountered another problem. From the browser (http://192.168.1.61:3000/) I no longer saw the connected devices. As soon as I opened it, only this error log appeared: Error: ENOENT: no such file or directory, stat '/Users/astrovic/.nvm/versions/node/v8.14.1/lib/node_modules/tishadow/lib/api.jsca'. But I had a backup of an old version of TiShadow in which there was the api.jsca file. So adding it manually I solved the problem

Astrovic avatar Jul 12 '19 07:07 Astrovic

I finally managed to make a reproducible example on v7.5.2.GA.

The issue occurs when you have the following in tiapp.xml:

<transpile>true</transpile>

Bizarrely, Alloy does work in some areas of the application, but not others. I managed to create a simple application that has this issue:

app/index.xml

<Alloy>
	<Window onOpen="onWinOpen">
	</Window>
</Alloy>

app/index.js

var helper = require('/helper');

$.index.open();

function onWinOpen() {
	helper.test();
};

app/lib/helper.js

exports.test = function () {
	Alloy.createController('foo').getView().open();
};

app/foo.xml

<Alloy>
	<Window backgroundColor="red">
	</Window>
</Alloy>

Running the above application gives the error:

Can't find variable: Alloy

Strangely, if index.js is like the following, it works fine:

var helper = require('/helper');

$.index.open();

function onWinOpen() {
	Alloy.createController('foo').getView().open();
};

So there is certainly an issue when transpile is set to true.

yahya-uddin avatar Jul 22 '19 13:07 yahya-uddin

Note that add var Alloy = require('alloy'); at the top of helper.js can help solve the issue, but I then find you sometimes cannot cannot access variables in Alloy.Globals.

yahya-uddin avatar Jul 22 '19 13:07 yahya-uddin

Any updates on this? I've found that this is still an issue.

yahya-uddin avatar Oct 24 '19 00:10 yahya-uddin