Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are the iOS frameworks binaries located in the filesystem?

I'm kind of confused about frameworks on iOS. I think they are basically a directory containing a dynamic library, headers and resources.

But in my device the frameworks directories in System/Library/Frameworks don't contain the dynamic library. How is this possible? Shouldn't it be present to be loaded in memory when the application requiring it is launched?

like image 423
Zmaster Avatar asked May 31 '12 09:05

Zmaster


2 Answers

The binaries no longer exist on-device (and have not since iOS 3.1): Apple has merged them all into one large mmap()'ed cache file, to make app launch a bit more efficient. As the pages usually never change, the kernel can effectively share them between every running image. You can still use dlopen() on files held within the cache, as dyld short-circuits file lookup when the given library exists in the cache.

The cache file is in /System/Library/Caches/com.apple.dyld, and is named after the architecture (armv6 or armv7). The libraries within can be extracted using dsc_extractor or KennyTM's dyld_decache, available in this repository, but once extracted they can't actually be loaded into memory properly (as they all effectively get their symbol tables merged in the cache.)

There's a bit of a better (though older and less informed, more in-depth) write-up here: http://blog.howett.net/2009/09/cache-or-check/.

like image 86
Dustin Howett Avatar answered Oct 22 '22 18:10

Dustin Howett


I've noticed this, too. Strange. I can't explain to you "where they are", but I have observed, for example:

If I list out a (private) framework directory:

iPhone4:/System/Library/PrivateFrameworks/BluetoothManager.framework root# ls -alt
total 8
lrwxr-xr-x   1 root wheel   28 Nov  4  2011 CodeResources -> _CodeSignature/CodeResources
drwxr-xr-x   3 root wheel  170 Nov  2  2011 ./
drwxr-xr-x   2 root wheel  102 Nov  2  2011 _CodeSignature/
-rw-r--r--   1 root wheel  740 Nov  2  2011 Info.plist
drwxr-xr-x 170 root wheel 5814 Dec 31  2007 ../

iPhone4:/System/Library/PrivateFrameworks/BluetoothManager.framework root# ls -alt _CodeSignature/
total 0
drwxr-xr-x 3 root wheel  170 Nov  2  2011 ../
drwxr-xr-x 2 root wheel  102 Nov  2  2011 ./
-rw-r--r-- 1 root wheel 1222 Nov  2  2011 CodeResources

You don't see a BluetoothManager.framework/BluetoothManager dylib file. However, this code does actually work to dynamically open that framework, as if that file exists:

handle = dlopen("/System/Library/PrivateFrameworks/BluetoothManager.framework/BluetoothManager", RTLD_LAZY);

Using the find command from the root filesystem ("/") location also finds no file on the device named BluetoothManager.

I know that's probably not the answer you're looking for, but depending on why you want to know, maybe it helps?

like image 26
Nate Avatar answered Oct 22 '22 16:10

Nate