Note that there are some explanatory texts on larger screens.

plurals
  1. POXCode linking error to cached library information without being called (Undefined symbols for architecture)
    primarykey
    data
    text
    <p>I am attempting to use a static library (.a) for which I also have the header files (no .m files), but when I add the library to my target (without even referencing/importing the library in my project code), I receive the <code>Undefined symbols for architecture armv7</code> linking error at compile time. The linker is complaining about classes that supposedly no longer exist in the newest version of the library, and may be using cached data? That suspicion could be supported by the finding that if I create a blank project and add the library in the exact same way as I added it to my project, the new project compiles without issue. But on another note, when I grep my file system for the classes/ivars the linker is complaining about, I get matches in my static library file and my <code>xcuserdata</code> workspace folders. So I am wondering if the issue is in my project, the library I am trying to import, or the way in which I am trying to add the library to my project? And also, why do I get linker errors when I am not even importing/calling the library from my code? I am using <code>XCode 4.6.1</code>.</p> <p>The linking error is as follows:</p> <pre><code>Undefined symbols for architecture armv7: "_OBJC_IVAR_$_GenericPopupView.delegateTheme", referenced from: -[MyListView setDelegateTheme:] in myLib.a(MyListView.o) -[MyListView tableView:cellForRowAtIndexPath:] in myLib.a(MyListView.o) "_OBJC_CLASS_$_SampleMarkView", referenced from: objc-class-ref in myLib.a(MyListView.o) "_OBJC_CLASS_$_CheckMarkView", referenced from: objc-class-ref in myLib.a(MyListView.o) "_OBJC_METACLASS_$_GenericPopupView", referenced from: _OBJC_METACLASS_$_MyListView in myLib.a(MyListView.o) "_OBJC_CLASS_$_GenericPopupView", referenced from: _OBJC_CLASS_$_MyListView in myLib.a(MyListView.o) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) </code></pre> <p>I added the library to my target by performing the following steps:</p> <ol> <li>Right-click on my project</li> <li>Select <code>'Add Files to "My Project"'</code></li> <li>Locate the .a file through the popup Finder window</li> <li>Verify the library path is in my <code>Target -&gt; Build Settings -&gt; Library Search Paths</code> (automatically added when I complete step 3)</li> <li>Add the header directory to <code>Target -&gt; Build Settings -&gt; Header Search Paths</code></li> <li>Verify that the library is listed in <code>Target -&gt; Build Phases -&gt; Link Binary With Libraries</code></li> <li><p>Verify that the library is compiled for <code>armv7</code> via <code>file</code>, <code>otool</code>, &amp; <code>lipo</code> (I heard the library may also include <code>armv6s</code>, but I didn't see <code>armv6</code> when I used the three commands)</p> <pre><code>$ file myLib.a myLib.a: Mach-O universal binary with 2 architectures myLib.a (for architecture armv7): current ar archive random library myLib.a (for architecture cputype (12) cpusubtype (11)): current ar archive random library $ otool -L myLib.a Archive : myLib.a (architecture cputype (12) cpusubtype (11)) … $ lipo -info myLib.a Architectures in the fat file: myLib.a are: armv7 (cputype (12) cpusubtype (11)) </code></pre></li> </ol> <p>Here are things I have tried inbetween each compile attempt without any success:</p> <ul> <li>Clean the project with (apple)+shift+k</li> <li>Clean the build directory (<code>DerivedData</code>) with (apple)+alt+shift+k</li> <li>Delete all the <code>DerivedData</code> directories from the command line </li> <li>Remove and re-add the library and its headers to my project</li> <li>Add the library without the headers</li> <li>Put the libraries in a project that is a target dependency instead of in my project directly <ul> <li>Note that I am unable to add the library as a <code>Target Dependency</code> in <code>Build Settings</code>; should I be able to?</li> <li>I am also unable to add the library to the target's <code>Build Scheme</code> (via XCode menu's <code>Product -&gt; Scheme -&gt; Edit Scheme... -&gt; Build -&gt; +</code>)</li> </ul></li> <li>Check the minimum iOS version via <code>iOS Deployment Target</code> in <code>Build Settings</code> – both my target and the library are iOS 6.0</li> <li><p>Removed all target search paths except those required for my project to build without the new library as shown below (most importantly I removed the <code>DerivedData</code> from the linker path); my overall project build settings (not the target's build settings) contains no other search paths</p> <p>Header Search Paths </p> <pre><code>$(BUILT_PRODUCTS_DIR)/usr/local/include $(SRCROOT)/../MyLibDirectory/headers </code></pre> <p>Library Search Paths </p> <pre><code>$(inherited) $(SRCROOT)/../TargetDependencyDirectory $(SRCROOT)/../openssl/lib $(SRCROOT)/../MyLibDirectory </code></pre></li> <li><p>Removed all other instances of the library on my machine (old versions)</p></li> <li>Set the user-defined build setting <code>USE_HEADERMAP = NO</code></li> <li>Install on a newly imaged machine with a fresh project checkout and repeat all of the above steps</li> <li>Add <code>–ObjC++</code> to the other linker flags (<code>-ObjC</code> is already a linker flag)</li> <li>Use <code>armv6s</code> by itself and with <code>armv6</code> in the <code>Valid Architecture</code> under <code>Build Settings</code> for my target and the target dependencies</li> <li>Set <code>Build Active Architecture Only</code> to <code>Yes</code></li> <li>Switched between adding the library in a project group vs. at the parent project group level</li> <li>Add an import and instantiation of an object from the library in my project code</li> <li>Played with the library's different settings for <code>Location</code> under <code>Identity and Type</code> in the <code>Utilities</code> window on the right side of XCode when the library is selected</li> <li>Add the library to the target's <code>Build Phases -&gt; Link Binary With Libraries</code> via the <code>+</code> then <code>Add Other...</code> </li> </ul> <p>I have already tried the recommended steps in these and other posts (only the last two of these listed have actual instructions):</p> <ul> <li><p><a href="https://stackoverflow.com/questions/11759444/xcode-referencing-old-framework">Xcode referencing old framework</a></p></li> <li><p><a href="https://stackoverflow.com/questions/13255342/xcode-referencing-old-removed-frameworks-causing-multiple-interface-declaration">Xcode referencing old/removed frameworks, causing multiple interface declarations</a></p></li> <li><p><a href="https://stackoverflow.com/questions/15576399/xcode-custom-framework-no-known-method-error">Xcode custom framework - No known method error</a></p></li> <li><a href="https://stackoverflow.com/questions/6429494/undefined-symbols-for-architecture-armv7">Undefined symbols for architecture armv7</a></li> </ul> <p>I have not tried changing all of my files to .mm (I didn't need to for previous versions of this library), but I have a lot of .m files that I think might break if I change them all...</p> <p>Any help or succestions are greatly appreciated! I'm really having a hard time figuring out why this new version of the library is giving me problems.</p>
    singulars
    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.
 

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