I am a bit of a iPhone/Mac OS newb.
When I look at a backtrace in the debugger and UIKit or other Apple Libraries are on the call stack I can't see their function arguments because of missing debug symbols.
Does Apple Ship debugging symbols for the iPhone Simulator libraries like UIKit?
Thanks.
No. The OS-level components do not ship with debug symbols, nor have those symbols available to you. On the Mac, the only case I can think of where a special debug version of a framework was made available was for Core Data, but that was more for logging of SQL and other database-related actions.
You can extract a little more information about what's going on in the Simulator using DTrace scripts and custom instruments, which can probe for even private methods and classes. For example, I created a couple of scripts and a custom instrument here that logs out every method that is called in the process of starting up an iPhone application in the Simulator. I describe how that works in this article on MacResearch.
Related
I'm debugging an iPhone application and, well, gdb is just not doing it for me.
Are there any alternative debuggers or debugger uis I can use for XCode in general, or specifically for debugging iPhone applications?
lldb is the only supported alternative. Last time I checked it was in alpha state.
Life was better for Apple developers when we had a choice of IDE's (CodeWarrior, Think__, MPW, etc.) and debuggers (anybody remember Jasiks?), but anyways... consider this a business opportunity (to write a better debugger).
Not sure if you care to know this fact, since I have a feeling you're just not too thrilled with Xcode's built in debugging capabilities, but you CAN change the debugger between GDB and LLDB very easily. Look at the "To change the debugger..." section of Apple's Debugging & Analyzing Your Code document (right at the top, within the first screen of text).
I was wondering if is there any way to quickly check iOS/objective-c snippets or new code inside my xcode project without having to compile the whole app for that, open up the simulator just to get the NSLog message traced on the console.
I remember when life was easier using ruby's irb or node command for node.js :)
It just gives me the impression that on iOS development you have to learn how to deal with this high complexity and dependencies all the time, but I am just starting on this new world. so any help would be appreciated.
thanks a lot
This timely blog post should help; I'm using it often already.
Update: there is also Code Runner available in Mac App Store - this supports many languages, including Objective-C.
An Xcode project can contain multiple targets. One of the targets can be a test driver in which you can put some class/object/snippet exercise code and drive it from the command-line, results to the debug console. Another option is to create unit test targets.
If the code you're writing has known expected input-output pairs and you're just writing code to make them work, you may want to look into using XCode's unit testing capabilities. A link to a tutorial on using unit tests is at http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/UnitTesting/0-Introduction/introduction.html . If you want to test more interactive things, it is possible to use Instruments (a program in XCode) to automate those tests as well using the Automation instrument. A guide on using Instruments is available at http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/AboutTracing/AboutTracing.html .
Not really—Objective-C is a compiled language, while I believe Ruby is interpreted (which allows for interactive testing like what you describe). You can reduce some of the overhead of building and running your project by just leaving the simulator open; stopping the app from Xcode will close the app but leave the simulator running, meaning that a rebuilt version of the app will launch more quickly when you run it.
I recently ran into a problem for which there were no working solutions on Google. I'd like to log an applications's Objective-C messages to the console or to a file. I didn't write the application so I don't have the source code to recompile with logging included. I have a jailbroken iPhone so no restrictions on how to realize this. I even considered doing this through a MobileSubstrate extension (may I hook objc_msgSend for that application to do some logging?), but had not very much ideas. Can you please help me out with this?
There is a logging mechanism for ObjC messages, but I'm not sure whether you'll get method names without symbol files. Assuming that your jailbroken phone will allow you to run any app under control of the debugger (gdb), you should be able to start the app, set a breakpoint early during the initialization, then do this:
(gdb) call (void)instrumentObjcMessageSends(YES)
The log file will be written to a text file in the tmp folder. More details here:
http://www.dribin.org/dave/blog/archives/2006/04/22/tracing_objc/
Is there any equivalent to a Flash projector for iPhone? Flash projectors basically seem to package script and Flash libraries into one executable file that can be run on a PC. I'm wondering if anyone has made a similar thing for iPhone where I can take my existing code and package it with the necessary iPhone stuff to make a PC executable. Of course hardware-specific things would not be available like accelerometer/phone/gps, etc. but I don't need any of those. If not, is there anyone currently attempting this?
Thanks for the input guys, but I think everyone except Noah is misinterpreting my question. Flash was just an example, if you hate Flash just pretend I said something else. I am wondering if it is possible to make code for iPhone run on a PC in a similar way to the way a projector works for Flash.
Right now, the only way to run an iPhone app outside of an iDevice is to compile it from source for a non-iPhone target, so it depends on what you're using to compile. If you're authoring in XCode, you can target the Simulator (which is mac-only), but Apple doesn't currently have a way to compile for any other targets, or a way to compile an object file that runs on Macs without the simulator. If you're authoring in Flash CS5, of course you can just publish a projector.
Not at this time. However, Flash CS5 will create iPhone applications.
Flash is not available on the iPhone.
Furthermore, any company attempting to make a Flash runtime -- which would require doing bytecode interpretation -- would run up against Apple's developer agreement, which specifically forbids that.
I think Adobe is planning for CS5 the export to iPhone app feature. It essentially compiles flash's runtime to Apple's cocoa touch framework and produces a true iPhone app, thus circumventing the bytecode interpretation clause. Time will tell, time will tell...
--- Thanks for the clarification Myz... WTB Noah's reading skills, I thought you had typo'd the PC part due to the outrageousness of your question.
If by PC you mean a windows binary simulator interpreting .ipa files. No, such thing doesn't exist and I don't expect to see it for decades. The platform is much more harder to emulate than the old SNES/N64 and others.
I'm writing an iPhone game in objective-C using XCode. I'd like to profile the performance of my code. What is a good profiler to use?
Have you tried Shark? it comes with the developer tools.
Apple provides a program called Instruments, which is included with the iPhone SDK download, that really is excellent. It allows you to view memory leaks, animation performance, and a bunch of other stuff.
The developer tools you downloaded also included a great app called Instruments. You'll find it in your Developer folder next to Xcode:
/Developer/Applications/Instruments.app
Instruments works great for profiling and also has some preset modes that you can use to track down memory leaks, view how many instances of various objects have been created, monitor your OpenGL performance, etc.
To use Instruments, just build your app in Xcode, then while still in Xcode, launch Instruments from:
Run > Start With Performance Tool > Instruments Templates
…then select the type of performance monitoring you'd like to do.
Shark is an incredible profiler, included as part of Apple's CHUD tools, with XCode. If you can get that to run in, say, the simulator, you will be extremely pleased with the results it provides.
Just wanted to plug a set of profiler macros I created for iPhone. You can profile in the traditional sense vs sampling w Shark. It also doesn't require any special tools and the output is saved to a file in your app's Documents folder.
http://code.google.com/p/iphone-quick-profiler/
.n