4

I created a really simple Swift package, that contain only a few Objective-C source files, but when I try to build another project that it, it fail compiling because:

ld: bitcode bundle could not be generated because 'MySwiftPackage.o' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build file 'MySwiftPackage.o' for architecture arm64

I also tried to force Bitcode to be enable by adding settings: cSettings: [.define("OTHER_CFLAGS", to: "-fembed-bitcode")] and .define("ENABLE_BITCODE", to: "YES") with no luck.

How can I identify what is causing the bitcode to be disabled ?

Here is my package.swift:

let package = Package(
    name: "MySwiftPackage",
    platforms: [.iOS(.v11)],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "MySwiftPackage",
            targets: ["MySwiftPackage"]),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "MySwiftPackage",
            publicHeadersPath: "Public",
            cSettings: [
                .headerSearchPath("Internal")
            ])
    ]
)
Leguman
  • 2,104
  • 1
  • 18
  • 22
  • You are not telling it to compile with full bitcode. I haven't done it in a package before, but in a normal project you go into the build settings and set bitcode mode – Scriptable Aug 09 '21 at 15:11
  • I've tried forcing the Bitcode option through `cSettings: [.define("OTHER_CFLAGS", to: "-fembed-bitcode")]` and `.define("ENABLE_BITCODE", to: "YES")` but it doesn't seems to change anything. It seems that SPM enable Bitcode by default – Leguman Aug 09 '21 at 15:17
  • that info would of been handy to put in your question – Scriptable Aug 09 '21 at 15:28
  • You're right, I'll add it, thanks – Leguman Aug 09 '21 at 15:40
  • Have you resolved this? I'm running into a similar issue. – Jake Sep 14 '21 at 19:16
  • Do you get this warning when adding the package to a project/target? If so, have you tried editing the `build settings` to enable `ENABLE_BITCODE`for that target? – vicegax Feb 21 '22 at 11:19

0 Answers0