I have a bunch of SVG files. Most are used as images and there are no problems with them.
But one particular SVG file I read and parse as XML.
While everything is perfectly fine while I run my project through the IDE, I have problems with that file in the exported version.
var file = FileAccess.open(file_path, FileAccess.READ) returns null
I can bypass the problem by putting this SVG-XML near the project binary in the corresponding directory.
I looked into the *.pck file itself and I see that my problematic file is mentioned there. At least its name.
I have tried some shaman dancing with
const _force_pack = preload(“res://img/world_map.svg”), experimented with export_presets.cfg
Are you sure the path is correct? It should work fine. Try printing FileAccess.get_open_error() after calling FileAccess.open() like print(error_string(FileAcess.get_open_error()) to see the error.
The .pck filesystem is case sensitive. For example, if your file name is World_map.svg then the path would be res://World_map.svg and not res://world_map.svg
If your filesystem is case insensitive (Windows, macOS) it will work in the editor and it will also work if you move the file to the exported project.
I’m on Windows right now but I also tested it on Linux. I exported the project with the default Linux and Windows preset.
Did you change the Import settings of that specific svg file for any reason? The only way I can get it to fail is to change its Import As to Skip File (not exported) which… well… you can guess why it fails then
Hmm… Can you, please, try to move that *.svg in /img dir? To get res://img/whatever_name.svg path? Yes, it sounds stupid, I know, but please. All this situation sounds stupid
Maybe the content of the SVG is important somehow too? Maybe the engine is trying to be cleverer than it is?
Moved it to res://img/icon.svg and changed the path when opening it in code and it still works fine (only tested on Windows)
I’m not sure. You could try to reproduce the issue in a new project using the same svg file.
If it still fails on a new project you could try opening an issue in the issue tracker giving as much info as possible and also attaching that new project.