You can either compile Nim to Objective-C with `nim objc yourfile.nim`

Or compile Nim to C as a shared library.

Tag the exported proc with `{.exportc.}` or `{.exportc: "my_desired_name".}` to 
ask Nim not to mangle them.

Then you can compile to a shared library and associated header with: `nim c 
--noMain --noLinking --header:my_header.h my_file.nim`

Or combine both (?): `nim objc --noMain --noLinking --header:my_header.h 
my_file.nim`

When calling Nim code, you will need to initialize Nim runtime once by calling 
NimMain().

Then you can follow any tutorial to call C from Objective-C.

The full details of Nim interop are written here: 
[https://nim-lang.org/docs/backends.html#interfacing-backend-code-calling-nim](https://nim-lang.org/docs/backends.html#interfacing-backend-code-calling-nim).

Note that the Objective-C backend is less tested compared to C and C++ so I 
recommend you go the C way but if you get Objective-C to work that would be 
very nice. 

Reply via email to