Shipping configuration files with Foo.app
-
I have some configuration files I want to package into my Foo.app. (I'm currently strictly developing on Mac Desktop). I've tried a few things and done some searching, but the solution is eluding me.
I tried just adding the files to the project. They aren't moved into the ../build-Foo* directories.
I made my .json files part of the Resources list by editing the .pro, but that didn't do anything -- not even change how they display in the navigator inside Qt Creator.
Is there an automatic way to do this? For now, I'm copying with a little script.
-
Hi and welcome to devnet,
If you have put your files in Qt's resources system, they are built in your application.
What kind of configuration file are you using ?
How will they be used by your application ? -
It's a desktop Widget GUI app.
The files contain JSON and define some extensive default behavior for a process engine. I'm building a Beat Saber map editor for Mac that works on the concept of patterns.
For instance, one pattern is a simple down stroke of a blue cube. Another pattern is the same thing for a red cube. Up strokes of each are two more patterns. Those are easy. But then we can do down-up. Or we can do a sort of swirl combo of down, up-left, up, and then we can repeat that pattern 3 or 4 times fairly quickly. You end up twirling the saber in circles. It's kind of fun, once you recognize the pattern. The first time I hit it, I flailed hard.
And then we can do that 3 times on blue, and 3 times on red.
Rather than manually laying out each cube, I'm designing patterns, and the program can insert the entire pattern for me. And I'm going to see how well I can get it to generate an entire map from a single click. We'll see if I'm clever enough for that algorithm to work well.
The JSON files define the well-known patterns I might use a lot.
Once I'm satisfied, I'll open-source the project on github and maybe someone will do the work to make it build on Windows, too. I don't have any Windows in the house to test against, so for now I'm staying Mac-centric.
-
Then why not put the json into a resource file like @SGaist proposed?
-
Then why not put the json into a resource file like @SGaist proposed?
@Christian-Ehrlicher said in Shipping configuration files with Foo.app:
Then why not put the json into a resource file like @SGaist proposed?
I wasn't sure how to accomplish that, and ultimately it's going to be quite a bit of JSON. However, I stumbled across a solution. In my Foo.pro file:
myPatterns.files = $$PWD/Patterns
myPatterns.path = Contents/Resources
QMAKE_BUNDLE_DATA += myPatternsI got that from this:
https://www.ics.com/blog/your-guide-deploying-qt-applications-macos
It may be that putting it into a resource file would have been the proper choice. I'm still a bit of a Qt newbie. The only thing I've used resources files for so far are icons.
I like the solution I stumbled on, but maybe it's not a good solution. For now, it's working.
-
No problem with that solution, it's the proper way to ship resources especially if they are big.
Will these files be changed somehow or are they meant to be read-only ?