2 years ago

#4571

test-img

AhsokaTano

Swift Package Mixed Language does not compile

I have searched lengthely for the solution to my problem, thus before changing strategy, I decide to ask here.

What I need is a mixed language Swift Package using Swift, c++ and Objective-C++. But, I always get the following error when I compile it: 'cstdlib' file not found. Same error happens for several other standard c++ libraries included in my TestSwiftPackage.hpp file.

The project that I am trying to move to Swift Package works perfectly. Thus, I have tried using the same c++ build settings in my Package.swift, such as :

  • cSettings with headerSearchPath,
  • cxxSettings with unsafeFlags,
  • linkerSettings with linkedLibrary,
  • etc...

But, I keep running into the same compilation bug.

The example project can be found here: https://drive.google.com/drive/folders/1U0dtcd5aaAreg5rs3bQC8JlF8IwnXIM4?usp=sharing

bug bug

Package.swift file:

// swift-tools-version:5.5
import PackageDescription

let package = Package(
   
   name: "TestSwiftPackage",
   products: [
       .library(
           name: "TestSwiftPackage",
           targets: ["TestSwiftPackage"]),
   ],
   dependencies: [],
   targets: [
       .target(
           name: "TestSwiftPackage",
           dependencies: ["TestSwiftPackageC"]
       ),
       .target(
           name: "TestSwiftPackageC",
           dependencies: []
       ),
       .testTarget(
           name: "TestSwiftPackageTests",
           dependencies: ["TestSwiftPackage"]),
   ],
   cLanguageStandard: .gnu11,
   cxxLanguageStandard: .gnucxx11
)

c++

swift

xcode

objective-c++

swift-package-manager

0 Answers

Your Answer

Accepted video resources