Skip to content

[google_maps_flutter_ios]: Add swift package manager compatibility #8288

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 2.14.0

* Adds Swift Package Manager compatibility.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.

## 2.13.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ should add it to your `pubspec.yaml` as usual.
| Heatmap.maximumZoomIntensity | ✓ |
| HeatmapGradient.colorMapSize | ✓ |

## Swift Package Manager Support

This package supports Swift Package Manager for projects targeting iOS 15 or above. For projects targeting iOS 14, you need to disable Swift Package Manager. For more information on how to disable Swift Package Manager for a single project, refer to [this document][3].

[1]: https://pub.dev/packages/google_maps_flutter
[2]: https://flutter.dev/to/endorsed-federated-plugin
[3]: https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-app-developers#turn-off-for-a-single-project
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ dev_dependencies:
sdk: flutter

flutter:
# Swift Package Manager for google_maps_flutter_ios does not support iOS 14,
# so it needs to be disabled for this example project.
disable-swift-package-manager: true
uses-material-design: true
assets:
- assets/
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths

pod 'OCMock', '~> 3.9.1'
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objectVersion = 60;
objects = {

/* 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 */; };
5276B9112D0C699A009C4BA0 /* OCMock in Frameworks */ = {isa = PBXBuildFile; productRef = 5276B9102D0C699A009C4BA0 /* OCMock */; };
5B5EF9A6C72A03092BDA553E /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28D4666EF03E57DB7D03E916 /* Pods_RunnerTests.framework */; };
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
Expand Down Expand Up @@ -88,6 +89,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5276B9112D0C699A009C4BA0 /* OCMock in Frameworks */,
5B5EF9A6C72A03092BDA553E /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -198,6 +200,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
BB6BD9A1101E970BEF85B6D2 /* [CP] Copy Pods Resources */,
A89AF444D8C8FFBE1C95B3BF /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand All @@ -219,7 +222,6 @@
F7151F0C265D7ED70028CB91 /* Sources */,
F7151F0D265D7ED70028CB91 /* Frameworks */,
F7151F0E265D7ED70028CB91 /* Resources */,
7862D82E36C37F9B7558DA5E /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -260,7 +262,8 @@
);
mainGroup = 97C146E51CF9000F007C117D;
packageReferences = (
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */,
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */,
5276B90F2D0C699A009C4BA0 /* XCRemoteSwiftPackageReference "ocmock" */,
);
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -329,38 +332,38 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
7862D82E36C37F9B7558DA5E /* [CP] Embed Pods Frameworks */ = {
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-RunnerTests/Pods-RunnerTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/OCMock/OCMock.framework",
);
name = "[CP] Embed Pods Frameworks";
name = "Run Script";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OCMock.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RunnerTests/Pods-RunnerTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
A89AF444D8C8FFBE1C95B3BF /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/integration_test/integration_test.framework",
);
name = "Run Script";
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/integration_test.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
BB6BD9A1101E970BEF85B6D2 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -685,13 +688,29 @@
/* End XCConfigurationList section */

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

/* Begin XCRemoteSwiftPackageReference section */
5276B90F2D0C699A009C4BA0 /* XCRemoteSwiftPackageReference "ocmock" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "http://github.com/erikdoe/ocmock";
requirement = {
kind = revision;
revision = fe1661a3efed11831a6452f4b1a0c5e6ddc08c3d;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
5276B9102D0C699A009C4BA0 /* OCMock */ = {
isa = XCSwiftPackageProductDependency;
package = 5276B90F2D0C699A009C4BA0 /* XCRemoteSwiftPackageReference "ocmock" */;
productName = OCMock;
};
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
isa = XCSwiftPackageProductDependency;
productName = FlutterGeneratedPluginSwiftPackage;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Downloaded by pub (not CocoaPods).
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :http => 'https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter/ios' }
s.documentation_url = 'https://pub.dev/packages/google_maps_flutter_ios'
s.source_files = 'Classes/**/*.{h,m}'
s.public_header_files = 'Classes/**/*.h'
s.module_map = 'Classes/google_maps_flutter_ios.modulemap'
s.source_files = 'google_maps_flutter_ios/Sources/google_maps_flutter_ios/**/*.{h,m}'
s.public_header_files = 'google_maps_flutter_ios/Sources/google_maps_flutter_ios/include/**/*.h'
s.module_map = 'google_maps_flutter_ios/Sources/google_maps_flutter_ios/include/google_maps_flutter_ios.modulemap'
s.dependency 'Flutter'
# Allow any version up to the next breaking change after the latest version that
# has been confirmed to be compatible via an example in examples/. See discussion
Expand All @@ -36,6 +36,7 @@ Downloaded by pub (not CocoaPods).
s.xcconfig = {
'LIBRARY_SEARCH_PATHS' => '$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)/ $(SDKROOT)/usr/lib/swift',
'LD_RUNPATH_SEARCH_PATHS' => '$(inherited) /usr/lib/swift',
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) FGM_USING_COCOAPODS=1'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this FGM_USING_COCOAPODS preprocessor definition used to detect if cocoapods are used or not.
This is used for example at: https://github.com/flutter/packages/pull/8288/files#diff-dcc8100c7e606a3918ac1f3f2cd0aa16c2c6e551e09b9ff717f724a671ce5323R8

}
s.resource_bundles = {'google_maps_flutter_ios_privacy' => ['Resources/PrivacyInfo.xcprivacy']}
s.resource_bundles = {'google_maps_flutter_ios_privacy' => ['google_maps_flutter_ios/Sources/google_maps_flutter_ios/Resources/PrivacyInfo.xcprivacy']}
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import PackageDescription

let package = Package(
name: "google_maps_flutter_ios",
platforms: [
.iOS(.v15)
],
products: [
.library(name: "google-maps-flutter-ios", type: .static, targets: ["google_maps_flutter_ios"])
],
dependencies: [
.package(url: "https://github.com/googlemaps/ios-maps-sdk", "9.0.0"..<"10.0.0"),
.package(url: "https://github.com/googlemaps/google-maps-ios-utils", "6.1.0"..<"7.0.0"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jokerttu Can you explain why the SwiftPM implementation can only be used in iOS 15+? Why can't it include google-maps-ios-utils 5.0 like the CocoaPods version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See discussion here; apparently the SDK's SPM configuration was broken in the version of the SDK that still supported iOS 14 :(

],
targets: [
.target(
name: "google_maps_flutter_ios",
dependencies: [
.product(
name: "GoogleMapsUtils",
package: "google-maps-ios-utils"
),
.product(
name: "GoogleMaps",
package: "ios-maps-sdk"
),
],
exclude: [
"include/google_maps_flutter_ios-umbrella.h", "include/google_maps_flutter_ios.modulemap",
],
resources: [
.process("Resources")
],
cSettings: [
.headerSearchPath("include/google_maps_flutter_ios")
]
)
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@

#import "FLTGoogleMapHeatmapController.h"
#import "FLTGoogleMapJSONConversions.h"

/// If Swift Package Manager is in use, Objective-C headers are available under the
/// GoogleMapsUtilsObjC package. When using CocoaPods, the headers are provided by the
/// GoogleMapsUtils package.
#ifdef FGM_USING_COCOAPODS
@import GoogleMapsUtils;
#else
@import GoogleMapsUtilsObjC;
#endif

@interface FLTGoogleMapHeatmapController ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// If Swift Package Manager is in use, Objective-C headers are available under the
/// GoogleMapsUtilsObjC package. When using CocoaPods, the headers are provided by the
/// GoogleMapsUtils package.
#ifdef FGM_USING_COCOAPODS
@import GoogleMapsUtils;
#else
@import GoogleMapsUtilsObjC;
#endif

#import "GoogleMapController.h"

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

#import <Flutter/Flutter.h>
#import <GoogleMaps/GoogleMaps.h>

/// If Swift Package Manager is in use, Objective-C headers are available under the
/// GoogleMapsUtilsObjC package. When using CocoaPods, the headers are provided by the
/// GoogleMapsUtils package.
#ifdef FGM_USING_COCOAPODS
@import GoogleMapsUtils;
#else
@import GoogleMapsUtilsObjC;
#endif

#import "messages.g.h"

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

#import <Flutter/Flutter.h>
#import <GoogleMaps/GoogleMaps.h>

/// If Swift Package Manager is in use, Objective-C headers are available under the
/// GoogleMapsUtilsObjC package. When using CocoaPods, the headers are provided by the
/// GoogleMapsUtils package.
#ifdef FGM_USING_COCOAPODS
@import GoogleMapsUtils;
#else
@import GoogleMapsUtilsObjC;
#endif

#import "messages.g.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
#import <Flutter/Flutter.h>
#import <Foundation/Foundation.h>
#import <GoogleMaps/GoogleMaps.h>

/// If Swift Package Manager is in use, Objective-C headers are available under the
/// GoogleMapsUtilsObjC package. When using CocoaPods, the headers are provided by the
/// GoogleMapsUtils package.
#ifdef FGM_USING_COCOAPODS
@import GoogleMapsUtils;
#else
@import GoogleMapsUtilsObjC;
#endif

#import "messages.g.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v22.6.1), do not edit directly.
// Autogenerated from Pigeon (v22.7.3), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>
Expand Down Expand Up @@ -551,15 +551,13 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) {
@property(nonatomic, strong) id bitmap;
@end

/// Pigeon equivalent of [DefaultMarker]. See
/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#defaultMarker(float)
/// Pigeon equivalent of [DefaultMarker].
@interface FGMPlatformBitmapDefaultMarker : NSObject
+ (instancetype)makeWithHue:(nullable NSNumber *)hue;
@property(nonatomic, strong, nullable) NSNumber *hue;
@end

/// Pigeon equivalent of [BytesBitmap]. See
/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#fromBitmap(android.graphics.Bitmap)
/// Pigeon equivalent of [BytesBitmap].
@interface FGMPlatformBitmapBytes : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
Expand All @@ -569,8 +567,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) {
@property(nonatomic, strong, nullable) FGMPlatformSize *size;
@end

/// Pigeon equivalent of [AssetBitmap]. See
/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname
/// Pigeon equivalent of [AssetBitmap].
@interface FGMPlatformBitmapAsset : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
Expand All @@ -579,8 +576,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) {
@property(nonatomic, copy, nullable) NSString *pkg;
@end

/// Pigeon equivalent of [AssetImageBitmap]. See
/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname
/// Pigeon equivalent of [AssetImageBitmap].
@interface FGMPlatformBitmapAssetImage : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
Expand All @@ -592,8 +588,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) {
@property(nonatomic, strong, nullable) FGMPlatformSize *size;
@end

/// Pigeon equivalent of [AssetMapBitmap]. See
/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname
/// Pigeon equivalent of [AssetMapBitmap].
@interface FGMPlatformBitmapAssetMap : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
Expand All @@ -609,8 +604,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) {
@property(nonatomic, strong, nullable) NSNumber *height;
@end

/// Pigeon equivalent of [BytesMapBitmap]. See
/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-frombitmap-bitmap-image
/// Pigeon equivalent of [BytesMapBitmap].
@interface FGMPlatformBitmapBytesMap : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v22.6.1), do not edit directly.
// Autogenerated from Pigeon (v22.7.3), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import "messages.g.h"
#import "./include/google_maps_flutter_ios/messages.g.h"

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
Expand Down
Loading