Text files copied via a build step are getting corrupted

Feedback Case Number: 66769.

I’ve just open sourced a complicated app (Better Code Editor) and it was during testing this that I stumbled upon a nasty bug that I think relates to copying files into an app’s resources folder during a build step when cross-compiling. This is on Xojo 2021 Release 3.

I develop on a Mac (macOS Monterey).

In the demo app, I have several theme files which are text files containing JSON. When the app is built (both debug and production), these files are copied into the app’s Resources Folder under a Themes subdirectory. The app then loads these files and parses them using the built-in ParseJSON() method.

When debugging the apps from macOS to Windows or Linux they work fine. When debugging on macOS it’s fine. When running the built app within macOS it’s fine. The issue occurs if I build for Windows or Linux (64-bit) from macOS. If I run one of the built apps on either Windows or Linux, the app crashes with an UnhandledException. I caught the exception and it seems to be an InvalidJSONException - something about an “invalid char”. I dumped the contents of the theme file to disk upon the exception to see what was happening.

Instead of seeing JSON, I see this:

aMac OS X        	2∞‚ATTR‚††com.apple.lastuseddate#PSw`ùaπˆ6This resource fork intentionally left blank   ˇˇ

I think the IDE is messing something when copying the files into the built app.

If I build the project on a Windows PC it works fine.

Seems like “Build steps are messy when cross-compiling from macOS”.

Did you provide a sample privately?

1 Like

Better, can you replicate it in a simple public sample?

Making a bug report without example will get the bug report closed after 10 days anyways.

1 Like

I linked to my open source repository demonstrating it.

1 Like

Correct but it is not a simple sample that they can just download from the FC and build for Windows from Mac and reproduce the problem. If it takes longer for the staff to test it will take longer to reproduce and fix.

Chances are it will be ignored. It needs plugins and is not reproducible with easy steps, showing the isolated case.

I do the same thing with XML files and have not seen any corruption using 2021r2.1 building on Mac (Mojave) and running the built 64-bit app under Windows.

Unfortunately it looks like your app cannot be compiled with 2021r2.1 so you’ve painted yourself into a bit of a corner debugging-wise.

Yep. Trust me, I did not want to paint myself into a corner but it seemed the only practical way forwards given the crazy new UI control hierarchy introduced in 2021r3.

Life on the bleeding edge…

2 Likes