Search code examples
cobjective-cswiftios13arm64

Xcode 11.5 Undefined symbols for architecture arm64 when using .C source


I'm attempting to use some C code in a Swift project for iOS.

The C code comes with a makefile that will compile a static .a library for the x86_64 architecture. Obviously, to use this code in iOS we need arm64 compatibility.

I've tried a few different approaches including:

  1. Throwing the C source and header files directly into the project, listing the C header in the bridging header.
  2. Same as approach #1 but routing my C calls through an Objective-C intermediary.
  3. Using Swift Package Manager to package up the C code into a framework I can drop into the project.

On approaches #1 and #2, Xcode is giving me code completion and syntax highlighting so I know the C headers are being picked up but at compile time I get error:

Undefined symbols for architecture arm64

If I try to call a simple C function I wrote myself, everything works fine. So I'm wondering if there's something in the lower level C I'm trying to use that is incompatible with arm64 or if I may simply need to modify something in my Xcode build settings.


Solution

  • The issue was resolved by ensuring all files were listed in Compile Sources