Thank you for your quick response.
I am using libiconv in Swift.
To use it with Swift, I have bundled libiconv as an xcframework.
It seems that when compiling C sources with Swift, the system libraries are included automatically.
Here are the detailed build logs:
```
❯ swift build -vv
Downloading binary artifact https://github.com/sidepelican/xciconv/releases/download/1.17.1/libiconv.xcframework.zip
info: credentials for https://github.com/sidepelican/xciconv/releases/download/1.17.1/libiconv.xcframework.zip found in keychain
[16384/3832430] Downloading https://github.com/sidepelican/xciconv/releases/download/1.17.1/libiconv.xcframework.zip
info: found binary artifact: '(<AbsolutePath:"/Users/iceman/projects/xciconv/.build/artifacts/xciconv/libiconv/libiconv.xcframework">, PackageModel.BinaryTarget.Kind.xcframework)'
Downloaded https://github.com/sidepelican/xciconv/releases/download/1.17.1/libiconv.xcframework.zip (1.81s)
Building for debugging...
Copying /Users/iceman/projects/xciconv/.build/artifacts/xciconv/libiconv/libiconv.xcframework/macos-arm64_x86_64/libiconv.framework
/Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name test -incremental -emit-dependencies -emit-module -emit-module-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/test.swiftmodule -output-file-map /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/test.build/output-file-map.json -c /Users/iceman/projects/xciconv/Sources/test/main.swift -I /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug -target arm64-apple-macosx12.0 -swift-version 5 -v -enable-batch-mode -index-store-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/index/store -Onone -enable-testing -g -j8 -DSWIFT_PACKAGE -DDEBUG -I /Users/iceman/projects/xciconv/.build/artifacts/xciconv/libiconv/libiconv.xcframework/macos-arm64_x86_64 -Xcc -I -Xcc /Users/iceman/projects/xciconv/.build/artifacts/xciconv/libiconv/libiconv.xcframework/macos-arm64_x86_64 -module-cache-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/ModuleCache -parseable-output -Xfrontend -entry-point-function-name -Xfrontend test_main -F /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug -color-diagnostics -sdk /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -F /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -I /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -L /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -Xcc -isysroot -Xcc /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -Xcc -F -Xcc /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC
Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx12.0
/Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/iceman/projects/xciconv/Sources/test/main.swift -emit-dependencies-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/test.build/main.d -emit-reference-dependencies-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/test.build/main.swiftdeps -target arm64-apple-macosx12.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -I /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug -I /Users/iceman/projects/xciconv/.build/artifacts/xciconv/libiconv/libiconv.xcframework/macos-arm64_x86_64 -I /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug -F /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -module-cache-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -entry-point-function-name test_main -empty-abi-descriptor -resource-dir /Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -I -Xcc /Users/iceman/projects/xciconv/.build/artifacts/xciconv/libiconv/libiconv.xcframework/macos-arm64_x86_64 -Xcc -isysroot -Xcc /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -Xcc -F -Xcc /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -module-name test -disable-clang-spi -target-sdk-version 14.0 -target-sdk-name macosx14.0 -external-plugin-path /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift/host/plugins#/Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/test.build/main.swift.o -index-store-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/index/store -index-system-modules
/Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Users/iceman/projects/xciconv/Sources/test/main.swift -target arm64-apple-macosx12.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -I /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug -I /Users/iceman/projects/xciconv/.build/artifacts/xciconv/libiconv/libiconv.xcframework/macos-arm64_x86_64 -I /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug -F /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -module-cache-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -entry-point-function-name test_main -empty-abi-descriptor -resource-dir /Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -I -Xcc /Users/iceman/projects/xciconv/.build/artifacts/xciconv/libiconv/libiconv.xcframework/macos-arm64_x86_64 -Xcc -isysroot -Xcc /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -Xcc -F -Xcc /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -module-name test -disable-clang-spi -target-sdk-version 14.0 -target-sdk-name macosx14.0 -external-plugin-path /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift/host/plugins#/Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -emit-module-doc-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/test.swiftdoc -emit-module-source-info-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/test.swiftsourceinfo -emit-dependencies-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/test.build/test.emit-module.d -o /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/test.swiftmodule -emit-abi-descriptor-path /Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/test.abi.json
/Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/libiconv.framework/Headers/iconv.h:122:13: error: '(anonymous struct)::dummy2' from module 'libiconv' is not present in definition of 'iconv_allocation_t' in module 'Darwin.POSIX.iconv'
mbstate_t dummy2;
^
/Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/iconv.h:90:9: note: definition has no member 'dummy2'
typedef struct {
^
/Users/iceman/projects/xciconv/.build/arm64-apple-macosx/debug/libiconv.framework/Headers/iconv.h:120:9: error: '(anonymous struct)::dummy1' from module 'libiconv' is not present in definition of 'iconv_allocation_t' in module 'Darwin.POSIX.iconv'
void* dummy1[28];
^
/Applications/Xcode_15.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/iconv.h:90:9: note: definition has no member 'dummy1'
typedef struct {
^
error: fatalError
```
The steps to reproduce my issue are as follows:
1. Download the source code from https://github.com/sidepelican/xciconv
2. Execute the `swift build` command (in root directory)
The `./build.sh` inside the same repository is used to build the xcframework.
My macOS version is 13.6.1 (22G313), and I'm using the M2 chip.