IOS problem with Assets

Hi!

I have a problem with the IOS build using OS X 10.11 and i need to fix it urgently!

I have the next code:

@:build(haxe.ui.toolkit.core.Macros.buildController("assets/templates/ApplicationView.xml"))
class ApplicationView extends SpriteView implements mmvc.api.IViewContainer

And it gives me the runtime error:

Assets.hx:551: [openfl.Assets] There is no String asset with an ID of "../../../../assets/templates/ApplicationView.xml"

In other platforms (windows and android) i haven’t any problems. Only with the IOS version. You can see the weird thing “…/…/…/…/”. It is the problem.

The result of CPP code:

With android or windows:
super::__construct(HX_HCSTRING("assets/templates/ApplicationView.xml","\x7c","\xeb","\xbb","\x44"));

With ios:
super::__construct(HX_HCSTRING("../../../../assets/templates/ApplicationView.xml","\x3c","\xd2","\x71","\x14"));

I don’t know why it happens. I’m stuck :frowning:

I’m using Lime 2.8.3, OpenFL 3.5.3, and legacy code (because it has HaxeUI).

Thanks in advance!

The quickest solution will be compiling application with “-verbose -clean” switch and pipe output to text file. Next, manually edit cpp file, and manually run linking stage (should be one of the last entries in piped text file).

Thanks for the answer. Here you can see the log.

I have tested Haxe 3.2.0 (binaries), and 3.3.0 nightly build with the same result. The 3.2.1 version doesn’t work with me because this issue.

Tomorrow i would try the manual process.

I forgot that edited cpp file should be recompiled also before linking.

Other option is to edit lime compile script not to recreate cpp files when running build (since You are using simulators etc, it may be easier to achieve than running manually all toolchain):
You could build te game, edit script to not update cpp files, rebuild script, edit file, rebuild game, and revert script to previous state.

You could do the following:
In file lime/version/lime/project/PlatformTarget.hx change in line 66:

if (!Reflect.hasField (metaFields.update, "ignore") && (command == "update" || command == "build" || command == "test")) {

into

if (!Reflect.hasField (metaFields.update, "ignore") && (command == "update")) {

then from folder lime/version/tools run

haxe tools.hxml

It will rebuild script. If You encounter errors, probably You need to install “lime-tools” and “format” libs with haxelib.
Then, if You are modifying App sources, run

openfl update $(Your_target) $(Your_flags)

This will regenerate cpp files.
Then, edit bad strings and run “test” or “build” commands.
Should be fine I think.

@Retard: lime-tools is old and deprecated, to rebuild, use lime rebuild tools with a development version of Lime installed :slightly_smiling:

@aWaKeNiNG: This looks like an issue with Haxe UI, it needs a Context.resolvePath call in the macro, probably. This uses all of the available Haxe classpaths, rather than looking relative to the current working directory. The directory structure is different (due to Xcode) on iOS builds, so macros need to resolve using the Haxe classpaths

Thanks @Retard. Currently, i want to search the origin of the problem and fix it.

@singmajesty: Today i have found that the problem is produced here, in lime library. I have seen that the Build.hxml file containts the -cp ../../../../ lines.

In the line 103,
Input: sources = [,Source,assets,/Users/pablomartin/Documents/workspace/sdks/HaxeToolkit/haxe/lib/lime/git/legacy]
Output: [../../../../,../../../../Source,../../../../assets,/Users/pablomartin/Documents/workspace/sdks/HaxeToolkit/haxe/lib/lime/git/legacy]

The second argument of relocatePaths function is Export/ios/JardinElena/haxe.

Tomorrow i will continue with the research.

Thanks for your help.

In this code, it may need Context.resolvePath before calling sys.FileSystem.exists

@singmajesty ah, yes, I’m trying to get familiar with building chain. Thank You for info:)

Thanks @singmajesty

Currently, sys.FileSystem.exists(c) was always false. If i add the next block before L752, then now it can enter in the if block.

#if macro
if (!sys.FileSystem.exists(c)) {
	c = haxe.macro.Context.resolvePath(c);
}
#end

But, it doesn’t help with the problem, the CPP file continues with the same path.

Now, i have change the next code and it works!!

with:

var relativePath = resourcePath;
resourcePath = resolveResource(resourcePath, Context.getClassPath());
if (sys.FileSystem.exists(resourcePath) == false) {
	Context.error("XML file not found", Context.currentPos());
}
		
var e:Expr = Context.parseInlineString("super(\"" + relativePath + "\")", Context.currentPos());

For now, i have tested in Android, Windows and IOS, and it works fine. I will create a PR to fix that.

Thanks again! :smiley:

1 Like