Search code examples
objective-cxcodeframeworksbreakpoints

How to set breakpoints in a Objc framework that is used by a blackbox Mac application?


I want to set breakpoints in the Objc framework that is compiled from my Xcode project, and let it break the Mac application that is dependent on the framework I build.

For example, Application "Blackbox" will use Framework "A", and I have access to the source code of "A" only.

Thus I cannot set breakpoints in the framework projects and simply change them to User, which will be accessible to all the Xcode projects. Or simply merge these two projects since I have to access to "Blackbox".

How can break the application to jump to the breakpoints I set in my framework?


Solution

  • I want to set breakpoints in the Objc framework that is compiled from my Xcode project, and let it break the Mac application that is dependent on the framework I build.

    Breakpoints are managed by the debugger; they're not compiled into your framework. What you need to do is to first set up your Mac so that you can attach the debugger, lldb, to the application you're trying to work on. In order to do that you'll probably need to first disable System Integrity Protection so that the operating system won't block you from debugging the app. Then you'll need to a copy of the symbol file (it'll end in .dsym) that you built when you built the framework, and you'll need to load it into the debugger. The blog post Attaching sources to iOS/macOS binaries compiled on another machine might help you walk through those steps.

    Once you've done all that, you should be able to set breakpoints on particular methods in your framework, watch what happens as you step through the framework, etc. What you won't be able to do, unless you can also get the symbol file for the application itself, is to see the app's source code when method calls into your framework return to the app.