Skip to content

Commit

Permalink
Support Apple's Swift Package Manager
Browse files Browse the repository at this point in the history
**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.
  • Loading branch information
Aleksei committed May 26, 2023
1 parent a0c1318 commit 3313f7d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@
/localhost.pem
/localhost-key.pem
/serve_header.yml

# Swift Package Manager build directory
/.build
22 changes: 22 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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
)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,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).
Expand Down
3 changes: 3 additions & 0 deletions single_include/nlohmann/apple/_SwiftPackageManagerFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Umbrella source file for the Swift Package Manager

#include <json.hpp>

0 comments on commit 3313f7d

Please sign in to comment.