macOS Command Line Tool with Swift Cocoa Framework: Library not loaded

后端 未结 3 858
长发绾君心
长发绾君心 2020-12-28 13:05

The following error is thrown when trying to run my target:

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: x/Xcode/DerivedData/x/Buil         


        
3条回答
  •  遥遥无期
    2020-12-28 13:45

    In your "Command Line Tool" Target.. set the following...

    LD_RUNPATH_SEARCH_PATHS = @executable_path
    

    (Or as Xcode calls them, "Runtime Search Paths") Setting this, the @rpath, in essence, says.. "hey, look in whatever folder the 'tool' is running in" for the dynamically loadable libs. (In this case it will be your build folder.

    Other useful @rpath combinations involve similarly relative paths to the executable (which may also be a library or framework binary, in some cases), via @loader_path. Say if the lib was bundled within a framework.. It may require the LD_RUNPATH_SEARCH_PATHS of @loader_path/Frameworks, etc.

提交回复
热议问题