How Structure External Files

Hi All,

The app I am converting to Xojo has a bunch of folders in a Resources folder. A compiled app maintains the same structure.

I don’t think Xojo auto-mirrors the folder structure during the build stage. So how best to structure all the folders that a Xojo app will need? Best resources to study?

Appreciate,
John…

i would try a build step with subdirectory
or if the ressources are app neutral then create all the folders at start somewhere with FolderItem class.
everything the user can edit should not be in the app folder.

Hi Markus,

I saw that in the docs on build, so need to play with it a bit. Ideally, all things I need for the app, like icons, images, files, etc., are in a single resource file (both macOS and WIndows). Then how to get it to copy into the built app?

Thanks,
John…

using a script, so they are in the Resource folder at run time.

Hi Emile,

Not familiar with Xojo “scripting” yet. Got be a simple thing to copy from and to I would think. Are there examples anywhere?

Thanks,
John…

The easiest way to start is to use a copyfiles script step.

You can do with the with Insert → Build Step → Copy Files. Drag the files into the main part of the window. Then select if you want to have the files always (both), debug, build or not at all. Select Resources Folder as Destination.

I use this for files which are always there. For more complicated things I use scripts.

Hi Beatrix,

Ahh, something new to learn.

Thank you!

John…

1 Like

icons and images i dropped in the project tree contens. you can then use them by name.
i copied only the app manual pdf via copyfiles build step.
(Supports Hi-DPI is disabled in this project)

Hi Markus,

Very helpful!

I’m also accessing a dynLib (Mac) and DLL (Windows) which are placed next to the project. I don’t see it anywhere within the built app folder hierarchy. So I am assuming that it is still looking in the raw project folder?

What would you do for the dynamic library?

Thanks much,
John…

The dylib needs to go into the Frameworks folder:

I only build for macOS so that the architecture doesn’t matter. You would need macOS for the dylib and Windows for the DLL.

1 Like

Hi Beatrix,

Thank you.

The macOS screen capture is cut off. But I think you mean in the macOS Build Settings (for the dynLib) and similar under Windows build for the dll.

Appreciate,
John…

Hi all,

What if I have a file that I need to access. It’s a dynamic library. Apparently, the current path is:

/usr/local/lib/libSwEpLib.dylib

But I want it to be located next to my app project, preferably in the Resource folder (also next to project structure). I think that way it will be easy to keep it together when i build the app.

I need to send a path to the dynamic library so it knows where things are.

Best approach?

Appreciate,
John…

Not sure I understand. In the IDE script you can use files from anywhere. Make a copy of the dylib into a folder next to your project and copy the dylib there. I have a folder “build automation” with all the files I need to make my app and the helper apps:

Hi Beatrix,

Sorry, I wasn’t clear about that location. I’m building an app and the dynamic library needs to be in a reliable folder location. In the 4D world, plugins and images and icons, etc., were placed in the Resources folder. Easy management and building.

I showed that location because that appears to be where the dynamic library is being called from. Which is not what I want. I want the dynamic library files (Mac and Win) in the Resources folder, next to the app project, so they can be easily copied during the build.

Important because I need to set the paths to files and send the paths inside the dynamic library.

This is all new territory, and in a few weeks/months it will feel like an old pair of jeans.

Does that make more sense?

Appreciate,
John…

@John_Foster - is this a desktop app or a console app you’re building?

You can’t place dylibs in the Resources folder of the app because this will make an error when notarising. Instead, the dylib needs to go to the Frameworks folder. Then you make a constant to talk to your dylib like this:

Everyone here has had fun with this topic. And you haven’t even gotten to codesigning and notarisation, yet.

2 Likes

Hi Beatrix,

Ahh, I see. Thanks for that tip!!!

As for notarization, I’ve always used DMG Canvas on the Mac and for Windows I use INNO Installer plus command-line notarization using my USB Token.

BTW, what’s the best approach to passing the path of folders or files to the DynLib (stored as you suggested)? I am experimenting with:

Var f As FolderItem = New FolderItem("Resources")

Anyway, appreciate all your helpful support,
John…

Hi All,

I got it figured out with Geoffs help.

We had to set the dynamic library, in the build script, in the build destination, to App Parent Folder.

I didn’t understand that when I click on the Xojo Run button, it’s building as well. I thought the ‘Run’ and the ‘build’ were separate processes. Thus, my confusion with what Beatrix was sharing.

Hopefully this will help someone else down the road.

Appreciate,
John…

Just FYI - Notarization and Code Signing are not the same thing. Code Signing is what you do with your USB Token. DMGCanvas will create the DMG wrapper, sign it if you have an Apple certificate and I believe they support notarization now if you have an app-specific password, but none of that is done automatically.

HI Greg,

Yes I know that.

I do believe that DMG Canvas does both.

Of course, I already have all the credentials from Apple and DMG Canvas uses them.

Been using it that way for years with my 4D app.

Appreciate,
John…

1 Like