Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

iphone - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...