How to enable Stack Smashing Protection in pure swift application?
I did try to put "-fstack-protector-all" flag to Other C++ Flags under project build settings tab in xCode, but is seems that, this flag is unused or have no impact on builded application.
To verifie build I'm using otool -Iv AppBinary | grep stack
.
In Swift, Stack smashing is enabled by default one only need to add the "-fstack-protector-all" flag under build settings in objective-c applications.
How to check if stack smashing is enabled. Run the otool command and presence of
stack_chk_guard
andstack_chk_fail
means the code is stack smashing protected.I was also facing this in my 100% Swift project.
Whenever I added
-fstack-protector-all
to the "Other C-Flags" Build Settings the flags did not show up in the binary as described in the other comments.What I did was to create an Objective-C Class…
… added a dummy implementation …
… and called it from my AppDelegate.
After that the flags showed up as described.