makepad / makepad

Makepad is a creative software development platform for Rust that compiles to wasm/webGL, osx/metal, windows/dx11 linux/opengl
http://makepad.dev/
MIT License
4.97k stars 235 forks source link

iOS Simulator: Resources cannot be found #413

Open joulei opened 4 months ago

joulei commented 4 months ago

When running Makepad Apps in the Xcode Simulator, none of the resources can be found:

draw/src/font_atlas.rs:187:17 - get_font_by_path - 
makepad/makepad_widgets/resources/GoNotoKurrent-Regular.ttf File open failed
widgets/src/image_cache.rs:209:21 - 
load_image_dep_by_path: Resource not found makepad/makepad_example_news_feed/resources/profile_1.jpg File open failed
tremolo commented 2 months ago

Apparently the required resources are not properly bundled for the examples. This is not a real solution yet, but as a quick way to test the examples you can manually copy them to the app directory

After doing that you can just start the app again as documented like cargo makepad apple ios --org=my.test --app=makepad-example-ironfish run-sim -p makepad-example-ironfish --release or by clicking on it in the emulator.

A real solution would require copying the files as part of the build process and for deployment bundle it properly in the ipa file, but for a quick test it works fine If other resources are not found, just copy to the reported subdirectory in the $appdir


## copy resources for example/simple ##
orgname=my.test
appname=makepad-example-simple
# appdir=$(xcrun simctl get_app_container booted ${orgname}.${appname})
appdir=./target/makepad-apple-app/x86_64-apple-ios/release/${appname}.app
# copy widget resources, like fonts
mkdir -p ${appdir}/makepad/makepad_widgets/resources/
rsync -av ./widgets/resources/ ${appdir}/makepad/makepad_widgets/resources/

## copy resources for example/ironfish ##
orgname=my.test
appname=makepad-example-ironfish
# appdir=$(xcrun simctl get_app_container booted ${orgname}.${appname})
appdir=./target/makepad-apple-app/x86_64-apple-ios/release/${appname}.app

# copy widget resources, like fonts
mkdir -p ${appdir}/makepad/makepad_widgets/resources/
rsync -av ./widgets/resources/ ${appdir}/makepad/makepad_widgets/resources/

# copy app specific resources
mkdir -p ${appdir}/makepad/makepad_example_ironfish/resources/
rsync -av examples/ironfish/resources/  $appdir/makepad/makepad_example_ironfish/resources/
#--------------------------------------------------------------------------------------