Skip to content

Commit 2d242f9

Browse files
committed
Adds Swift Package Manager (SPM) support.
* Fixes flakey tests * Updated resource loading for proj.db * Reorganizes files for SPM layout and public headers * Updates build notes
1 parent 9d2d0ae commit 2d242f9

36 files changed

+180
-102
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ Pods
55
xcuserdata/
66
*.swp
77
Carthage/
8+
.build/
9+
.swiftpm/

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ Adheres to [Semantic Versioning](http://semver.org/).
44

55
---
66

7-
## 2.0.4 (TBD)
7+
8+
## 3.0.0
9+
* Refactored to support Swift Package Manager because Cocoapods are deprecated
10+
* Restructuring files to better align with SPM format and updating header includes
811

912
* TBD
1013

Cartfile

Whitespace-only changes.

Cartfile.resolved

Whitespace-only changes.

Package.resolved

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// swift-tools-version: 5.10
2+
import PackageDescription
3+
4+
/// Cocoapods to SPM Conversion Notes
5+
/// * Using name: `proj-ios` causes issues with resource loading in Objective-C with [SWIFTPM_MODULE_BUNDLE pathForResource:resource ofType:type]; (The `-` become `_`)
6+
/// * Moved `proj.db` into this package since it gets loaded here for actual usage, not in PROJ (Access to resources is limited in SPM vs cocoapods)
7+
/// * Reorganized headers into include folder and resources into Resources
8+
9+
let package = Package(
10+
name: "projections",
11+
platforms: [
12+
.iOS(.v13), .macOS(.v13)
13+
],
14+
products: [
15+
.library(
16+
name: "projections",
17+
type: .static,
18+
// type: .dynamic,
19+
targets: ["projections"]
20+
)
21+
],
22+
dependencies: [
23+
.package(url: "https://github.com/ngageoint/PROJ.git", branch: "9.4.0_release_spm"),
24+
// .package(name: "PROJ", path: "../PROJ"),
25+
// .package(url: "https://github.com/ngageoint/PROJ.git", branch: "9.6_release_spm"),
26+
27+
.package(url: "https://github.com/ngageoint/coordinate-reference-systems-ios.git", branch: "psolt/package"),
28+
// .package(name: "coordinate-reference-systems-ios", path: "../coordinate-reference-systems-ios")
29+
],
30+
31+
targets: [
32+
.target(
33+
name: "projections",
34+
dependencies: [
35+
.product(name: "proj", package: "PROJ"),
36+
.product(name: "crs-ios", package: "coordinate-reference-systems-ios"),
37+
],
38+
path: "proj-ios",
39+
exclude: [
40+
],
41+
resources: [
42+
.copy("Resources/proj.db"),
43+
.copy("Resources/projections.ogc.plist"),
44+
.copy("Resources/projections.none.plist"),
45+
.copy("Resources/projections.epsg.plist")
46+
],
47+
publicHeadersPath: "include/Projections"
48+
),
49+
.testTarget(
50+
name: "proj-iosTests",
51+
dependencies: [
52+
"projections",
53+
],
54+
path: "proj-iosTests",
55+
exclude: [
56+
"Info.plist",
57+
],
58+
sources: ["."],
59+
resources: [
60+
],
61+
cSettings: [
62+
// .headerSearchPath("../include/proj"),
63+
]
64+
),
65+
.testTarget(
66+
name: "proj-iosTests-swift",
67+
dependencies: [
68+
"projections",
69+
],
70+
path: "proj-iosTests-swift",
71+
sources: ["."],
72+
resources: [
73+
]
74+
),
75+
]
76+
)
77+
78+

docs/release.txt

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11

2-
Xcode Build:
3-
4-
xcodebuild -workspace 'proj-ios.xcworkspace' -scheme proj-ios build
5-
6-
Xcode Test:
7-
8-
xcodebuild test -workspace 'proj-ios.xcworkspace' -scheme proj-ios -destination 'platform=iOS Simulator,name=iPhone 15'
2+
Swift Build & Test:
93

10-
CocoaPods Local Lint:
4+
swift build
5+
swift test
116

12-
pod lib lint proj-ios.podspec --use-libraries
13-
14-
CocoaPods GitHub Release Lint:
15-
16-
pod spec lint proj-ios.podspec --use-libraries
7+
Xcode Build:
178

18-
CocoaPods Deploy To Trunk:
9+
open Package.swift
10+
Command + B
1911

20-
pod trunk push proj-ios.podspec --use-libraries
12+
Xcode Test:
13+
open Package.swift
14+
Command + U

proj-ios/PROJCRSParser.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
//
88

99
#import "PROJCRSParser.h"
10-
#import "CRSProjParser.h"
11-
#import "CRSKeyword.h"
10+
11+
@import proj;
12+
@import crs_ios;
1213

1314
@implementation PROJCRSParser
1415

proj-ios/PROJIOUtils.m

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,24 @@ +(NSString *) propertyListPathWithName: (NSString *) name{
1515
return [self resourcePathWithName:name andType:PROJ_PROPERTY_LIST_TYPE];
1616
}
1717

18-
+(NSString *) databasePath{
19-
return [self resourcePathWithName:[NSString stringWithFormat:@"%@/%@", PROJ_BUNDLE_NAME, PROJ_DATABASE_NAME] andType:PROJ_DATABASE_TYPE];
18+
+(NSString *) databasePath {
19+
NSString *path = [self resourcePathWithName:PROJ_DATABASE_NAME andType:PROJ_DATABASE_TYPE];
20+
return path;
2021
}
2122

2223
+(NSString *) resourcePathWithName: (NSString *) name andType: (NSString *) type{
24+
25+
// NSString *resource = [NSString stringWithFormat:@"%@/%@", PROJ_IOS_BUNDLE_NAME, name];
26+
27+
// FIXME: Test this in an app to see if it works properly, then just use name if that's true. We're not loading from the proj.bundle anymore (Remove that reference)
28+
NSString *resource = name;
2329

24-
NSString *resource = [NSString stringWithFormat:@"%@/%@", PROJ_IOS_BUNDLE_NAME, name];
2530
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:resource ofType:type];
31+
32+
if (!resourcePath) {
33+
resourcePath = [SWIFTPM_MODULE_BUNDLE pathForResource:resource ofType:type];
34+
}
35+
2636
if(resourcePath == nil){
2737
resourcePath = [[NSBundle bundleForClass:[self class]] pathForResource:resource ofType:type];
2838
if(resourcePath == nil){

0 commit comments

Comments
 (0)