Skip to content

[geolocator_apple] Add swift package manager compatibility #1630

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

Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ unlinked.ds
unlinked_spec.ds
flutter_export_environment.sh
**/.flutter-plugins-dependencies
**/Flutter/ephemeral/

# Android related
gradle-wrapper.jar
Expand Down Expand Up @@ -95,6 +96,8 @@ GeneratedPluginRegistrant.java
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
**/ios/Flutter/Flutter.podspec
**/.build/
**/.swiftpm/

# Firebase related
.firebase/
Expand Down
4 changes: 4 additions & 0 deletions geolocator_apple/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.3.13

* Adds Swift Package Manager compatibility.

## 2.3.12

* Removed deprecated `-[UIApplication openURL:]` dead code.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@
Pod::Spec.new do |s|
s.name = 'geolocator_apple'
s.version = '1.2.0'
s.summary = 'Geolocation iOS plugin for Flutter.'
s.summary = 'Geolocation iOS & macOS plugin for Flutter.'
s.description = <<-DESC
Geolocation iOS plugin for Flutter. This plugin provides the Apple implementation for the geolocator plugin.
DESC
s.homepage = 'http://github.com/baseflow/flutter-geolocator'
s.license = { :type => 'MIT', :file => '../LICENSE' }
s.author = { 'Baseflow' => 'hello@baseflow.com' }
s.source = { :http => 'https://github.com/baseflow/flutter-geolocator/tree/master/' }
s.source_files = 'Classes/**/*.{h,m}'
s.public_header_files = 'Classes/**/*.h'
s.module_map = 'Classes/GeolocatorPlugin.modulemap'
s.dependency 'Flutter'
s.platform = :ios, '11.0'
s.source_files = 'geolocator_apple/Sources/geolocator_apple/**/*.{h,m}'
s.public_header_files = 'geolocator_apple/Sources/geolocator_apple/include/**/*.h'
s.module_map = 'geolocator_apple/Sources/geolocator_apple/include/GeolocatorPlugin.modulemap'

s.ios.dependency 'Flutter'
s.osx.dependency 'FlutterMacOS'
s.ios.deployment_target = '11.0'
s.osx.deployment_target = '10.11'

# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386'}
s.resource_bundles = {'geolocator_apple_privacy' => ['Resources/PrivacyInfo.xcprivacy']}
s.resource_bundles = {'geolocator_apple_privacy' => ['geolocator_apple/Sources/geolocator_apple/PrivacyInfo.xcprivacy']}
end
29 changes: 29 additions & 0 deletions geolocator_apple/darwin/geolocator_apple/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "geolocator_apple",
platforms: [
.iOS("11.0"),
.macOS("10.11")
],
products: [
.library(name: "geolocator-apple", targets: ["geolocator_apple"])
],
dependencies: [],
targets: [
.target(
name: "geolocator_apple",
dependencies: [],
resources: [
.process("PrivacyInfo.xcprivacy")
],
publicHeadersPath: "include/geolocator_apple",
cSettings: [
.headerSearchPath("include/geolocator_apple")
]
)
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Maurits van Beusekom on 24/06/2020.
//

#import "ErrorCodes.h"
#import "../include/geolocator_apple/Constants/ErrorCodes.h"

NSString * const GeolocatorErrorLocationUpdateFailure = @"LOCATION_UPDATE_FAILURE";
NSString * const GeolocatorErrorLocationServicesDisabled = @"LOCATION_SERVICES_DISABLED";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#import <CoreLocation/CoreLocation.h>
#import "GeolocatorPlugin.h"
#import "GeolocatorPlugin_Test.h"
#import "Constants/ErrorCodes.h"
#import "Handlers/GeolocationHandler.h"
#import "Handlers/PermissionHandler.h"
#import "Handlers/PositionStreamHandler.h"
#import "Utils/ActivityTypeMapper.h"
#import "Utils/AuthorizationStatusMapper.h"
#import "Utils/LocationAccuracyMapper.h"
#import "Utils/LocationDistanceMapper.h"
#import "Utils/LocationMapper.h"
#import "Utils/PermissionUtils.h"
#import "Handlers/LocationAccuracyHandler.h"
#import "Handlers/LocationServiceStreamHandler.h"
#import "./include/geolocator_apple/GeolocatorPlugin.h"
#import "./include/geolocator_apple/GeolocatorPlugin_Test.h"
#import "./include/geolocator_apple/Constants/ErrorCodes.h"
#import "./include/geolocator_apple/Handlers/GeolocationHandler.h"
#import "./include/geolocator_apple/Handlers/PermissionHandler.h"
#import "./include/geolocator_apple/Handlers/PositionStreamHandler.h"
#import "./include/geolocator_apple/Utils/ActivityTypeMapper.h"
#import "./include/geolocator_apple/Utils/AuthorizationStatusMapper.h"
#import "./include/geolocator_apple/Utils/LocationAccuracyMapper.h"
#import "./include/geolocator_apple/Utils/LocationDistanceMapper.h"
#import "./include/geolocator_apple/Utils/LocationMapper.h"
#import "./include/geolocator_apple/Utils/PermissionUtils.h"
#import "./include/geolocator_apple/Handlers/LocationAccuracyHandler.h"
#import "./include/geolocator_apple/Handlers/LocationServiceStreamHandler.h"

@interface GeolocatorPlugin ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Created by Maurits van Beusekom on 20/06/2020.
//

#import "GeolocationHandler.h"
#import "GeolocationHandler_Test.h"
#import "../Constants/ErrorCodes.h"
#import "../include/geolocator_apple/Handlers/GeolocationHandler.h"
#import "../include/geolocator_apple/Handlers/GeolocationHandler_Test.h"
#import "../include/geolocator_apple/Constants/ErrorCodes.h"

double const kMaxLocationLifeTimeInSeconds = 5.0;

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

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import "LocationAccuracyHandler.h"
#import "ErrorCodes.h"
#import "../include/geolocator_apple/Handlers/LocationAccuracyHandler.h"
#import "../include/geolocator_apple/Constants/ErrorCodes.h"

@interface LocationAccuracyHandler()
@property (strong, nonatomic) CLLocationManager *locationManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import "LocationServiceStreamHandler.h"
#import "../Utils/ServiceStatus.h"
#import "../include/geolocator_apple/Handlers/LocationServiceStreamHandler.h"
#import "../include/geolocator_apple/Utils/ServiceStatus.h"

@interface LocationServiceStreamHandler()
@property (strong, nonatomic) CLLocationManager *locationManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Created by Maurits van Beusekom on 26/06/2020.
//

#import "PermissionHandler.h"
#import "../Constants/ErrorCodes.h"
#import "../Utils/PermissionUtils.h"
#import "../include/geolocator_apple/Handlers/PermissionHandler.h"
#import "../include/geolocator_apple/Constants/ErrorCodes.h"
#import "../include/geolocator_apple/Utils/PermissionUtils.h"

@interface PermissionHandler() <CLLocationManagerDelegate>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
// Created by Maurits van Beusekom on 04/06/2021.
//

#import "PermissionHandler.h"
#import "PositionStreamHandler.h"
#import "../Constants/ErrorCodes.h"
#import "../Utils/ActivityTypeMapper.h"
#import "../Utils/LocationAccuracyMapper.h"
#import "../Utils/LocationDistanceMapper.h"
#import "../Utils/LocationMapper.h"
#import "../include/geolocator_apple/Handlers/PermissionHandler.h"
#import "../include/geolocator_apple/Handlers/PositionStreamHandler.h"
#import "../include/geolocator_apple/Constants/ErrorCodes.h"
#import "../include/geolocator_apple/Utils/ActivityTypeMapper.h"
#import "../include/geolocator_apple/Utils/LocationAccuracyMapper.h"
#import "../include/geolocator_apple/Utils/LocationDistanceMapper.h"
#import "../include/geolocator_apple/Utils/LocationMapper.h"

@interface PositionStreamHandler()
@property (strong, nonatomic, nonnull) GeolocationHandler *geolocationHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import <Foundation/Foundation.h>

#import "ActivityTypeMapper.h"
#import "../include/geolocator_apple/Utils/ActivityTypeMapper.h"

@implementation ActivityTypeMapper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Maurits van Beusekom on 15/06/2020.
//

#import "AuthorizationStatusMapper.h"
#import "../include/geolocator_apple/Utils/AuthorizationStatusMapper.h"

@implementation AuthorizationStatusMapper
+ (NSNumber *) toDartIndex: (CLAuthorizationStatus) authorizationStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Maurits van Beusekom on 06/07/2020.
//

#import "LocationAccuracyMapper.h"
#import "../include/geolocator_apple/Utils/LocationAccuracyMapper.h"

@implementation LocationAccuracyMapper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Maurits van Beusekom on 06/07/2020.
//

#import "LocationDistanceMapper.h"
#import "../include/geolocator_apple/Utils/LocationDistanceMapper.h"

@implementation LocationDistanceMapper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Maurits van Beusekom on 20/06/2020.
//

#import "LocationMapper.h"
#import "../include/geolocator_apple/Utils/LocationMapper.h"

@implementation LocationMapper
+ (NSDictionary *) toDictionary:(CLLocation *)location {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Maurits van Beusekom on 27/08/2021.
//

#import "PermissionUtils.h"
#import "../include/geolocator_apple/Utils/PermissionUtils.h"

@implementation PermissionUtils
+ (BOOL) isStatusGranted:(CLAuthorizationStatus)authorizationStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by Maurits van Beusekom on 24/06/2020.
//

#import <Foundation/Foundation.h>

FOUNDATION_EXPORT NSString * const GeolocatorErrorLocationUpdateFailure;
FOUNDATION_EXPORT NSString * const GeolocatorErrorLocationServicesDisabled;
FOUNDATION_EXPORT NSString * const GeolocatorErrorLocationSubscriptionActive;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// This header is available in the Test module. Import via "@import geolocator_apple.Test;"

#if __has_include(<geolocator_apple/GeolocationHandler.h>)
#import <geolocator_apple/GeolocationHandler.h>
#import <geolocator_apple/LocationAccuracyHandler.h>
#import <geolocator_apple/PermissionHandler.h>
#else
#import "Handlers/GeolocationHandler.h"
#import "Handlers/LocationAccuracyHandler.h"
#import "Handlers/PermissionHandler.h"
#endif

/// Methods exposed for unit testing.
@interface GeolocatorPlugin(Test)
Expand Down
40 changes: 22 additions & 18 deletions geolocator_apple/example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
86CF01536E48F5FD7EA4BF3A /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A4FBB87ACA23BE7AAB26EAD /* libPods-RunnerTests.a */; };
94DC9D5BB92DE35994AB163F /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 74FF83166DF8B30D7F87CE53 /* libPods-Runner.a */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
Expand Down Expand Up @@ -76,6 +77,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
94DC9D5BB92DE35994AB163F /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -192,13 +194,15 @@
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
591FD69E94FC610DB997784E /* [CP] Copy Pods Resources */,
);
buildRules = (
);
dependencies = (
);
name = Runner;
packageProductDependencies = (
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */,
);
productName = Runner;
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -249,6 +253,9 @@
Base,
);
mainGroup = 97C146E51CF9000F007C117D;
packageReferences = (
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */,
);
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -297,23 +304,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
591FD69E94FC610DB997784E /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
6E879EFB06735EEE96AC22A9 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -772,6 +762,20 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
isa = XCSwiftPackageProductDependency;
productName = FlutterGeneratedPluginSwiftPackage;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Prepare Flutter Framework Script"
scriptText = "/bin/sh &quot;$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh&quot; prepare&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down Expand Up @@ -58,6 +76,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
Loading