Where’s the path of Objective-C runtime

Hi systems programming guys. I’m exploring the macOS as a low-level itself, so when I use the otool(1) utility to inspect a tiny objc helloworld program, it told me that there is a shared library like /usr/lib/libobjc.A.dylib (not identical) but I didn’t find that in path /usr/lib/. Also the docs sucked (see below). I want to know more details about the objc runtime on macOS (beta 27.6 +) and be seeking for help here because there are few materials online and not even to say the sucked AI.

The prima motivation is the runtime itself and how it works. Of course I would love to read disassembled code and manpages or using utilities that Apple offered to understand those things . But I really don’t know where is the runtime if both docs and otool output lied.

The latest documentation about Objective-C Runtime is outdate and it said “Objective-C runtime library support functions are implemented in the shared library found at /usr/lib/libobjc.A.dylib.”

Answered by Etresoft in 902431022

Apple's system-provided dynamic libraries are all pre-cached in the operating system and don't exist on disk.

You can find the source code to the Objective-C runtime here: https://opensource.apple.com

However, the open source site is always a little behind. It only has 26.5 right now. I'm sure it will be at least a year before 27.6 shows up.

Generally-speaking, Objective-C itself is outdated. Any documentation you find will be ancient. If you did find something really interesting, it's possible that it won't be useful because Apple will have already re-implemented that part in Swift.

Accepted Answer

Apple's system-provided dynamic libraries are all pre-cached in the operating system and don't exist on disk.

You can find the source code to the Objective-C runtime here: https://opensource.apple.com

However, the open source site is always a little behind. It only has 26.5 right now. I'm sure it will be at least a year before 27.6 shows up.

Generally-speaking, Objective-C itself is outdated. Any documentation you find will be ancient. If you did find something really interesting, it's possible that it won't be useful because Apple will have already re-implemented that part in Swift.

Don't use the comment feature. It hides your replies.

Swift is open source too. See https://github.com/swiftlang/swift

There is certainly still lots of Objective-C, but even something like AppKit isn't 100% Objective-C anymore. If you poke around in the Xcode debugger, especially UI debugging, you'll see more and more SwiftUI being used, even for things that were once ancient Objective-C code.

Apple's system-provided dynamic libraries are all pre-cached

Right. For more information about that process, and the linker in general, both static and dynamic, see An Apple Library Primer.

it said “Objective-C runtime library support functions are implemented in … /usr/lib/libobjc.A.dylib.”

If you file a bug against the doc, and reply here with the bug number, I’ll get that fixed. (Although the fix will likely be to simply strike that sentence because, in general, our framework docs don’t list the location of each framework on disk.)

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The canonical path for the ObjC dylib is /usr/lib/libobjc.A.dylib, but the binary itself is in the shared cache, like other system-provided dynamic libraries.

You can use lldb to list the dynamic libraries that your app uses (and their paths) using this command:

target modules list

Thanks for the help. I was just confused about the “missing“ path, then I used otool(1) utility in hope of knowing the actual path but got shocked like “what?! the utility lied to me too?” with no knowing that they are ”cached” at somewhat rather than at filesystem. I’m curious that do they live in memory since boot just like kernel XNU too? Can I inspect that behavior less or more, or they are part of kernel components in some sense?

And I noticed the Objectiv-C documentation was update. Great improvemen!

Where’s the path of Objective-C runtime
 
 
Q