Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C and C interoperability

We're going to have to write a C library and this library has to be accessible from Objective-C. Now I don't know anything about Objective-C so I wonder how simple Objective-C <-> C interoperability is. Is that as simple as including the C header in the Objective-C code and linking to the library? Is there anything special I'm supposed to do (like the extern "C" bit with C++)?

like image 716
Tamas Czinege Avatar asked Oct 19 '09 21:10

Tamas Czinege


People also ask

What is Objective-C interoperability?

To use Objective-C code in Swift, it is only necessary to import Objective-C header file in bridging header file to expose it to Swift. If you are working on a framework, you will need to import Objective-C in umbrella header since bridging headers are not available for frameworks.

Is Objective-C outdated?

To sum it up, Objective-C, when compared to Swift, is a more outdated language and lacks modern tools and properties.

Can you use Swift and Objective-C together?

You can use Objective-C and Swift files together in a single project, no matter which language the project used originally. This makes creating mixed-language app and framework targets as straightforward as creating an app or framework target written in a single language.

Will Objective-C be deprecated?

If Swift succeeds, Objective-C will go away. It won't be deprecated, but it'll move to Florida to enjoy its golden years.


2 Answers

Objective-C is a strict superset of C. You don't need to use extern "C" or anything like that.

like image 165
mmx Avatar answered Oct 27 '22 00:10

mmx


Objective-C is a strict superset of GNU C (note, this is not the same as ISO C90).

like image 41
BobbyShaftoe Avatar answered Oct 27 '22 01:10

BobbyShaftoe