Search code examples
xcodemacoslinkerrelease

macOS: Should I ship system libs if my app dynamically links to them?


My app uses a couple of third-party dynamic libs, which I include in my app package. But what about the system libs that my own code and third-party libs depend on?

Examples include

  • /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
  • /usr/lib/libSystem.B.dylib

Should I bundle these and update their reference paths in all caller binaries of the app package?

If I must, should I create app binaries for each macOS version?

My thinking is that I shouldn't force my users to install Xcode, but I'm not sure if those system frameworks and dynamic libs are bundled with OS or installed through Xcode ...


Solution

  • The system libs are guarantee to run on any system your application supports (and naturally they are installed on any Mac since the system itself uses them). Therefore, no, you don't have to bundle these libs. Instead you have to carefully decide from which version of the OS your codes are prepared to support this or that version of a lib.

    When a piece of code needs to be handled differently for different versions of the lib at runtime, you can use such form to synchronize your codes with the current environment :

    if (@available(macOS 10.14, *)) {
        //codes supporting any system since 10.14
    } else {
        //codes supporting earlier systems
    }