Note that there are some explanatory texts on larger screens.

plurals
  1. POSymbol not found: _objc_retainAutoreleasedReturnValue in MacOS command line tool
    primarykey
    data
    text
    <p>There are a <em><a href="https://stackoverflow.com/questions/11551927/symbol-not-found-objc-retainautoreleasedreturnvalue-running-arc-compiled-code">couple</a> <a href="https://stackoverflow.com/questions/12735408/symbol-not-found-objc-retainautoreleasedreturnvalue">questions</a></em> with the same keywords as the title, however they focus on the iOS side of Objective-C. My problem is with a MacOS command line tool.</p> <p>Basically what's happening is that the Foundation (Cocoa) tool is calling a C function which ends up calling another Foundation method. And as the Foundation method is being called from the C function, that's where the "<code>Symbol not found: _objc_retainAutoreleasedReturnValue</code>" error is being thrown at run time. </p> <p>The code looks like this:</p> <p>log.h</p> <pre><code>@interface Log : NSObject { } @end void RemoveLogFile(NSString * theLogFile); </code></pre> <p>log.m</p> <pre><code>#import "Log.h" @implementation Log @end // this is a C-style function void RemoveLogFile(NSString * theLogFile) { NSString * logFileName; NSLog( @"about to allocate a filename" ); // crash can happen in either case below #if 1 logFileName = [NSString stringWithFormat: @"%@.log", theLogFile]; #else logFileName = [[NSString alloc] initWithFormat: @"%@.log", theLogFile]; #endif NSLog( @"done allocating"); } </code></pre> <p>main.m</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "Log.h" int main(int argc, const char * argv[]) { @autoreleasepool { NSString* outPath = [[NSString alloc] initWithFormat: @"%@/MyLogFile", @"/tmp/"]; NSLog( @"past out path alloc"); RemoveLogFile(outPath); NSLog( @"done with the test"); } return 0; } </code></pre> <p>ARC is turned on for the 64-bit compiled tool (<a href="https://stackoverflow.com/questions/7919227/arc-error-fobjc-arc-is-not-supported-with-fragile-abi">it can't be turned on for the 32-bit version</a>) and the minimum supported MacOS version is 10.6.</p> <p>When the tool is called in MacOS 10.7, it promptly crashes out with a log like this:</p> <pre><code>Process: com.dautermann.Doughnuts [540] Path: /Library/PrivilegedHelperTools/com.dautermann.Doughnuts Identifier: com.dautermann.Doughnuts Version: ??? (1.0) Code Type: X86-64 (Native) Parent Process: launchd [1] Date/Time: 2013-02-19 05:02:48.337 -0800 OS Version: Mac OS X 10.7 (11A390) Report Version: 8 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000002, 0x0000000000000000 Application Specific Information: objc[540]: garbage collection is OFF Dyld Error Message: Symbol not found: _objc_retainAutoreleasedReturnValue Referenced from: /Library/PrivilegedHelperTools/com.dautermann.Doughnuts Expected in: /usr/lib/libobjc.A.dylib Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 dyld 0x00007fff5fc0106d dyld_fatal_error + 1 1 dyld 0x00007fff5fc04918 dyld::fastBindLazySymbol(ImageLoader**, unsigned long) + 128 2 libdyld.dylib 0x00007fff925f0716 dyld_stub_binder_ + 13 3 ??? 0x0000000100004030 0 + 4294983728 4 com.dautermann.Doughnuts 0x0000000100001523 0x100000000 + 5411 5 com.dautermann.Doughnuts 0x0000000100001470 0x100000000 + 5232 </code></pre> <p>My educated guess (with help from other folks) is that I may need to either pass in a "<code>char *</code>", or I have to declare something somewhere as "<code>_unsafe_unretained</code>". It sure seems like something that the modern Xcode 4.6 compiler should be handling for me. </p> <p>Anyone have any guesses as to what I might be doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload