4

I hope there is somebody that can help me with the following.

Currently i have an Android app that is connected to a C library using JNI. Now i would like to connect my iOS app to that same C library, but how can i call the functions and how can i access the interfaces without JNI?

Hopefully somebody has some good tips or tutorials.

So what i have is an Android App, an iOS App and a C-library adapted to JNI (Java Native Interface). The Android part works. But now i would like to reuse as much as possible but still connect my iOS app to that (or most of that) library. (library are separate header and .c files)

Please help :)

stackr
  • 2,742
  • 27
  • 44

2 Answers2

3

To elaborate slightly on my comment - unlike Android, iOS apps are built using Objective C with Apple's libraries. Objective C is a superset of C, which means that any valid C code is also valid Objective C code. You should be able to add the source files directly to an iOS project in Xcode, and sprinkle library calls anywhere you want. That means there is nothing like the JNI for iOS (or OSX) development.

Matt Wilding
  • 20,115
  • 3
  • 67
  • 95
2

You have two options:

  1. Directly use your library by adding it to project in xcode, assign a library search path, assign header search path and incude headers in .m objective-c source code that use it.
  2. Add all .c files to be compiled and linked by xcode and incude headers in .m objective-c source code that use it.

p.s. if you have used some particular compiler switches you may need to rebuild your libraries to properly target iOS.

Shebuka
  • 3,148
  • 1
  • 26
  • 43