Question

I have the source code for a video decoder which is written in C.

The code has successfully compiled and and executed under linux OS. Later i also ported this decoder in an android application with the help of ndk and JNI.

Now my requirement is to port this application onto iOS (that is for iPhones). My queries are:

  • Are there tools like ndk and jni to port this code to iOS?
  • Will there be any dependability issues for this code?

I tried googled regarding the same but couldnt get fair amount of information to proceed with the porting procedure.

Any Suggestions or helpful links regarding the will shall be appreciated. Please reply regarding the same. Thanks in advance.

Was it helpful?

Solution

As stated above yes all C code is valid in Objective-C since Objective-C is a superset of C. However this is a bit of a twist of words. The statement is actually

"All C Syntax is valid in Objective-C"

There is no guarantee that all your code will be 100% functional in an iOS environment. Since you can do things like make UNIX system calls from C or other machine/OS specific things there may be parts of the code that are not supported in iOS. If you wrote all the C code you are using and are sure that it contains no such calls or similar things than you should be fine.

OTHER TIPS

Good News!

Objective C, which is the language used for iPhone is a superset of C. Which means that all C code is natively supported. You do not need to convert the code at all!

More info here

Its not as simple though, Depends on how code is written in C.

If directly adding files and calling functions do not work, you will need to make following changes in file names -

  • Make the file with extension .mm instead of .m
  • rename .c file to .mm
  • rename .h file to .hpp (It worked for me once I ported C files in my proj)

Refer this link

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top