Invalid XCFramweork when generated with BUILD_LIBRARY_FOR_DISTRIBUTION=YES

Hi all,

I'm attempting to generate an XCFramework that must maintain ABI stability. The framework is created from an SPM using the attached script generate-FK.sh.

I does not work. Removing the flag BUILD_LIBRARY_FOR_DISTRIBUTION=YES and adding the flag -allow-internal-distribution to xcodebuild -create-xcframework everything is fine. Despite this resolves the problem, it results in the generated module not being ABI stable. However, when attempting the script approach, it generates the XCFramework but when used it raises an error in arm64-apple-ios-private.swiftinterface with no such file or module as soon as it encounters an import statement for ModuleX reading it.

The package structure is attached as Package.swift and te obtained result XCFramework structure is as follows:

MyLibrary.xcframework
├── Info.plist
├── ios-arm64
│   └── MyLibrary.framework
│       ├── Headers
│       │   ├── ModuleH-Swift.h
│       │   ├── ModuleH.modulemap
│       │   ├── ModuleC-Swift.h
│       │   ├── ModuleC.modulemap
│       │   ├── ModuleA-Swift.h
│       │   ├── ModuleA.modulemap
│       │   ├── MyLibrary-Swift.h
│       │   └── MyLibrary.modulemap
│       ├── Info.plist
│       ├── Modules
│       │   └── MyLibrary.swiftmodule
│       │       ├── arm64-apple-ios.abi.json
│       │       ├── arm64-apple-ios.swiftdoc
│       │       └── arm64-apple-ios.swiftmodule
│       └── MyLibrary
└── ios-arm64_x86_64-simulator
    └── MyLibrary.framework
        ├── Headers
        │   ├── ModuleH-Swift.h
        │   ├── ModuleH.modulemap
        │   ├── ModuleC-Swift.h
        │   ├── ModuleC.modulemap
        │   ├── ModuleA-Swift.h
        │   ├── ModuleA.modulemap
        │   ├── MyLibrary-Swift.h
        │   └── MyLibrary.modulemap
        ├── Info.plist
        ├── Modules
        │   └── MyLibrary.swiftmodule
        │       ├── arm64-apple-ios-simulator.abi.json
        │       ├── arm64-apple-ios-simulator.swiftdoc
        │       ├── arm64-apple-ios-simulator.swiftmodule
        │       ├── x86_64-apple-ios-simulator.abi.json
        │       ├── x86_64-apple-ios-simulator.swiftdoc
        │       └── x86_64-apple-ios-simulator.swiftmodule
        ├── MyLibrary
        └── _CodeSignature
            └── CodeResources

It's worth mentioning that the library must be compatible with both Objective-C and Swift, and Modules A, C, and H are imported into the MyLibrary module as @_exported modules, that is why I've included the headers and module maps.

What is wrong?

Thank you in advance for your assistance.

Invalid XCFramweork when generated with BUILD_LIBRARY_FOR_DISTRIBUTION=YES
 
 
Q