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

**URL:** <https://discourse.julialang.org/t/embedding-julia-calling-julia-functions-from-an-xcode-project-in-objective-c/73675>\
**Category:** New to Julia\
**Tags:** embedding\
**Created:** [December 27, 2021, 11:12am UTC](https://discourse.julialang.org/t/embedding-julia-calling-julia-functions-from-an-xcode-project-in-objective-c/73675 "2021-12-27T11:12:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ondo](https://avatars.discourse-cdn.com/v4/letter/o/ecb155/32.png) [@Ondo](https://discourse.julialang.org/u/Ondo)\
**Post date:** [December 27, 2021, 11:12am UTC](https://discourse.julialang.org/t/embedding-julia-calling-julia-functions-from-an-xcode-project-in-objective-c/73675/1 "2021-12-27T11:12:02Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [December 27, 2021, 5:28pm UTC](https://discourse.julialang.org/t/embedding-julia-calling-julia-functions-from-an-xcode-project-in-objective-c/73675/2 "2021-12-27T17:28:54Z")

</div>

> [@Ondo](#):
>
> I have tried to set up the paths

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"`.

---

<div class="post-metadata">

**Author:** ![Ondo](https://avatars.discourse-cdn.com/v4/letter/o/ecb155/32.png) [@Ondo](https://discourse.julialang.org/u/Ondo)\
**Post date:** [January 1, 2022, 1:09pm UTC](https://discourse.julialang.org/t/embedding-julia-calling-julia-functions-from-an-xcode-project-in-objective-c/73675/3 "2022-01-01T13:09:51Z")

</div>

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?

Thanks,
