0

I have a program that when executed creates a folder in "~/Library/Application Support/MyApp" on mac. This is the directory that its config.cfg and log files and written to. The program has 2 files its depends on, a .dylib library and a .map file.

When I run macdeployqt, the .dylib is automatically copied to the Frameworks folder within the .app bundle. I have specified the file name of the .dylib in the .pro file:

INCLUDEPATH = libokFrontPanel.dylib
DEPENDPATH = libokFrontPanel.dylib
LIBS = libokFrontPanel.dylib

So when building the compiler looks in the build folder for the .dylib file.

Is there a way to automatically copy the .map file from the build folder into "~/Library/Application Support/MyApp" which is where it looks for the file at run time?

I could always just have to user manually copy the file there before use, but it would be nice if it could be automated at run time/compilation time.

Thanks, Mitch

Mitchell D
  • 465
  • 8
  • 24
  • The user's Documents folder is for the user to store their documents, not for your application's config and log files. I suggest you look at the Library or Application Support folder. You can read about OS X folders in the Apple docs here: https://developer.apple.com/library/mac/documentation/General/Conceptual/MOSXAppProgrammingGuide/AppRuntime/AppRuntime.html Note Table 1-1 Key directories for Mac apps – TheDarkKnight Mar 30 '15 at 08:22
  • @TheDarkKnight I tried doing that but the program then requires the user to navigate to the folder where the log files are stored, Library is inaccessible through the standard file browser... Hmm – Mitchell D Mar 30 '15 at 08:29
  • Perhaps you can think of another method for the user to select a log file, than using the standard Open File browser. If you plan on releasing your product via the App Store, I would expect the app may be declined if storing the files in the user's Documents folder. – TheDarkKnight Mar 30 '15 at 08:46
  • @TheDarkKnight yes I think you right. In terms of the .map file, is there anything I can put in the .pro file to have it included in the build in the ~/Library folder? – Mitchell D Mar 30 '15 at 08:50
  • @TheDarkKnight I have edited my original question and changed the code to use the Library/Application Support folder. It works fine to load the file from. Is there a way to have the .map file automatically copied into this directory? – Mitchell D Mar 30 '15 at 09:28

1 Answers1

0

Automatically, no, but there's no reason why you can't have your application check for its existence in the user's ~/Library/ folder on startup and if it's not there, copy it with QFile::copy

Alternatively, if you're distributing with a package (pkg), you can create a postscript to copy the file on install.

Community
  • 1
  • 1
TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85