Skip to content

Instantly share code, notes, and snippets.

@harlanhaskins
Created January 16, 2017 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harlanhaskins/739a86b0bdea465890f3466190c1ccd1 to your computer and use it in GitHub Desktop.
Save harlanhaskins/739a86b0bdea465890f3466190c1ccd1 to your computer and use it in GitHub Desktop.

SwiftPM C++ Source File Support

Introduction

Swift Package Manager is currently able to compile C and Objective-C source files as targets. We wish to extend this to C++ source files, allowing developers to interface with existing C++ libraries and expose C APIs that can be consumed in Swift.

swift-evolution thread

Motivation

It's common for developers to mix C and C++ in projects, especially if they use a system C++ library. Unfortunately, SwiftPM cannot facilitate these kinds of projects, because it is not able to differentiate C++ and C files within the same target.

Proposed Solution

Teach SwiftPM how to compile C++ and Objective-C++ files, and provide a -Xcxx flag to pass arguments to clang++.

Detailed Design

Impact on Existing Code

This proposal is additive, so it will not affect existing C or Objective-C targets.

Alternatives Considered

Unsolved Problems

Future Directions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment