How can I examine assembly in Xcode 4?

13,675

Solution 1

The "View Disassembly" option is gone, as far as I can tell.

Here's one workaround:

  1. Build your project
  2. Open the build log, and use the search window to find the compile command that was used to build the source file you're interested in. Copy the entire build command.
  3. Open a terminal window, and cd to your project directory.
  4. Paste the build command from the build log into the terminal, and append -save-temps. Hit enter.
  5. You now have two new files, yourFile.i and yourFile.s, which are the preprocessed source and generated assembly, respectively, built exactly as they are in your project.

Alternatively, you can disassemble the built binary (or the object file resulting from your source file) using otool -tvV /path/to/binaryOrDotOFile.

Finally, if this is a feature that you would like to have back, make sure to file a bug report!

Edit: This feature is back in Xcode 4.1. In the assistant editor pane, select "Generated Output -> YourFilename (Assembly)". Boom!

Solution 2

You can build Assembly by going to Product->Generate Output->Assembly File. Hope this is what you are looking for.

Note: They changed it again in Xcode 5. The above answer is doing the thing now

Solution 3

In Xcode 5.0.2 you can select Product → Perform Action → "Assemble MyController.m"

N.B. While this question refers to Xcode 4, it comes up high in results on google.

Solution 4

For lazy folks like me, Stephen Canon's suggestion above to use the -save-temps flag can be accomplished with even less work: go to project settings -> build phases -> compile sources and note the "Compiler Flags" column. Add -save-temps to whichever file you need a disassembly of, and the .ii and .s files will end up in the project directory.

Probably a better solution would be to make a custom rule with something like "-Wa,-alh" and a shell redirect "> myFile.s", but I don't see how to easily duplicate the default build rule for modification.

How in the world did "view assembly" get removed from XCode 4?!?!

Solution 5

According to this thorough review of Xcode 4, this functionality has been removed from Xcode 4. You'll need to file a bug/rdar if you want to try and get it back.

Another helpful quick-glance at Xcode 4 features by the same author: http://pilky.me/view/16

Share:
13,675
Bill
Author by

Bill

Updated on June 11, 2022

Comments

  • Bill
    Bill about 2 years

    I'm tuning some code that runs in a tight loop in my iPhone app and I'm curious to see the generated assembly code to see if anything looks out of the ordinary.

    In Xcode 3.x, there was a Build > Show Assembly Code option in the menu, but I don't see anything in the menus or the documentation for Xcode 4.

    Anyone know how to do this? I could do "gcc -S" but my understanding is that that won't be identical to how the entire project is compiled.

  • Matt Bierner
    Matt Bierner almost 9 years
    I believe help is accessed with: help disass