Embedding Julia: Calling Julia functions from an Xcode project in Objective C

I have copied Julia’s lib and include folders to my Xcode project. I have set the @executable path under build setting to the copy of Julia lib folder that was added to the Xcode project. I have added all 43 Julia libraries to “Link binary with libraries” under “Build phases” (for lack of knowing better - this is probably overkill). The main.m shown below gives rise to the error message:

  "uv/threadpool.h" file not found

although it is in include/julia/uv/

#import <Cocoa/Cocoa.h>
#include “include/julia/julia.h”

int main(int argc, const char * argv)
jl_init_with_image("/Applications/Julia-1.7.app/Contents/Resources/julia/bin/julia", “/Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/sys.dylib.dSYM”);

return NSApplicationMain(argc, argv);

I am not at all sure that the two arguments I pass to jl_init_with_image() are correct but compilations halts before seeing this because of the file not found.

There seems to be something fundamentally wrong with the way I have tried to set up the paths. Advice will be much appreciated,

Change your include path so that it extends to …/include/julia so that #include "julia.h" works instead of requiring #include "include/julia/julia.h".

Thanks a lot. I added all Julia’s dylibs into the project itself (in the Frameworks foldes of the Xcode sidebar), and the julia header files directly in the project as well, so now #include “julia.h” works. However, the files in the uv folder still cannot be seen (I cannot pull them out of the UV folder because of #include statements in other files). I got suspicious that something more profound is wrong. I deleted the #include “julia.h” and built the project, which works, but I get an error at runtime that I believe point to the more fundamental problem. Only I cannot decipher it:

dyld: Library not loaded: /Users/julia/buildbot/worker/package_macos64/build/usr/lib/libllvmcalltest.dylib
Referenced from: /Users/admin/Library/Developer/Xcode/DerivedData/JuliaExp-emjbnnwntjrrdgbvszakzvyborjq/Build/Products/Debug/JuliaExp.app/Contents/MacOS/JuliaExp
Reason: image not found

libllvmcalltest.dylib is in the project but I cannot recognise the /Users/julia/buildbot/… path indicated for it.
And then what image is it that cannot be found?