I'd like to disable NSAssert calls that occur in our codeline when building our release iOS binary, and I'd then like to confirm that they are disabled, because I'm super paranoid. How can I confirm they are disabled?
To disable NSAssert calls in our release builds, I have added the NS_BLOCK_ASSERTIONS=1 (from here) constant to the command-line release build I am doing with xcodebuild, so that NSAsserts are blocked across the entire application's build, including the build of all of our static libraries that it uses. With dozens of static libraries, it's too much maintenance to try and verify this flag is set in each lib's project file, so this global approach is preferred. It looks something like this:
xcodebuild -target MyApp -configuration MyReleaseConfig -DNS_BLOCK_ASSERTIONS=1 build
Then to confirm that our calls to NSAssert have indeed been blocked, here is what I am trying, and where I seek advice: I am dumping the symbol table out of the resulting binary, and grepping for the actual method that the NSAssert macro invokes, like this:
# Use 'nm' tool to dump symboltable into txt file
/Applications/Xcode.app/Contents/Developer/usr/bin/nm MyApp.app/MyApp > MyApp.symbols.txt
# Search symbols for NSAssertionHandler:
grep "NSAssertionHandler" ./MyApp.symbols.txt
# Output results:
RESULT=$?
if [ $RESULT -eq 0 ]
then
echo -e "** ASSERTION CHECKER FAILED: FOUND 1 OR MORE NSASSERT CALLS IN RELEASE BINARY **"
else
echo -e "** ASSERTION CHECKER SUCCEEDED: NO NSASSERT CALLS IN RELEASE BINARY **"
fi
The problem is that I am still seeing NSAssertionHandler show up in the symbol:
U _OBJC_CLASS_$_NSAssertionHandler
I suspect I'm either using nm
incorrectly; or, perhaps this symbol shows up because we are linking with a third-party library that uses NSAsserts, or maybe the iOS APIs themselves use NSAsserts, thereby confounding my verification step. I want all of our code's calls to NSAssert to be blocked in our release builds -- how can I verify that this is the case? Any suggestions would be appreciated!