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 :)

2
  • 7
    Objective C is a superset of C, so your C library should Just Work. Commented Jul 17, 2012 at 15:00
  • 1
    this post might be of interest to you stackoverflow.com/questions/10289890/… Commented Jul 17, 2012 at 15:10

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

2 Comments

.mm extension means Objective-C++. A C library should work just fine with .m files
The renaming of the files did the trick.. Why is that by the way? Does anybody know?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.