Skip to content

[Bug]: Incompatible with warnings as errors when built through Xcode #532

@Obbut

Description

@Obbut

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

  1. Create an Xcode project with a target that depends on Containerization
  2. Enable SWIFT_TREAT_WARNINGS_AS_ERRORS = YES on the target
  3. Build

The issue does not occur when building via SPM with .treatAllWarnings(as: .error).

To quickly reproduce this using Xcodegen:

mkdir -p /tmp/containerization-zstd-repro/Sources/MyLib

cat > /tmp/containerization-zstd-repro/Sources/MyLib/MyLib.swift << 'EOF'
import Containerization

public struct MyLib {
    public init() {}
}
EOF

cat > /tmp/containerization-zstd-repro/project.yml << 'EOF'
name: ZstdRepro
options:
  bundleIdPrefix: com.test
packages:
  containerization:
    url: https://github.com/apple/containerization
    exactVersion: "0.25.1"
targets:
  ZstdRepro:
    type: framework
    platform: macOS
    deploymentTarget: "26.0"
    sources:
      - Sources/MyLib
    dependencies:
      - package: containerization
        product: Containerization
    settings:
      SWIFT_TREAT_WARNINGS_AS_ERRORS: YES
EOF

cd /tmp/containerization-zstd-repro
xcodegen generate
xcodebuild -project ZstdRepro.xcodeproj -scheme ZstdRepro -destination 'platform=macOS' build

Current behavior

The build fails with errors originating from zstd's module.modulemap:

<unknown>:0: error: definition of configuration macro 'ZSTDLIB_VISIBLE' has no effect on the import of 'libzstd'; pass '-DZSTDLIB_VISIBLE=...' on the command line to configure the module
/Users/robbert/Library/Developer/Xcode/DerivedData/ZstdRepro-cmbtortrvhygntcubcdbmijtgeye/SourcePackages/checkouts/zstd/lib/zstd.h:33:13: note: macro was defined here
#    define ZSTDLIB_VISIBLE __attribute__ ((visibility ("default")))
            ^
<unknown>:0: error: definition of configuration macro 'ZSTDLIB_HIDDEN' has no effect on the import of 'libzstd'; pass '-DZSTDLIB_HIDDEN=...' on the command line to configure the module
/Users/robbert/Library/Developer/Xcode/DerivedData/ZstdRepro-cmbtortrvhygntcubcdbmijtgeye/SourcePackages/checkouts/zstd/lib/zstd.h:41:13: note: macro was defined here
#    define ZSTDLIB_HIDDEN __attribute__ ((visibility ("hidden")))
            ^
<unknown>:0: error: definition of configuration macro 'ZSTD_CLEVEL_DEFAULT' has no effect on the import of 'libzstd'; pass '-DZSTD_CLEVEL_DEFAULT=...' on the command line to configure the module
/Users/robbert/Library/Developer/Xcode/DerivedData/ZstdRepro-cmbtortrvhygntcubcdbmijtgeye/SourcePackages/checkouts/zstd/lib/zstd.h:134:11: note: macro was defined here
#  define ZSTD_CLEVEL_DEFAULT 3
          ^
<unknown>:0: error: definition of configuration macro 'ZDICTLIB_VISIBLE' has no effect on the import of 'libzstd'; pass '-DZDICTLIB_VISIBLE=...' on the command line to configure the module
/Users/robbert/Library/Developer/Xcode/DerivedData/ZstdRepro-cmbtortrvhygntcubcdbmijtgeye/SourcePackages/checkouts/zstd/lib/zdict.h:28:13: note: macro was defined here
#    define ZDICTLIB_VISIBLE __attribute__ ((visibility ("default")))
            ^
<unknown>:0: error: definition of configuration macro 'ZDICTLIB_HIDDEN' has no effect on the import of 'libzstd'; pass '-DZDICTLIB_HIDDEN=...' on the command line to configure the module
/Users/robbert/Library/Developer/Xcode/DerivedData/ZstdRepro-cmbtortrvhygntcubcdbmijtgeye/SourcePackages/checkouts/zstd/lib/zdict.h:36:13: note: macro was defined here
#    define ZDICTLIB_HIDDEN __attribute__ ((visibility ("hidden")))
            ^
<unknown>:0: error: definition of configuration macro 'ZSTDERRORLIB_VISIBLE' has no effect on the import of 'libzstd'; pass '-DZSTDERRORLIB_VISIBLE=...' on the command line to configure the module
/Users/robbert/Library/Developer/Xcode/DerivedData/ZstdRepro-cmbtortrvhygntcubcdbmijtgeye/SourcePackages/checkouts/zstd/lib/zstd_errors.h:24:13: note: macro was defined here
#    define ZSTDERRORLIB_VISIBLE __attribute__ ((visibility ("default")))
            ^
<unknown>:0: error: definition of configuration macro 'ZSTDERRORLIB_HIDDEN' has no effect on the import of 'libzstd'; pass '-DZSTDERRORLIB_HIDDEN=...' on the command line to configure the module
/Users/robbert/Library/Developer/Xcode/DerivedData/ZstdRepro-cmbtortrvhygntcubcdbmijtgeye/SourcePackages/checkouts/zstd/lib/zstd_errors.h:32:13: note: macro was defined here
#    define ZSTDERRORLIB_HIDDEN __attribute__ ((visibility ("hidden")))

The root cause is fixed in facebook/zstd#4531, but Containerization pins zstd at exact: "1.5.7" which does not include the fix.

Expected behavior

Importing Containerization should not produce warnings, so that Xcode targets can use warnings-as-errors without issue.

Environment

- OS: macOS 26.3
- Xcode: 26.3
- Swift: 6.2

Relevant log output

N/A

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions