godotengine / godotengine/godot
Non-fatal error when launching dotnet project on iOS due to missing scripts
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.3.stable.mono.official [77dcf97d8]
### System information
Godot v4.3.stable.mono - macOS 13.7.2 - GLES3 (Compatibility) - AMD Radeon Pro 560 OpenGL Engine - Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz (8 Threads)
### Issue description
When exporting a dotnet project to iOS and selecting "Export selected scenes (and dependencies)" option, dependencies of the C# scripts are not included in the exported .pck file, which causes following errors to be printed:
```
ERROR: Cannot open file 'res://AbstractCustomResource.cs'.
at: read_all_file_utf8 (modules/mono/utils/string_utils.cpp:152)
ERROR: Failed to read file: 'res://AbstractCustomResource.cs'.
at: load_source_code (modules/mono/csharp_script.cpp:2721)
ERROR: Cannot load C# script file 'res://AbstractCustomResource.cs'.
at: load (modules/mono/csharp_script.cpp:2797)
ERROR: Failed loading resource: res://AbstractCustomResource.cs. Make sure resources have been imported by opening the project in the editor at least once.
at: _load (core/io/resource_loader.cpp:284)
ERROR: Cannot load script for type 'AssemblyNotExported.AbstractCustomResource'. Path: 'res://AbstractCustomResource.cs'.
at: void Godot.Bridge.ScriptManagerBridge.GetOrLoadOrCreateScriptForType(System.Type, Godot.NativeInterop.godot_ref*) (:0)
ERROR: Cannot open file 'res://CustomResource.cs'.
at: read_all_file_utf8 (modules/mono/utils/string_utils.cpp:152)
ERROR: Failed to read file: 'res://CustomResource.cs'.
at: load_source_code (modules/mono/csharp_script.cpp:2721)
ERROR: Cannot load C# script file 'res://CustomResource.cs'.
at: load (modules/mono/csharp_script.cpp:2797)
ERROR: Failed loading resource: res://CustomResource.cs. Make sure resources have been imported by opening the project in the editor at least once.
at: _load (core/io/resource_loader.cpp:284)
ERROR: Cannot load script for type 'AssemblyNotExported.CustomResource'. Path: 'res://CustomResource.cs'.
at: void Godot.Bridge.ScriptManagerBridge.GetOrLoadOrCreateScriptForType(System.Type, Godot.NativeInterop.godot_ref*) (:0)
ERROR: Cannot open file 'res://AbstractCustomResource.cs'.
at: read_all_file_utf8 (modules/mono/utils/string_utils.cpp:152)
ERROR: Failed to read file: 'res://AbstractCustomResource.cs'.
at: load_source_code (modules/mono/csharp_script.cpp:2721)
ERROR: Cannot load C# script file 'res://AbstractCustomResource.cs'.
at: load (modules/mono/csharp_script.cpp:2797)
ERROR: Failed loading resource: res://AbstractCustomResource.cs. Make sure resources have been imported by opening the project in the editor at least once.
at: _load (core/io/resource_loader.cpp:284)
ERROR: Cannot load script for type 'AssemblyNotExported.AbstractCustomResource'. Path: 'res://AbstractCustomResource.cs'.
at: void Godot.Bridge.ScriptManagerBridge.GetOrLoadOrCreateScriptForType(System.Type, Godot.NativeInterop.godot_ref*) (:0)
```
Note: despite the logged errors, game works as expected and logic defined in the "missing" scripts is executed correctly.
- why are the error messages logged?
- why are those files tried to be read from "res://" if they should be part of the assembly?
**Side question**: while troubleshooting this issue, i assumed that the ".dll" file should be loaded in the beginning, as described in [Opening PCK files at runtime](https://docs.godotengine.org/en/4.3/tutorials/export/exporting_pcks.html#opening-pck-files-at-runtime), however when examining the exported ".pck" file, i did not find the "ProjectName.dll" file there.
- where i can find the main project assembly in the "pck" file and do i need it?
- in future, when say when adding a DLC to the project, where i can find information on how to export a dotnet project so that the exported pack contains ".dll" file to be loaded?
### Steps to reproduce
- download MRP
- add ios export template
- export with provided export_presets.cfg
- run using xcode
- observe the errors
### Minimal reproduction project (MRP)
[assembly-not-exported.zip](https://github.com/user-attachments/files/18277523/assembly-not-exported.zip)
Contributor guide
Research direction
Reproduce the iOS export using the provided assembly-not-exported.zip project and export_presets.cfg with “Export selected scenes (and dependencies).” Start with the reported paths in modules/mono/csharp_script.cpp and modules/mono/utils/string_utils.cpp, then inspect how the project assembly and referenced scripts are packaged. Done means the export behavior and any logged errors are explained and the reported non-fatal errors no longer occur or are documented as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, ios
- Domain
- game-dev, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100