Xcode Guard Malloc and on Device Debugging: 'libgmalloc.dylib' image not found
XcodeMallocXcode Problem Overview
I enabled memory checking in Xcode (Edit Scheme -> Options). I'm now getting the following when I perform on device debugging: dyld: could not load inserted library '/usr/lib/libgmalloc.dylib' because image not found
. The measure was taken proactively in hopes of catching mistakes early in the cycle.
Is memory checking not valid on a device? It appears its valid since it was acknowledged and investigated according to http://lists.apple.com/archives/xcode-users/2012/Mar/msg00271.html. Also, Xcode had no complaints during compile and link. If its not valid for a device, why is Xcode inserting the library? Are there any solutions? Googling returned a few hits, but I did not see any concrete solutions.
How does one enable Xcode Guard Malloc when debugging on a device?
Xcode Solutions
Solution 1 - Xcode
You can't use GuardMalloc on the device.
Solution 2 - Xcode
To work around, I created two new Xcode schemes. One is named 'XXX Device' and does not include the malloc guards; the second is 'XXX Simulator' and does include the malloc guards.
Adding a scheme for device/simulator purposes is questionable (http://www.cocoabuilder.com/archive/xcode/303307-why-does-xcode-create-nonsensical-destinations-in-every-scheme.html). Apparently, Dave Duncan has not encountered an issue where Xcode does not do something correctly (or he does not use tools such as malloc guards).
This reeks of Cupertino software junk. +1 to Apple and its crappy QA department (if it exists) which let another bug fly free.
Solution 3 - Xcode
As others answered, you can not use Enable Guard Malloc
on device, but you can use it on simulator.
All 3 other memory management options, as of Xcode 7.3.1, can be used on device: Enable Malloc Scribble
, Enable Malloc Guard Edges
and Enable Zombie Objects
.
Solution 4 - Xcode
Rebooting device fixed it. iOS hasn't updated. Really bad !