Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: Can't find variable: Alloy #559

Open
Astrovic opened this issue Jul 3, 2019 · 5 comments
Open

ReferenceError: Can't find variable: Alloy #559

Astrovic opened this issue Jul 3, 2019 · 5 comments

Comments

@Astrovic
Copy link

Astrovic commented Jul 3, 2019

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?

@dbankier
Copy link
Owner

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.

@Astrovic
Copy link
Author

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

@yahya-uddin
Copy link

yahya-uddin commented Jul 22, 2019

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
Copy link

yahya-uddin commented Jul 22, 2019

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants