After a hairpulling search session, I found out that the file you're supposedly supply to otool is inside the .app
directory. Yes, the .app
is a directory, not a file.
So this is how to do it:
- build your project first, which will create a
.app
file.
- in the Xcode project navigator (left panel side), filter for
.app
name on bottom.
- right click on the
.app
file, select "show in finder".
- open a terminal window.
- type
cd
and then drag the .app
directory to the terminal. It will populate the path.
- type
otool -Iv Your_App_Binary_Name | grep stack
This Your_App_Binary_Name
bits can make you confused, but don't be. Just note what is the name of your .app
directory. For example, if the directory is MyApp.app
, then your binary should be MyApp
without extension, inside the MyApp.app
directory. If you see the file using finder (right click on the .app
and select "show package contents"), you'll see the type of the binary file is UNIX executable.
(Don't forget, if your app name contains spaces, you need to use backslash to escape the space. For example, if your app name is "My Holy App", then the directory is My\ Holy\ App.app
and the app binary is My\ Holy\ App
)
So your terminal will look like this for target named "My App":
$ cd ......./Build/Products/Debug-iphoneos/MyApp.app
$ otool -Iv MyApp | grep stack
0x00000001000c17bc 19966 ___stack_chk_fail
0x00000001000d8268 19967 ___stack_chk_guard
0x00000001000d8d18 19966 ___stack_chk_fail
or in case your target has spaces like "My Holy App":
$ cd ......./Build/Products/Debug-iphoneos/My\ Holy\ App.app
$ otool -Iv My\ Holy\ App | grep stack
0x00000001000c17bc 19966 ___stack_chk_fail
0x00000001000d8268 19967 ___stack_chk_guard
0x00000001000d8d18 19966 ___stack_chk_fail
EDIT: user mnemonic23 stated that if you compile the IPA with rebuild from bitcode, the result of otool won't show the result above. You have to compile the IPA without rebuild from bitcode.