Patroclus
Patroclus

Reputation: 1232

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?

Upvotes: 1

Views: 309

Answers (2)

lazd
lazd

Reputation: 4687

I was able to accomplish this in Xcode 2.5 on Mac OS X 10.4.11 by following these steps:

Build setup (Project Info -> Build)

  1. Debug information form: DWARF with dSYM file
  2. Separate PCH Symbols: unchecked
  3. Generate Debug Symbols: checked
  4. Level of Debug Symbols: full
  5. Strip debug symbols: unchecked

Note: It's possible not all of these options were required.

Initial build and framework link

  1. Run a development build
  2. Symlink the built framework into My.app/Contents/Frameworks/ folder:
ln -s /Users/you/MyFramework/build/Development/My.framework /Applications/My.app/Contents/Frameworks/My.framework

Executable setup

  1. Select Project -> New Custom Executable...
  2. Use the wizard to add /Applications/My.app

Debug

  1. Set a breakpoint in your framework
  2. Select Build -> Build and Debug
  3. Enjoy debugging

Upvotes: 1

Caleb
Caleb

Reputation: 124997

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.

Upvotes: 1

Related Questions