Should the MACH_O_TYPE in a generated Xcode project be `staticlib`and not `mh_dylib` for C targets?

The current default has subtly different behavior from swift build. Specifically, if the C library has missing extern definitions, the build fails on a missing symbol in Xcode, but succeeds with swift build.

Missing extern definitions are valid C. My project, Opaque, defines an extern symbol in a C target which the dependent target implements using @_cdecl. This allows me to implement that symbol using the Swift standard library.

I'm tempted to call this a bug, but I was wondering if anyone could imagine a situation changing this default would break existing projects.

It seems to me that your C target has an undisclosed dependency on your Swift target. Would it be feasible to move the symbols that have to be user-defined to another target that can be a dependency of your C target?

My understanding is that SwiftPM targets are meant to be standalone units that have all of their dependencies resolved.

1 Like

Thanks, this worked! I didn't realize a C library could depend on a Swift library.

However, there still may be an issue of swift build behavior being inconsistent with swift package generate-xcodeproj.