It's somewhat difficult to do DYLD_INSERT_LIBRARIES right on OSX; it tends to subtly break various system components even if your binary doesn't do anything. However, SIMBL (http://www.culater.net/software/SIMBL/SIMBL.php) usually works fine. (On the (jailbroken) iPhone, you'd want MobileSubstrate (http://iphonedevwiki.net/index.php/MobileSubstrate), which does use DLYD_INSERT_LIBRARIES, where it causes few to no issues.)
Also, when replacing methods, it's better to do it like this, by storing the actual function pointer to the implementation: http://pastie.org/private/nbaaog7hptyzsytahpc5a — it makes "stacked" overrides (imagine an app tried to hook the same thing as well, you don't want that to cause issues) safer than renaming.
Comments
It's somewhat difficult to do DYLD_INSERT_LIBRARIES right on OSX; it tends to subtly break various system components even if your binary doesn't do anything. However, SIMBL (http://www.culater.net/software/SIMBL/SIMBL.php) usually works fine. (On the (jailbroken) iPhone, you'd want MobileSubstrate (http://iphonedevwiki.net/index.php/MobileSubstrate), which does use DLYD_INSERT_LIBRARIES, where it causes few to no issues.)
Also, when replacing methods, it's better to do it like this, by storing the actual function pointer to the implementation: http://pastie.org/private/nbaaog7hptyzsytahpc5a — it makes "stacked" overrides (imagine an app tried to hook the same thing as well, you don't want that to cause issues) safer than renaming.