dd-sdk-ios icon indicating copy to clipboard operation
dd-sdk-ios copied to clipboard

Cannot build DataDog with SPM as a dependency in a private framework

Open mergesort opened this issue 6 months ago • 0 comments

Describe the bug

I have a reasonably complex project (30-40,000 LOC) and a rather modularized app. Unfortunately after I added a dynamic library (required for AppIntents to be modularized, I cannot get DataDog to build properly. If I do not import the DataDog package, my new framework will build just fine, but when I add it (transitively as a dependency), the framework stops building.

Reproduction steps

I'm seeing a similar error message to #1085, and tried to apply the fix of adding -Xcc -fmodule-map-file=\"$(GENERATED_MODULEMAP_DIR)/_Datadog_Private.modulemap\" flags.

The shape of the packages and frameworks that cause this issue are approximately:

  • A static SPM framework (let's call this SPM A)
  • A dynamic SPM library (let's call this SPM B)
  • A dynamic library (let's call this Library A)
  • Two targets, an iOS app and a widget

The dependency tree looks like so:

  • iOS app imports Library A
  • Library A imports SPM B
  • SPM B imports SPM A
  • SPM A imports DataDog, like so
import PackageDescription

let package = Package(
    name: "PlinkyLogging",
    platforms: [
        .iOS(.v17),
        .macOS(.v13)
    ],
    products: [
        .library(
            name: "PlinkyLogging",
            targets: ["PlinkyLogging"]
        )
    ],
    dependencies: [
        .package(url: "https://github.com/Datadog/dd-sdk-ios.git", exact: Version(2, 15, 0)),
        .package(path: "../Scribbles")
    ],
    targets: [
        .target(
            name: "PlinkyLogging",
            dependencies: [
                .product(name: "DatadogCore", package: "dd-sdk-ios", condition: .when(platforms: [.iOS])),
                .product(name: "DatadogLogs", package: "dd-sdk-ios", condition: .when(platforms: [.iOS])),
                .product(name: "Scribbles", package: "Scribbles")
            ]
        )
    ]
)

SDK logs

When I try to build this tree structure, I get these error messages. (Where PlinkyAppIntents is equivalent to Library A.)

<unknown>:0: error: missing required module 'DatadogPrivate'
/Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/Objects-normal/arm64/PlinkyAppIntents.private.swiftinterface:1:1: error: failed to verify module interface of 'PlinkyAppIntents' due to the errors above; the textual interface may be broken by project issues or a compiler bug
// swift-interface-format-version: 1.0

The full error log looks like this.

SwiftVerifyEmittedModuleInterface normal arm64 Verifying\ emitted\ module\ interface\ PlinkyAppIntents.swiftinterface /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/Objects-normal/arm64/PlinkyAppIntents.swiftinterface (in target 'PlinkyAppIntents' from project 'Plinky')
    cd /Users/mergesort/Developer/Plinky
    builtin-swiftTaskExecution -- /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -typecheck-module-from-interface /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/Objects-normal/arm64/PlinkyAppIntents.swiftinterface -target arm64-apple-ios17.2-simulator -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.1.sdk -I /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/PackageFrameworks -F /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator -no-color-diagnostics -enable-library-evolution -enable-testing -g -debug-info-format\=dwarf -dwarf-version\=4 -module-cache-path /Users/mergesort/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity\=checked -Onone -D DEBUG -D DEBUG -serialize-debugging-options -const-gather-protocols-file /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/Objects-normal/arm64/PlinkyAppIntents_const_extract_protocols.json -enable-experimental-feature DebugDescriptionMacro -enable-experimental-feature OpaqueTypeErasure -enable-bare-slash-regex -validate-clang-modules-once -clang-build-session-file /Users/mergesort/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/mergesort/Developer/Plinky -resource-dir /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/mergesort/Developer/Plinky -Xcc -fmodule-map-file\=/Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/GeneratedModuleMaps-iphonesimulator/DatadogPrivate.modulemap -Xcc -D_LIBCPP_HARDENING_MODE\=_LIBCPP_HARDENING_MODE_DEBUG -Xcc -ivfsstatcache -Xcc /Users/mergesort/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator18.1-22B5023b-f62f332bdfa1a9e81825a8fb829964d1.sdkstatcache -Xcc -I/Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/PlinkyAppIntents-generated-files.hmap -Xcc -I/Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/PlinkyAppIntents-own-target-headers.hmap -Xcc -I/Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/PlinkyAppIntents-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/Plinky-55f32dabc6dadfc07dccd87fc9b8887c-VFS-iphonesimulator/all-product-headers.yaml -Xcc -iquote -Xcc /Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/PlinkyAppIntents-project-headers.hmap -Xcc -I/Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/SourcePackages/checkouts/dd-sdk-ios/DatadogCore/Private/include -Xcc -I/Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/DerivedSources-normal/arm64 -Xcc -I/Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/DerivedSources/arm64 -Xcc -I/Users/mergesort/Library/Developer/Xcode/DerivedData/Plinky-erlmwxneafajiwamkoqolwxeqxmz/Build/Intermediates.noindex/Plinky.build/Debug-iphonesimulator/PlinkyAppIntents.build/DerivedSources -Xcc -DDEBUG\=1 -module-name PlinkyAppIntents -frontend-parseable-output -disable-clang-spi -target-sdk-version 18.1 -target-sdk-name iphonesimulator18.1 -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/swift/host/plugins\#/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/local/lib/swift/host/plugins\#/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins

Command SwiftVerifyEmittedModuleInterface failed with a nonzero exit code

Expected behavior

I would expect the library to build. I've tried all of the usual debugging steps, clean, build, wipe derived data, reboot, etc.

Affected SDK versions

2.15.0

Latest working SDK version

I haven't tried old versions with this structure.

Did you confirm if the latest SDK version fixes the bug?

Yes

Integration Methods

SPM

Xcode Version

Version 16.1 beta (16B5001e) — but was possibly broken before.

Swift Version

Swift 6.0

MacOS Version

14.5

Deployment Target

iOS 17

Device Information

No response

Other relevant information

No response

mergesort avatar Aug 14 '24 21:08 mergesort