Cordova + XCTest results in 'Undefined symbols for architecture i386'

1.8k views Asked by At

I'm getting an error when I try to integrate XCTest with a Cordova project. It happens in a fresh cordova app, no customizations. Just add XCTest and tests fail with the following errors:

Undefined symbols for architecture i386:
  "_CGRectZero", referenced from:
      +[CDVUserAgentUtil originalUserAgent] in libCordova.a(CDVUserAgentUtil.o)
  "_OBJC_CLASS_$_ALAssetsLibrary", referenced from:
      objc-class-ref in libCordova.a(CDVURLProtocol.o)
  "_OBJC_CLASS_$_CLLocation", referenced from:
      l_OBJC_$CATEGORY_CLLocation$_JSONMethods in libCordova.a(CDVShared.o)
  "_UTTypeCopyPreferredTagWithClass", referenced from:
      ___30-[CDVURLProtocol startLoading]_block_invoke in libCordova.a(CDVURLProtocol.o)
  "_kUTTagClassMIMEType", referenced from:
      ___30-[CDVURLProtocol startLoading]_block_invoke in libCordova.a(CDVURLProtocol.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I tried removing the i386 architecture to no avail and a slew of other things but this one is escaping me.

Any thoughts? Thanks in advance!

Edit: I forgot to note the project builds perfectly fine but running the tests [via Product -> Test] causes these error.

1

There are 1 answers

0
johncblandii On BEST ANSWER

Found it.

You have to add each framework to your test target that is needed. In my case, I needed to add:

CoreLocation.framework
AssetsLibrary.framework
CoreGraphics.framework
MobileCoreServices.framework

After that, the unit tests failed as expected.