"Undefined symbols for i386 architecture" in unit tests

I get the following error only when I try to build unit tests of the iPhone static library:

Undefined symbols for architecture i386: "std::terminate()", referenced from: -[ZipArchive dealloc] in libMyProject.a(ZipArchive.o) "___gxx_personality_v0", referenced from: Dwarf Exception Unwind Info (__eh_frame) in libMyProject.a(ZipArchive.o) ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) 

Building a source project works great.

What can I lose?

It should be noted that ZipArchive is a .mm file that refers to the libz.dylib structure, which is referenced both in the source project and in the test project.

In addition, the usual suspected Build objects have the following meanings:

Framework search paths : "$ (SDKROOT) / Developer / Library / Frameworks" "$ (DEVELOPER_LIBRARY_DIR) / Frameworks"

Other linker flags : -all_load -lxml2 - ObjC

Header search paths : / usr / include / libxml2

+4
source share
2 answers

I found a solution in this post .

For some reason that eludes me, the compiler needs a ZipArchive.mm file to rename to .m when the static library is used in another project (in this case, a test project).

+7
source

This usually happens for one of two reasons:

  • You copied the header of the framework or system directly to the project folder instead of adding it using a link through Xcode
  • You have installed several SDKs and they are referenced by the wrong structure or header. Most frameworks are not "developers." SenTestingKit.framework is an example of a developer platform, UIKit.framework is not. Oddly enough, there are two different places in which the development platform exists. In the / Developers / ~ folder in Xcode, as well as in the SDK developers folder. The default behavior is a link to the framework in the Xcode developer folder. To override this, enter "$ (SDKROOT) / Developer / Library / Frameworks" in the "Path Search Paths". Or in the case of an imported header or library, go to the appropriate field and add "$ (SDKROOT) / ..."

Make sure your search paths are the same for all purposes: Search path

If you use multiple SDKs, the wrong version for the Developer Framework may be added (e.g. SenTestingKit). Manually enter the correct path in the Framework search path using

$ (SDKROOT) / Developer / Library / Frameworks

enter image description here

+4
source

All Articles