# Should the MACH\_O\_TYPE in a generated Xcode project be \`staticlib\`and not \`mh\_dylib\` for C targets?

**URL:** <https://forums.swift.org/t/should-the-mach-o-type-in-a-generated-xcode-project-be-staticlib-and-not-mh-dylib-for-c-targets/24458>\
**Category:** Package Manager\
**Created:** [May 13, 2019, 3:09am UTC](https://forums.swift.org/t/should-the-mach-o-type-in-a-generated-xcode-project-be-staticlib-and-not-mh-dylib-for-c-targets/24458 "2019-05-13T03:09:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![George](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/george/32/37757_2.png) [@George](https://forums.swift.org/u/George)\
**Post date:** [May 13, 2019, 3:09am UTC](https://forums.swift.org/t/should-the-mach-o-type-in-a-generated-xcode-project-be-staticlib-and-not-mh-dylib-for-c-targets/24458/1 "2019-05-13T03:09:10Z")

</div>

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](https://github.com/GeorgeLyon/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.

---

<div class="post-metadata">

**Author:** ![fclout](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/fclout/32/36155_2.png) [@fclout](https://forums.swift.org/u/fclout)\
**Post date:** [May 13, 2019, 5:16am UTC](https://forums.swift.org/t/should-the-mach-o-type-in-a-generated-xcode-project-be-staticlib-and-not-mh-dylib-for-c-targets/24458/2 "2019-05-13T05:16:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![George](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/george/32/37757_2.png) [@George](https://forums.swift.org/u/George)\
**Post date:** [May 15, 2019, 1:43am UTC](https://forums.swift.org/t/should-the-mach-o-type-in-a-generated-xcode-project-be-staticlib-and-not-mh-dylib-for-c-targets/24458/3 "2019-05-15T01:43:23Z")

</div>

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`.
