5

Premise:

I'm trying to build a static library of C to be referenced from a Swift project through an objective-c bridging-header. I built the static library, included it in my project, Sourcekit recognizes the function I want to call from the Static library, but I am still getting errors (detailed below).

I followed the Wenderlich Tutorial for creating a static library in XCode. When I generate the universal binary, and run lipo command:

lipo -info libMyStaticLib.a

I get:

Architectures in the fat file: libMyStaticLib.a are: armv7 armv7s i386 arm64

I figured out it wasn't building the x86_64 architecture because when I linked to it in my project that requires the library, I got the error:

ld: warning: ignoring file 
/Users/jamesmart/SourcetreeProjects/MyProject/libMyStaticLib.a, missing
required architecture x86_64 in file
/Users/jamesmart/SourcetreeProjects/MyProject/libMyStaticLib.a (4 slices)
Undefined symbols for architecture x86_64:
"_helloWorld", referenced from:
__TFC7MyProject16BridgePlayground12sendIntToGetfS0_FT_T_ in BridgePlayground.o
ld: symbol(s) not found for architecture x86_64

I have seen the similar StackOverflow questions:

XCode 6.1 Missing required architecture X86_64 in file for extern library

XCode 6.1 Missing required architecture X86_64 in file

And I have tried the solutions listed, but nothing seems to be able to build that darn x86_64 architecture. I've also tried building my static library to many target devices:

Just tried to link pictures but I don't have enough reputation, sorry...

But I've tried targeting simulators and iOS Device, neither option solves this.

"Build active architecture only" is set to "No" in my static library build settings and also is passed as a parameter to the xcodebuild function in my Run Script build phase:

xcodebuild -target SegmentationLib ONLY_ACTIVE_ARCH=NO -configuration
${CONFIGURATION} -sdk iphoneos  BUILD_DIR="${BUILD_DIR}"
BUILD_ROOT="${BUILD_ROOT}"
xcodebuild -target SegmentationLib -configuration ${CONFIGURATION} -sdk
iphonesimulator -arch i386 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"

My "Valid Architectures" in Build settings are currently set to armv7, armv7s, and arm64 - Although I have tried only setting it to armv7 per someone's suggestion, and that didn't work either.

I am using XCode version 6.2 and am on OSX Yosemite 10.10.2.

Can anyone help with this?

Community
  • 1
  • 1
James Mart
  • 560
  • 3
  • 16

0 Answers0