Skip to content

Instantly share code, notes, and snippets.

@alimovlex
Last active February 15, 2023 16:42
Show Gist options
  • Select an option

  • Save alimovlex/e8fbbb38c1de430cb5fa811154edd3a4 to your computer and use it in GitHub Desktop.

Select an option

Save alimovlex/e8fbbb38c1de430cb5fa811154edd3a4 to your computer and use it in GitHub Desktop.
The Swift's package linker with C/C++ library
// swift-tools-version:4.0
/*
* Copyright (C) 2023 Recompile.me.
* All rights reserved.
*/
import PackageDescription
let package = Package(
name: "SwiftCPP", //your project's name where the main.swift is stored. It is similar to the folder's name.
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "LibraryCPP", //your C/C++ library's name
targets: ["LibraryCPP"]), //your C/C++ library's name
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
.target(
name: "LibraryCPP", //your C/C++ library's name
path: "Sources/LibraryCPP" //your path to the C/C++ library
),
.target(
name: "SwiftCPP", //your project's name
dependencies: ["LibraryCPP"]), //your Library's name
.testTarget(
name: "SwiftCPPTests", //your project's test name in the Tests folder
dependencies: ["SwiftCPP", "LibraryCPP"]), //linking the C/C++ library with the Swift package module for testing
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment