Set Image Reference to Relative Path
Sannyasin Brahmanathaswami
brahma at hindu.org
Wed Apr 6 21:57:35 EDT 2016
Jacque wrote:
It used to be that resources were copied into the same folder with the app executable. Then Apple changed the rules and disallowed resources like images and documents at that location. Instead, they had to go into a "resources" folder, separate from the executable.
--
So if I read this correctly.. we should being this now, even locally, because the standalone builder is not auto generating a resource folder and moving files designated under "copy files" into such a folder. righ?
/app source
/ myapp.livecode
/resources
img
data
scripts
otherwise it will fail? This may explain why my latest test build is not working on iPhone 9.3.1.
I looked at the bundle and there is no resources folder created automatically by the Standalone Builder I'm seeing this (where the SAB, copied the three folders I designated to the top level
/app source
/ myapp.livecode
img
data
scripts
but, I am using
function localPath
put specialFolderPath("Resources") into tPath
put "/" after tPath
return tPath
end localPath
My external behavior scripts work on desktop but not on mobile.
but the images are appearing...because we have a direct path but script only files are not being found because the iOS is looking for
/resource/scripts
So that means in the future we need to create a folder "resources" and you a relative path like this
/resources/img
tree.jpg
and also
/resources/script
scroller.livecodescript
and assign the behavior to the object in the GUI from there?
Good thing to know very early on...
On April 3, 2016 at 8:01:20 PM, J. Landman Gay (jacque at hyperactivesw.com(mailto:jacque at hyperactivesw.com)) wrote:
> Relative paths have been around for a while and are pretty much
> imperative for app distribution, since the user's filepaths won't be the
> same as your development paths.
>
> It used to be that resources were copied into the same folder with the
> app executable. Then Apple changed the rules and disallowed resources
> like images and documents at that location. Instead, they had to go into
> a "resources" folder, separate from the executable.
>
> To accomodate, LC now has a new-ish specialFolderPath("resources").
> During development it points to the same folder as the mainstack you're
> working on; after the app is built, it points to the "resources" folder
> inside the app bundle. In scripts, build file paths to
> specialFolderPath("resources") and the paths will always resolve
> correctly before and after compiling. For image references use
> "resources/imgname.png".
>
> To accomdate legacy script and image references, the LC engine
> automatically translates any relative paths and redirects them to the
> resources folder. On non-Apple systems this structure isn't strictly
> required, but since it works everywhere, it's an easy way to be
> consistent cross-platform.
More information about the use-livecode
mailing list