2

I'm trying to debug a certain method, but my breakpoints in that method never get hit when I'm debugging on a device, but they do get hit when I am debugging with the iOS simulator. The method is part of a library that my app calls, and I feel like that may be a factor. I developed both the app and the library, and I have both the app and the library open in the same Workspace when I'm debugging.

I put one breakpoint in on the line in my app's code that calls the library method, then a second breakpoint on the first line of the library. When I test with the simulator, both are hit. When I test on a device, only the first one is hit, and the second one gets skipped over (the code for the library method still appears to run).

Is there anything special I need to do to be able to step into a library call when I'm debugging on a device that I don't need to do when debugging on the simulator? Or is it impossible to debug inside a library?

I'm sorry if this is a little unclear - I'm trying to describe what I'm doing as well as I can, but it's pretty strange behavior that I haven't seen before, so it's a little hard to describe. If you need anymore information or anything is unclear, please let me know.


EDIT 1: I noticed something that's a little different, not sure if it's connected or not: I don't have a .h file containing the methods in my library. Actually, there is only 1 method in it (which I'll callmyMethod) that will be called from outside the library (then that method calls the other methods in the library as it needs them). Furthermore, I'm using the TARGET_IPHONE_SIMULATOR pre-processor trigger to make the call in a slightly different manner depending on if it's running on a device or on the simulator. To make the call into the library, on a button click method in my app I just have

#if TARGET_IPHONE_SIMULATOR
    extern void myMethod();
    myMethod();
#else
    extern void myMethod(const char diretory[], int directoryLength);
    const char *dir = [[documents path] UTF8String];
    myMethod(dir, [[documents path] length]);
#endif

I have matching #if blocks in the method in my library to declare it as needed, and to use dir when it is passed in. This seems to execute just fine. I can tell the code in my library is being called and doing something, it's just not doing what I want it to. Thus the attempts to put in a breakpoint, and the reason for this whole question.


EDIT 2: My library actually contains plain C code, not Objective-C. I put some printf lines into the library code, and its not being displayed. I'm curious if somehow my app is calling a previous version of my library, instead of calling the one that's open in my workspace. That would be consistent with the "it's just not doing what I want it to" part of my last edit. Would it be possible that the device is trying to run an old version of the library it has saved somehow? I thought that completely removing the app from the device before installing the new version of my app would prevent that, but perhaps I'm mistaken?

GeneralMike
  • 2,951
  • 3
  • 28
  • 56
  • 1
    Have you tried removing the app from the device and retrying? I've had issues where bundled files aren't automatically updated on a device, and maybe the files on the device don't currently have debug info. – Marcus Adams Jun 20 '13 at 20:15
  • @MarcusAdams: yeah, I fully removed the app from the device, then I updated it by plugging it into my Mac and having Xcode run it on the device - that should automatically put the debug info in I would imagine, correct? – GeneralMike Jun 21 '13 at 11:58
  • Yes, the problem lies elsewhere. – Marcus Adams Jun 21 '13 at 12:14
  • You also may need to "clean" your project (and then delete/reinstall on the device). But understand that optimization can do strange things with debugability. Sometimes you have to put the stop early and step through the code, et al. – Hot Licks Jun 21 '13 at 15:48
  • @HotLicks: I tried that too. I put the stop just before the call to my library, then tried to "step into" the library call, but it goes to a bunch of strange code that I didn't write (I think it's got a big hex tag before it). I stepped through that for a while hoping that it would make it back to the code I wrote, but it never seemed to. After a while I used the "step out", and that brought me back to the code in my app after the call to the library completes. I never hit any of the code in the library itself (at least not in the form I wrote it). – GeneralMike Jun 21 '13 at 16:02
  • Are you sure some of your code is not compiled as a separate library module? You generally cannot set breakpoints in such code. – Hot Licks Jun 21 '13 at 16:37
  • @HotLicks: Not sure I know what you mean my "separate library module" The code I'm trying to put breakpoints in is part of a library that I added to my app's Workspace (following the method in idz's [answer here](http://stackoverflow.com/questions/11655931/xcode-4-3-static-library-generation?rq=1)). The breakpoints function fine when I debug on the simulator, they are only skipped when I try to debug on a device. – GeneralMike Jun 21 '13 at 17:08

0 Answers0