Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug in a framework in Xcode?

I have two projects, one is the networkLib for login and some other network function, the other is the usingLibDemo. So I have all the source code of both projects.

The networkLib project outputs a framework, called myNetKit.framework, which is used by usingLibDemo.

enter image description here

Now I successfully use myNetKit.framework to login, but sometimes it crashes, maybe in main() without stack information, but sometimes Xcode gives me the stack info like below:

enter image description here

So I know where it crashes:

enter image description here

But the Utils.m is not exposed, how Xcode gets the stack info and the crash line, and eventually open the source file for me? Because that I have the source code in my disk?

If so, how can I debug the myNetKit.framework step by step, when it is not crashed?

Thanks a lot for any tips.

like image 782
Jason Lee Avatar asked Mar 27 '13 08:03

Jason Lee


1 Answers

If someone would have the same question in future (now I am using Xcode 8):

You can:

  1. build your framework project (in this example "networkLib")
  2. copy project output ("myNetKit.framework") to destination project ("usingLibDemo")
  3. run destination project ("usingLibDemo") on your device
  4. stop process
  5. launch app from your device manually ("usingLibDemo")
  6. open framework project and Attach to Process of your app (launched in step 5). In Xcode 8: Debug->Attach to Process-> Select name of your app.

Don't forget set some breakpoints in your framework project.

like image 76
merry_ejik Avatar answered Sep 21 '22 18:09

merry_ejik