Search code examples
swiftmacoscocoaresourcesstore

Xcode MacOS where to store binary file that's needed


I've got an executable file that is written in C which outputs some information I need in my Cocoa App. My question is where do I store this executable file in my project? And what is going to be the path where it is gonna be stored when I release the App?

I've read about the Application Support folder. Printing this out

print(FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first)

gets me

Optional(file:///Users/cemal/Library/Containers/noorganization.ProjectName/Data/Library/Application%20Support/)

Is this where my binary file will be stored? If yes, where do I have to store it now at build time, so it gets stored in the Application Support folder?


Solution

  • You'll likely want store the additional binary within the .app bundle, in the MacOS directory — Storing it elsewhere could create issues, especially if it's a location that might be inaccessable.

    .app/Contents/MacOS

    Typically, this directory contains only one binary file with your application’s main entry point and statically linked code. However, you may put other standalone executables (such as command-line tools) in this directory as well.

    Bundle Programming Guide : Bundle Structures