From 5783217ba2f02dd18395240c07b30eca3f3c34fe Mon Sep 17 00:00:00 2001 From: Aleksei Date: Thu, 13 Apr 2023 20:16:33 +0300 Subject: [PATCH 1/3] Support Apple's Swift Package Manager **Reason** - Main way to develop under Apple's platforms is using SPM **Changes** - Added Package.swift - Added _SwiftPackageManagerFile.cpp to single_include/nlohmann in order SPM to see it as a C++ source file - Added .build to .gitignore **Context** - SPM is a package manager for Swift and C-based languages. It is the main way to develop under Apple's platforms. It is also used to build Swift packages for Linux. --- .gitignore | 3 +++ Package.swift | 22 +++++++++++++++++++ README.md | 2 ++ .../apple/_SwiftPackageManagerFile.cpp | 3 +++ 4 files changed, 30 insertions(+) create mode 100644 Package.swift create mode 100644 single_include/nlohmann/apple/_SwiftPackageManagerFile.cpp diff --git a/.gitignore b/.gitignore index 30b62bfcf9..bfd52b4c66 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 0000000000..cf1a7b83f4 --- /dev/null +++ b/Package.swift @@ -0,0 +1,22 @@ +// swift-tools-version: 5.7 +// 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(.v11), .macOS(.v10_13), .tvOS(.v11), .watchOS(.v4) + ], + products: [ + .library(name: "nlohmann-json", targets: ["nlohmann-json"]) + ], + targets: [ + .target( + name: "nlohmann-json", + path: "single_include/nlohmann", + publicHeadersPath: "." + ) + ], + cxxLanguageStandard: .cxx11 +) diff --git a/README.md b/README.md index 43aacf4d55..6cf57bd520 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). diff --git a/single_include/nlohmann/apple/_SwiftPackageManagerFile.cpp b/single_include/nlohmann/apple/_SwiftPackageManagerFile.cpp new file mode 100644 index 0000000000..a296b8fb37 --- /dev/null +++ b/single_include/nlohmann/apple/_SwiftPackageManagerFile.cpp @@ -0,0 +1,3 @@ +// Umbrella source file for the Swift Package Manager + + #include \ No newline at end of file From 38434447ff6f578d6c2405b5e83534feed1e352a Mon Sep 17 00:00:00 2001 From: Aleksei Date: Fri, 26 May 2023 08:34:53 +0300 Subject: [PATCH 2/3] Use SPM 5.8 --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index cf1a7b83f4..1998dea0f1 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.7 +// swift-tools-version: 5.8 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription From 68e0db7f70d2d1dfa51ad1f083b5cf2ddfc33eb1 Mon Sep 17 00:00:00 2001 From: Aleksei Sapitskii Date: Wed, 4 Oct 2023 21:05:18 +0300 Subject: [PATCH 3/3] Adopt for Swift 5.9 --- Package.swift | 2 +- single_include/nlohmann/apple/_SwiftPackageManagerFile.cpp | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 single_include/nlohmann/apple/_SwiftPackageManagerFile.cpp diff --git a/Package.swift b/Package.swift index 1998dea0f1..7b1ca7ef2a 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.8 +// swift-tools-version: 5.9 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/single_include/nlohmann/apple/_SwiftPackageManagerFile.cpp b/single_include/nlohmann/apple/_SwiftPackageManagerFile.cpp deleted file mode 100644 index a296b8fb37..0000000000 --- a/single_include/nlohmann/apple/_SwiftPackageManagerFile.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// Umbrella source file for the Swift Package Manager - - #include \ No newline at end of file