Skip to content

Swift Interop Fix: Update C Enum to be Objective-C Enum #6

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 10 commits into
base: master
Choose a base branch
from
Open
8 changes: 6 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install
run: pod install
- name: Build & Test
run: xcodebuild test -workspace sf-ios.xcworkspace -scheme sf-ios -destination 'platform=iOS Simulator,OS=latest,name=iPhone 14'
run: |
iphone_names=$(xcrun simctl list devices available --json | jq -r '.devices | to_entries[] | .value[] | select(.name | test("^iPhone [0-9]+")) | .name')
latest_iphone=$(echo "$iphone_names" | sort | tail -n 1)
echo "latest_iphone: $latest_iphone"
xcodebuild test -workspace sf-ios.xcworkspace -scheme sf-ios -destination "platform=iOS Simulator,OS=latest,name=$latest_iphone"
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install
run: pod install
- name: Build
run: xcodebuild build-for-testing -workspace sf-ios.xcworkspace -scheme sf-ios -destination 'platform=iOS Simulator,OS=latest,name=iPhone 14'
run: |
iphone_names=$(xcrun simctl list devices available --json | jq -r '.devices | to_entries[] | .value[] | select(.name | test("^iPhone [0-9]+")) | .name')
latest_iphone=$(echo "$iphone_names" | sort | tail -n 1)
echo "latest_iphone: $latest_iphone"
xcodebuild build-for-testing -workspace sf-ios.xcworkspace -scheme sf-ios -destination "platform=iOS Simulator,OS=latest,name=$latest_iphone"
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.1.5 (TBD)
## 5.0.0

* TBD
* Breaking changes for Swift interopability. Converted C `enum` types to Objective-C `NS_ENUM` for proper visibility in Swift.
* Release builds were failing in [Mage iOS app](https://github.com/ngageoint/mage-ios/) (Cannot find 'SF_POINT' in scope) and optimizations were disabled due to related symbols issues.
* Updated types: `SFGeometryType`, `SFFiniteFilterType`, and `SFEventType` to use `NS_ENUM(NSInteger)`.

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

Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'
platform :ios, '15.0'

target :"sf-iosTests" do
podspec :path => './sf-ios.podspec'
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ Open sf-ios.xcworkspace in Xcode or build from command line:

Run tests from Xcode or from command line:

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

### Include Library ###

Include this repository by specifying it in a Podfile using a supported option.

Pull from [CocoaPods](https://cocoapods.org/pods/sf-ios):

pod 'sf-ios', '~> 4.1.4'
pod 'sf-ios', '~> 5.0.0'

Pull from GitHub:

pod 'sf-ios', :git => 'https://github.com/ngageoint/simple-features-ios.git', :branch => 'master'
pod 'sf-ios', :git => 'https://github.com/ngageoint/simple-features-ios.git', :tag => '4.1.4'
pod 'sf-ios', :git => 'https://github.com/ngageoint/simple-features-ios.git', :tag => '5.0.0'

Include as local project:

Expand Down
2 changes: 1 addition & 1 deletion docs/release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xcodebuild -workspace 'sf-ios.xcworkspace' -scheme sf-ios build

Xcode Test:

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

CocoaPods Local Lint:

Expand Down
7 changes: 3 additions & 4 deletions sf-ios.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'sf-ios'
s.version = '4.1.5'
s.version = '5.0.0'
s.license = {:type => 'MIT', :file => 'LICENSE' }
s.summary = 'iOS SDK for Simple Features'
s.homepage = 'https://github.com/ngageoint/simple-features-ios'
Expand All @@ -10,10 +10,9 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }

s.platform = :ios, '12.0'
s.ios.deployment_target = '12.0'
s.platform = :ios, '15.0'
s.ios.deployment_target = '15.0'

s.source_files = 'sf-ios/**/*.{h,m}'

s.frameworks = 'Foundation'
end
44 changes: 34 additions & 10 deletions sf-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -559,7 +559,8 @@
042FC6421B963FE500549A4B /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1230;
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1620;
ORGANIZATIONNAME = NGA;
TargetAttributes = {
042FC64A1B963FE500549A4B = {
Expand Down Expand Up @@ -707,6 +708,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -738,6 +740,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -753,7 +756,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "";
Expand All @@ -768,6 +771,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -799,6 +803,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -807,10 +812,11 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "";
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -827,9 +833,15 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
INFOPLIST_FILE = "sf-ios/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
PRODUCT_BUNDLE_IDENTIFIER = mil.nga.sf;
PRODUCT_NAME = sf_ios;
SKIP_INSTALL = YES;
Expand All @@ -847,9 +859,15 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
INFOPLIST_FILE = "sf-ios/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
PRODUCT_BUNDLE_IDENTIFIER = mil.nga.sf;
PRODUCT_NAME = sf_ios;
SKIP_INSTALL = YES;
Expand All @@ -861,7 +879,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 6179C77188B4A0E8D4DEDBEB /* Pods-sf-iosTests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -871,7 +888,11 @@
"$(inherited)",
);
INFOPLIST_FILE = "sf-iosTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "mil.nga.sf.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = sf_iosTests;
};
Expand All @@ -881,13 +902,16 @@
isa = XCBuildConfiguration;
baseConfigurationReference = B17E59AE80997CC09DD740D6 /* Pods-sf-iosTests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = "sf-iosTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "mil.nga.sf.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = sf_iosTests;
};
Expand Down
2 changes: 1 addition & 1 deletion sf-ios.xcodeproj/xcshareddata/xcschemes/sf-ios.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion sf-ios/SFCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* @return new curve
*/
-(instancetype) initWithType: (enum SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM;
-(instancetype) initWithType: (SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM;

/**
* Get the start Point of this Curve
Expand Down
2 changes: 1 addition & 1 deletion sf-ios/SFCurve.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@implementation SFCurve

-(instancetype) initWithType: (enum SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM{
-(instancetype) initWithType: (SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM{
self = [super initWithType:geometryType andHasZ:hasZ andHasM:hasM];
return self;
}
Expand Down
2 changes: 1 addition & 1 deletion sf-ios/SFCurvePolygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
*
* @return new curve polygon
*/
-(instancetype) initWithType: (enum SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM;
-(instancetype) initWithType: (SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM;

/**
* Initialize
Expand Down
2 changes: 1 addition & 1 deletion sf-ios/SFCurvePolygon.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ -(instancetype) initWithRing: (SFCurve *) ring{
return self;
}

-(instancetype) initWithType: (enum SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM{
-(instancetype) initWithType: (SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM{
self = [super initWithType:geometryType andHasZ:hasZ andHasM:hasM];
if(self != nil){
self.rings = [NSMutableArray array];
Expand Down
4 changes: 2 additions & 2 deletions sf-ios/SFGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Geometry type
*/
@property (nonatomic) enum SFGeometryType geometryType;
@property (nonatomic) SFGeometryType geometryType;

/**
* Has Z values
Expand All @@ -40,7 +40,7 @@
*
* @return new geometry
*/
-(instancetype) initWithType: (enum SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM;
-(instancetype) initWithType: (SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM;

/**
* Does the geometry have z coordinates
Expand Down
4 changes: 2 additions & 2 deletions sf-ios/SFGeometry.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@implementation SFGeometry

-(instancetype) initWithType: (enum SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM{
-(instancetype) initWithType: (SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM{
self = [super init];
if(self != nil){
self.geometryType = geometryType;
Expand Down Expand Up @@ -87,7 +87,7 @@ - (void) encodeWithCoder:(NSCoder *)encoder {
- (id) initWithCoder:(NSCoder *)decoder {
self = [super init];
if (self) {
_geometryType = (enum SFGeometryType)[decoder decodeIntForKey:@"geometryType"];
_geometryType = (SFGeometryType)[decoder decodeIntForKey:@"geometryType"];
_hasZ = [decoder decodeBoolForKey:@"hasZ"];
_hasM = [decoder decodeBoolForKey:@"hasM"];
}
Expand Down
4 changes: 2 additions & 2 deletions sf-ios/SFGeometryCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
*
* @return new geometry collection
*/
-(instancetype) initWithType: (enum SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM;
-(instancetype) initWithType: (SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM;

/**
* Initialize
Expand Down Expand Up @@ -171,7 +171,7 @@
* MULTISURFACE,
* GEOMETRYCOLLECTION
*/
-(enum SFGeometryType) collectionType;
-(SFGeometryType) collectionType;

/**
* Determine if this geometry collection is a MultiPoint instance or
Expand Down
8 changes: 4 additions & 4 deletions sf-ios/SFGeometryCollection.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ -(instancetype) initWithGeometry: (SFGeometry *) geometry{
return self;
}

-(instancetype) initWithType: (enum SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM{
-(instancetype) initWithType: (SFGeometryType) geometryType andHasZ: (BOOL) hasZ andHasM: (BOOL) hasM{
self = [super initWithType:geometryType andHasZ:hasZ andHasM:hasM];
if(self != nil){
self.geometries = [NSMutableArray array];
Expand Down Expand Up @@ -94,9 +94,9 @@ -(SFGeometry *) geometryAtIndex: (int) n{
return [self.geometries objectAtIndex:n];
}

-(enum SFGeometryType) collectionType{
-(SFGeometryType) collectionType{

enum SFGeometryType geometryType = [self geometryType];
SFGeometryType geometryType = [self geometryType];

switch (geometryType) {
case SF_MULTIPOINT:
Expand All @@ -119,7 +119,7 @@ -(enum SFGeometryType) collectionType{
}
break;
default:
[NSException raise:@"Unexpected" format:@"Unexpected Geometry Collection Type: %u", geometryType];
[NSException raise:@"Unexpected" format:@"Unexpected Geometry Collection Type: %ld", geometryType];
}

return geometryType;
Expand Down
Loading