Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use *.so library in Objective C?

I want to load a library compiled for unix(xxx.so) and i want to use it in an iOS application. The iOS application will be used in an enterprise - with an Apple Enterprise account(I mean the application won't be submitted to App Store).

Is it possible to use this type of library in ios?

Thanks.

like image 956
Ercan Celik Avatar asked Sep 23 '22 03:09

Ercan Celik


1 Answers

A .so file is a shared library. Prior to iOS8, Dynamic libraries were not supported in iOS. Post iOS8 though they are supported, as long as the library is compatible. In fact most iOS Frameworks (such as UIKit) are dynamic libraries.

The big thing here is the "compiled for unix" part. You have to compile the library in Xcode for iOS. Most "unix" shared libraries are for x86 or other processors, and will not work on the arm processors on iOS devices.

To make a shared library on iOS:

Create

  1. a new Project of type "Cocoa Touch Framework".
  2. Include all the source from the library you want to build.
  3. Add any exported headers to the Framework umbrella header
  4. Build the Framework
  5. Include the Framework in your other apps, usually by Adding it to the Target->General->Linked Frameworks and Libraries
  6. Import the Framework's headers and use them in the app
like image 91
David S. Avatar answered Sep 27 '22 03:09

David S.