If you have a post build step that copies resources after building then while you are debugging those resources aren't available and my app fails.
Not to start an argument, but for at least my education if not that of others...
But WHY is a build phase copy "better"/"preferred" to just dragging the resource into the project via the IDE?
Doesn't the resource (image, text, script, database, whatever) end up in exactly the same place, and therefore referenced in exactly the same way?
copying them into the project may cause them to load into memory when you dont want
and once loaded you cannot unload them
resources you can load & unload by reading a picture, for instance, then eventually niling the picture
resources when copied into the app do cause your project to take longer to build because the IDE has to do extra wotk with them
not so when they are in the resources dir
and loading them all into the project can lead to some slowness when you open the project
ask anyone who has resources on drop box etc :P
I have some helper apps. These are built in an IDE script and copied into the main app.
You can't use the copy file script because the helper apps aren't always there and then you loose them in the script.
Using an IDE script for the file type icons makes saving a project and using the SVN client waayyyyyy faster.
Norman.. thanks for the explanation... but I'm still not getting it.
It was my understanding (and perhaps incorrect, but borne out by observation)
If you drag a resource into the IDE, when compiled that resource is copied into the /RESOURCE directory (which can be seen by opening the App package) ,and the App code then can reference it by "name"
If you add a copy script, doesn't that put the resource in the exact same place? I can (per Beatrix) how it might speed up SVN because the resource isn't part of the project code.
The only real difference I am seeing is
For Xojo I always drag resources into the IDE, but then I usually don't need to dereference the resource.
but for Swift its actually a combination.... You can drag the resource into the project which places it in the /Resources directory of the application, but in order to use it, you must "load" it.
You can do whatever one you like.
There are pros and cons to each approach.
If you have large resources that you dont want to retain in memory all the time I would not drag them into the IDE because the first time you use the named reference its loaded and you cannot unload it.
So several hundred large movies or pdf's suck up memory and there's nothing you can do.
Plus the amount of code you save is really trivial. Maybe 5 lines ?
For a tiny handful of resources its no big deal.
For thousands or really large ones it is.
@Dave S and that is exactly what I have been trying to ascertain
after that line @Norman P explains the Pros/Cons. to sum them up.
dragging items into the app:
I can be wrong but that is the impression I got from the thread plus my experiences. aka not an expert.
Both the mentioned solution will slow down the debugging process because they lead to extra file copy operations.
Why not do this instead:
Assuming you usually copy your resource files into a specific directory, you'd have a property that gets set to that folder in App.Open.
However, when you are debugging, set it to the folder where the original resides, like this:
#if DebugBuild f = GetFolderItem("App Resources") #else f = app.ExecutableFile.Parent.Parent // "Contents" folder f = f.Child("Resources") #endif App.ResourcesFolder = f
And then you use that App.ResourcesFolder whenever you want to access your resources folder.
I manage one project that does just that and it's a nightmare to maintain. Out of the three approaches, that would be the last one I choose.
Some problems I've personally run into with that approach:
But that's just my personal experience, you may find you like that approach.
@ThomasTempelmann Both the mentioned solution will slow down the debugging process because they lead to extra file copy operations.
Why not do this instead
You still need to copy them into your app resources when you build to finally deploy so it only saves you a bit of time at the point you debug
Even with something as huge as the IDE + all its images I never found that to be a significant hold up
the first time you use the named reference its loaded and you cannot unload it.
Still not getting the difference, but Im sure it lies in this sentence.
Drag a large image into the app.. it gets loaded and cannot be unloaded
But drag a large image into the resources , and it...
A/ -doesn't get loaded until needed? (Is that a delay waiting to happen?)
B/ -can be unloaded (How???)
@Brian OBrien If you have a post build step that copies resources after building then while you are debugging those resources aren't available and my app fails.
Would you be seeing that under Windows ?
Debug resides in a different subfolder than a normal build.
How are you accessing the resources ?