From 58d6aa58316a84fc770bdd0409934cdfdf0697dc Mon Sep 17 00:00:00 2001 From: Aleksei Sapitskii <45671572+aleksproger@users.noreply.github.com> Date: Sat, 21 Oct 2023 20:41:10 +0300 Subject: [PATCH] Support Apple's Swift Package Manager (#4010) Co-authored-by: Aleksei --- .gitignore | 3 +++ Package.swift | 22 ++++++++++++++++++++++ README.md | 2 ++ 3 files changed, 27 insertions(+) create mode 100644 Package.swift diff --git a/.gitignore b/.gitignore index 30b62bfcf..bfd52b4c6 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ /localhost.pem /localhost-key.pem /serve_header.yml + +# Swift Package Manager build directory +/.build \ No newline at end of file diff --git a/Package.swift b/Package.swift new file mode 100644 index 000000000..2f9c4a1f4 --- /dev/null +++ b/Package.swift @@ -0,0 +1,22 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "nlohmann-json", + platforms: [ + .iOS(.v12), .macOS(.v10_13), .tvOS(.v12), .watchOS(.v4) + ], + products: [ + .library(name: "json", targets: ["json"]) + ], + targets: [ + .target( + name: "json", + path: "single_include/nlohmann", + publicHeadersPath: "." + ) + ], + cxxLanguageStandard: .cxx11 +) diff --git a/README.md b/README.md index 43aacf4d5..6cf57bd52 100644 --- a/README.md +++ b/README.md @@ -1338,6 +1338,8 @@ If you are using [cget](https://cget.readthedocs.io/en/latest/), you can install If you are using [CocoaPods](https://cocoapods.org), you can use the library by adding pod `"nlohmann_json", '~>3.1.2'` to your podfile (see [an example](https://bitbucket.org/benman/nlohmann_json-cocoapod/src/master/)). Please file issues [here](https://bitbucket.org/benman/nlohmann_json-cocoapod/issues?status=new&status=open). +If you are using [Swift Package Manager](https://swift.org/package-manager/), you can use the library by adding a package dependency to this repository. And target dependency as `.product(name: "nlohmann-json", package: "json")`. + If you are using [NuGet](https://www.nuget.org), you can use the package [nlohmann.json](https://www.nuget.org/packages/nlohmann.json/). Please check [this extensive description](https://github.com/nlohmann/json/issues/1132#issuecomment-452250255) on how to use the package. Please file issues [here](https://github.com/hnkb/nlohmann-json-nuget/issues). If you are using [conda](https://conda.io/), you can use the package [nlohmann_json](https://github.com/conda-forge/nlohmann_json-feedstock) from [conda-forge](https://conda-forge.org) executing `conda install -c conda-forge nlohmann_json`. Please file issues [here](https://github.com/conda-forge/nlohmann_json-feedstock/issues).