Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
365 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...