Skip to content

Commit 336fced

Browse files
committed
Adds Swift Package Manager support and removes Cocoapods.
1 parent 842f251 commit 336fced

3 files changed

Lines changed: 68 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ build.local.sh
2323
/.vs*
2424
/*build*
2525
/nbproject
26+
/.swiftpm
2627

2728
# Autotools
2829
autom4te.cache

Package.swift

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// swift-tools-version: 5.10
2+
3+
import PackageDescription
4+
5+
/// Cocoapods to SPM Notes:
6+
/// My goal is to to minimal changes to support SPM since this is a fork of OSGeo/PROJ.
7+
///
8+
/// * Creating a custom module.modulemap seems to fix build issues when using the proj.h header
9+
/// * The public interface is C for the proj.h API we use, so we don't need to use the C++ headers exposed
10+
/// * The C++ header search paths are added so under the hood we can find the headers.
11+
/// * The 9.4_release_spm does not include proj.db, since with Bundles, we need to load resources in the
12+
/// package that requires it. So projections-ios loads the proj.db from it's own bundle. (In Cocoapods you could
13+
/// reach into other bundles, but not with SPM)
14+
/// * Potentially the 9.6_release_spm can provided proj.db in source, but I haven't figured how that integrates.
15+
/// * CMake autogenerates some files that need to be added like "proj_config.h" (9.6 has more autogenerated files)
16+
17+
let package = Package(
18+
name: "proj",
19+
platforms: [
20+
.iOS(.v13), .macOS(.v12)
21+
],
22+
products: [
23+
.library(
24+
name: "proj",
25+
type: .static,
26+
targets: ["proj"]
27+
),
28+
],
29+
targets: [
30+
.target(
31+
name: "proj",
32+
path: "src",
33+
exclude: [
34+
"apps",
35+
"tests",
36+
"CMakeLists.txt",
37+
"lib_proj.cmake",
38+
"check_md5sum.cmake",
39+
"generate_wkt_parser.cmake",
40+
"general_doc.dox",
41+
"wkt1_grammar.y",
42+
"wkt2_grammar.y",
43+
],
44+
resources: [
45+
],
46+
publicHeadersPath: ".", // The C header files are mixed with src files, we use a modulemap.module to load "proj.h"
47+
cxxSettings: [
48+
.headerSearchPath("../include"),
49+
.headerSearchPath("../include/proj"),
50+
.headerSearchPath("../include/proj/internal"),
51+
.headerSearchPath("../include/proj/internal/vendor/nlohmann"),
52+
],
53+
linkerSettings: [
54+
.linkedLibrary("c++"),
55+
.linkedLibrary("sqlite3"),
56+
]
57+
)
58+
],
59+
cxxLanguageStandard: .cxx11
60+
)

src/module.modulemap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module proj {
2+
// Include the header, but not as an `umbrella header "proj.h"`, since it doesn't include all headers in src folder
3+
// The src directory has a C header API and the implementation is C++ under the hood.
4+
header "proj.h"
5+
6+
export *
7+
}

0 commit comments

Comments
 (0)