Skip to content

Update NS_ENUM and Add Swift Package Manager Support #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .github/workflows/build-test.yml

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install
run: pod install
- name: Build
run: xcodebuild build-for-testing -workspace sf-geojson-ios.xcworkspace -scheme sf-geojson-ios -destination 'platform=iOS Simulator,OS=latest,name=iPhone 14'
uses: actions/checkout@v4
- name: Swift Build
run: swift build
- name: Swift Test
run: swift test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Pods
xcuserdata/
*.swp
Carthage/
.build/
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ Adheres to [Semantic Versioning](http://semver.org/).

---

## 4.2.6 (TBD)
## 5.0.0 (5-4-2025)

* TBD
* Integrates sf-ios 5.0.0 (SimpleFeatures) breaking code chanegs for NS_ENUM.
* Updates existing enums to NS_ENUM for Swift for Objective-C interoperability.
* Adds Swift Package support and removes Cocoapods support (since it's deprecated).

## [4.2.5](https://github.com/ngageoint/simple-features-geojson-ios/releases/tag/4.2.5) (04-08-2024)

Expand Down
15 changes: 15 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"originHash" : "8069c0fafbcdb7a67b070448df7ff6bec18895a15a1ef21c9f16b8148c04a49e",
"pins" : [
{
"identity" : "simple-features-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ngageoint/simple-features-ios",
"state" : {
"branch" : "psolt/v5-NS_ENUM_Package",
"revision" : "466c1b5225e3fb6e004a459b2d4811dab20bc561"
}
}
],
"version" : 3
}
62 changes: 62 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// swift-tools-version:5.10
import PackageDescription

/// SPM Conversion Notes
/// * Hyphens break the resource bundling logic in Objective-C, so we're using full names
/// * sf-geoson is now SimpleFeaturesGeoJSON

let package = Package(
name: "SimpleFeaturesGeoJSON",
platforms: [.macOS(.v11), .iOS(.v13)],
products: [
.library(
name: "SimpleFeaturesGeoJSON",
targets: ["SimpleFeaturesGeoJSON"]),
],
dependencies: [

.package(url: "https://github.com/ngageoint/simple-features-ios", branch: "psolt/v5-NS_ENUM_Package"), // FIXME: Update to published release (5.0.0 version)

// .package(name: "simple-features-ios", path: "../simple-features-ios"), // Testing locally against (psolt/v5-NS_ENUM_Package)
],
targets: [
.target(
name: "SimpleFeaturesGeoJSON",
dependencies: [
.product(name: "SimpleFeatures", package: "simple-features-ios")
],
path: "sf-geojson-ios",
publicHeadersPath: "include"
),
.testTarget(
name: "SimpleFeaturesGeoJSONTests", // Use full name without hyphens to prevent SPM test resource bug
dependencies: [
"SimpleFeaturesGeoJSON",
"SimpleFeatureGeoJSONTestHelpers"
],
path: "sf-geojson-iosTests",
resources: [ // In Objective-C, the tests fail to load resource using SWIFTPM_MODULE_BUNDLE macro with hyphens for target/testTarget names, so we'll use full names.
.copy("fc-points.geojson"),
.copy("fc-points-altitude.geojson"),
.copy("gc.geojson"),
.copy("gc-multiple.geojson")
]
),
.testTarget(
name: "SimpleFeaturesGeoJSONTestsSwift",
dependencies: [
"SimpleFeaturesGeoJSON",
"SimpleFeatureGeoJSONTestHelpers",
],
path: "sf-geojson-iosTests-swift"
),
.target(
name: "SimpleFeatureGeoJSONTestHelpers", // Shared helper code
dependencies: [
"SimpleFeaturesGeoJSON",
],
path: "sf-geojson-ios-TestUtils",
publicHeadersPath: ""
),
]
)
10 changes: 0 additions & 10 deletions Podfile

This file was deleted.

43 changes: 26 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ View the latest [Appledoc](http://ngageoint.github.io/simple-features-geojson-io

```objectivec

@import SimpleFeaturesGeoJSON;

// NSString *content = ...

SFGGeometry *geometry = [SFGFeatureConverter jsonToGeometry:content];
Expand All @@ -37,6 +39,8 @@ SFGeometry *simpleGeometry = [geometry geometry];

```objectivec

@import SimpleFeaturesGeoJSON;

// SFGeometry *geometry = ...

NSString *content = [SFGFeatureConverter simpleGeometryToJSON:geometry];
Expand All @@ -53,43 +57,48 @@ NSDictionary *contentTree = [SFGFeatureConverter simpleGeometryToTree:geometry];

### Build ###

[![Build & Test](https://github.com/ngageoint/simple-features-geojson-ios/workflows/Build%20&%20Test/badge.svg)](https://github.com/ngageoint/simple-features-geojson-ios/actions/workflows/build-test.yml)
[![Build](https://github.com/ngageoint/simple-features-geojson-ios/actions/workflows/build.yml/badge.svg)](https://github.com/ngageoint/simple-features-geojson-ios/actions/workflows/build.yml)

Build this repository using Xcode and/or CocoaPods:
Build this repository using SPM:

pod repo update
pod install
swift build

Open sf-geojson-ios.xcworkspace in Xcode or build from command line:
Open the Swift Package in Xcode:

xcodebuild -workspace 'sf-geojson-ios.xcworkspace' -scheme sf-geojson-ios build
open Package.swift

Run tests from Xcode or from command line:

xcodebuild test -workspace 'sf-geojson-ios.xcworkspace' -scheme sf-geojson-ios -destination 'platform=iOS Simulator,name=iPhone 15'
swift test

### Include Library ###

Include this repository by specifying it in a Podfile using a supported option.
Add a package dependency version:

Pull from [CocoaPods](https://cocoapods.org/pods/sf-geojson-ios):
.package(url: "https://github.com/ngageoint/simple-features-geojson-ios", from: "5.0.0"),

pod 'sf-geojson-ios', '~> 4.2.5'
# Or specific branch:

Pull from GitHub:
.package(url: "https://github.com/ngageoint/simple-features-geojson-ios", branch: "release/5.0.0"),

# Or as a local dependency:

pod 'sf-geojson-ios', :git => 'https://github.com/ngageoint/simple-features-geojson-ios.git', :branch => 'master'
pod 'sf-geojson-ios', :git => 'https://github.com/ngageoint/simple-features-geojson-ios.git', :tag => '4.2.5'
.package(name: "simple-features-geojson-ios", path: "../simple-features-geojson-ios"),

Include as local project:
Use it in a target:

pod 'sf-geojson-ios', :path => '../simple-features-geojson-ios'
.target(
name: "MyLibrary",
dependencies: [
.product(name: "SimpleFeaturesGeoJSON", package: "simple-features-geojson-ios")
]
)

### Swift ###

To use from Swift, import the sf-geojson-ios bridging header from the Swift project's bridging header
To use from Swift, import the framework:

#import "sf-geojson-ios-Bridging-Header.h"
import SimpleFeaturesGeoJSON

#### Read ####

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
// Copyright © 2015 NGA. All rights reserved.
//

#import "SFGeometryEnvelope.h"
#import "SFMultiPoint.h"
#import "SFMultiLineString.h"
#import "SFCircularString.h"
#import "SFCompoundCurve.h"
#import "SFCurvePolygon.h"
#import "SFTIN.h"
#import "SFTriangle.h"

@import SimpleFeatures;

@interface SFGGeometryTestUtils : NSObject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2015 NGA. All rights reserved.
//

@import XCTest;
#import "SFGGeometryTestUtils.h"
#import "SFGTestUtils.h"

Expand Down Expand Up @@ -38,7 +39,7 @@ +(void) compareGeometriesWithExpected: (SFGeometry *) expected andActual: (SFGeo
}else{
[SFGTestUtils assertNotNil:actual];

enum SFGeometryType geometryType = expected.geometryType;
SFGeometryType geometryType = expected.geometryType;
switch(geometryType){
case SF_GEOMETRY:
[NSException raise:@"Unexpected Geometry Type" format:@"Unexpected Geometry Type of %@ which is abstract", [SFGeometryTypes name:geometryType]];
Expand Down Expand Up @@ -90,13 +91,13 @@ +(void) compareGeometriesWithExpected: (SFGeometry *) expected andActual: (SFGeo
[self compareTriangleWithExpected:(SFTriangle *)expected andActual:(SFTriangle *)actual];
break;
default:
[NSException raise:@"Geometry Type Not Supported" format:@"Geometry Type not supported: %d", geometryType];
[NSException raise:@"Geometry Type Not Supported" format:@"Geometry Type not supported: %ld", (long)geometryType];
}
}
}

+(void) compareBaseGeometryAttributesWithExpected: (SFGeometry *) expected andActual: (SFGeometry *) actual{
[SFGTestUtils assertEqualIntWithValue:expected.geometryType andValue2:actual.geometryType];
XCTAssertEqual(expected.geometryType, actual.geometryType);
[SFGTestUtils assertEqualBoolWithValue:expected.hasZ andValue2:actual.hasZ];
[SFGTestUtils assertEqualBoolWithValue:expected.hasM andValue2:actual.hasM];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
// Copyright © 2019 NGA. All rights reserved.
//

#import "SFGeometry.h"
#import "SFMultiPolygon.h"
#import "SFGPoint.h"
@import SimpleFeatures;
@import SimpleFeaturesGeoJSON;

@interface SFGTestUtils : NSObject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//

#import "SFGTestUtils.h"
#import "SFGFeatureConverter.h"
#import "SFGGeometryTestUtils.h"
#import "SFLinearRing.h"
@import SimpleFeatures;
@import SimpleFeaturesGeoJSON;

#define ARC4RANDOM_MAX 0x100000000

Expand Down
21 changes: 0 additions & 21 deletions sf-geojson-ios.podspec

This file was deleted.

Loading