5

I have been given a Shared Object file (.so) and the functions inside of it, but I don't have a clue as to how to use it, or alter it for use in an iOS application. Could someone point me in the right direction?

I know the .so came from an Android application, but I was told I could get it to work in an iOS application as well.

RileyE
  • 10,874
  • 13
  • 63
  • 106

2 Answers2

9

Actually and technically, yes, you can, but not in a way you would ever think.

If it came from Android, it is probably compiled for ARM. So it should be binary-compatible with the ARM CPU in iOS devices. However, iOS doesn't use the usual format of shared objects (that is, the ELF format), but iOS' and OS X's own Mach-O format.

This means that you cannot directly link against this shared object file nor are you able pass it directly to dlopen() and dlsym(). You have to get into serious hacking (something that you probably don't know). This involves loading and relocating the file properly.

An example of this can be found in iOS jailbreak developer and hacker, Comex's GitHub repository Frash, a Flash player for jailbroken iOS devices. Comex essentially wrote an ELF loader module (dubbed "food") for iOS and used it to make Android's libflashplayer.so work on iOS. Pretty neat, huh?

Also note that this is not going to be possible for AppStore apps as it needs dynamic loading and various alterations in the OS.

  • Thats great! Thank you. I don't need this to be pushed to the app store, so this should work out quite well for me. – RileyE Nov 29 '12 at 00:32
4

while technically possible (see h2co3's answer) for anything practical the answer is no

  • so files arent in the correct binary format
  • even if they were, dynamic loading is not allowed by appstore
Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • This isn't really a practical app. It will probably forever be in development mode and never make it to production. It serves its purpose just fine, though! – RileyE Nov 29 '12 at 00:34
  • @Daij-Djan: We can see some sdk like facebook/(or)Other having the dynamic library (.dylib). We can upload that into appstore also. How to create it by using xcode ? – Vineesh TP May 25 '16 at 05:21
  • see http://stackoverflow.com/questions/4733847/can-you-build-dynamic-libraries-for-ios-and-load-them-at-runtime -- since ios8 it is allowed by apple – Daij-Djan May 25 '16 at 06:02
  • you have to start with a mac dylib and chang it to ios & arm64 is all. the question should answer it. if you need more help plz ask a dedicated question here on SO. I am not able to help you because of time constrains – Daij-Djan May 25 '16 at 11:41