Skip to content
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

[google_sign_in_ios] Adds Swift Package Manager support #7356

Draft
wants to merge 9 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
2 changes: 1 addition & 1 deletion .ci/targets/ios_platform_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tasks:
args: ["build-examples", "--ios", "--swift-package-manager"]
- name: xcode analyze
script: .ci/scripts/tool_runner.sh
args: ["xcode-analyze", "--ios"]
args: ["xcode-analyze", "--ios", "--exclude=script/configs/exclude_xcode_analysis.yaml"]
- name: xcode analyze deprecation
# Ensure we don't accidentally introduce deprecated code.
script: .ci/scripts/tool_runner.sh
Expand Down
2 changes: 1 addition & 1 deletion .ci/targets/macos_platform_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tasks:
args: ["build-examples", "--macos", "--swift-package-manager"]
- name: xcode analyze
script: .ci/scripts/tool_runner.sh
args: ["xcode-analyze", "--macos"]
args: ["xcode-analyze", "--macos", "--exclude=script/configs/exclude_xcode_analysis.yaml"]
- name: xcode analyze deprecation
# Ensure we don't accidentally introduce deprecated code.
script: .ci/scripts/tool_runner.sh
Expand Down
4 changes: 4 additions & 0 deletions packages/google_sign_in/google_sign_in_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.8.0

* Adds Swift Package Manager compatibility.

## 5.7.8

* Updates Pigeon for non-nullable collection type support.
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

@import XCTest;
@import google_sign_in_ios;
#if __has_include(<google_sign_in_ios/google_sign_in_ios-umbrella.h>)
@import google_sign_in_ios.Test;
#endif
@import GoogleSignIn;

// OCMock library doesn't generate a valid modulemap.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Enables Google Sign-In in Flutter apps.
s.license = { :type => 'BSD', :file => '../LICENSE' }
s.author = { 'Flutter Team' => '[email protected]' }
s.source = { :http => 'https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_ios' }
s.source_files = 'Classes/**/*.{h,m}'
s.public_header_files = 'Classes/**/*.h'
s.module_map = 'Classes/FLTGoogleSignInPlugin.modulemap'
s.source_files = 'google_sign_in_ios/Sources/google_sign_in_ios/**/*.{h,m}'
s.public_header_files = 'google_sign_in_ios/Sources/google_sign_in_ios/include/**/*.h'
s.module_map = 'google_sign_in_ios/Sources/google_sign_in_ios/include/FLTGoogleSignInPlugin.modulemap'

# AppAuth and GTMSessionFetcher are GoogleSignIn transitive dependencies.
# Depend on versions which defines modules.
s.dependency 'AppAuth', '>= 1.7.4'
s.dependency 'AppAuth', '>= 1.7.6'
s.dependency 'GTMSessionFetcher', '>= 3.4.0'
s.dependency 'GoogleSignIn', '~> 7.1'
s.static_framework = true
Expand All @@ -33,5 +33,5 @@ Enables Google Sign-In in Flutter apps.
# GoogleSignIn depending a Swift pod (GTMAppAuth).
s.swift_version = '5.0'

s.resource_bundles = {'google_sign_in_ios_privacy' => ['Resources/PrivacyInfo.xcprivacy']}
s.resource_bundles = {'google_sign_in_ios_privacy' => ['google_sign_in_ios/Sources/google_sign_in_ios/Resources/PrivacyInfo.xcprivacy']}
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// swift-tools-version: 5.9

// 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_sign_in_ios",
platforms: [
.iOS("12.0"),
.macOS("10.15"),
],
products: [
.library(name: "google-sign-in-ios", targets: ["google_sign_in_ios"])
],
dependencies: [
// AppAuth and GTMSessionFetcher are GoogleSignIn transitive dependencies.
// Depend on versions which define modules.
Copy link
Member Author

@loic-sharma loic-sharma Aug 9, 2024

Choose a reason for hiding this comment

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

This mirrors:

# AppAuth and GTMSessionFetcher are GoogleSignIn transitive dependencies.
# Depend on versions which defines modules.
s.dependency 'AppAuth', '>= 1.7.6'
s.dependency 'GTMSessionFetcher', '>= 3.4.0'
s.dependency 'GoogleSignIn', '~> 7.1'

.package(
url: "https://github.com/openid/AppAuth-iOS.git",
from: "1.7.6"),
.package(
url: "https://github.com/google/gtm-session-fetcher.git",
from: "3.4.0"),
.package(
url: "https://github.com/google/GoogleSignIn-iOS.git",
from: "7.1.0"),
],
targets: [
.target(
name: "google_sign_in_ios",
dependencies: [
.product(name: "GoogleSignIn", package: "GoogleSignIn-iOS")
],
exclude: [
"include/google_sign_in_ios-umbrella.h", "include/FLTGoogleSignInPlugin.modulemap",
],
resources: [
.process("Resources")
],
cSettings: [
.headerSearchPath("include/google_sign_in_ios")
]
)
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FLTGoogleSignInPlugin.h"
#import "FLTGoogleSignInPlugin_Test.h"
#import "./include/google_sign_in_ios/FLTGoogleSignInPlugin.h"
#import "./include/google_sign_in_ios/FLTGoogleSignInPlugin_Test.h"

#import <GoogleSignIn/GoogleSignIn.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Autogenerated from Pigeon (v11.0.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon

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

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

# Suppress warnings from transitive dependencies that cause analysis to fail.
pod 'AppAuth', :inhibit_warnings => true
pod 'GTMAppAuth', :inhibit_warnings => true
inhibit_all_warnings!
Copy link
Member Author

Choose a reason for hiding this comment

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

These lines inhibit warnings but also add AppAuth and GTMAppAuth as CocoaPod dependencies:

pod 'AppAuth', :inhibit_warnings => true
pod 'GTMAppAuth', :inhibit_warnings => true

If the SwiftPM feature is enabled, this caused duplicate modules and the build would fail.

This is a temporary workaround. In the future, we'll remove CocoaPod integration from these example apps. That's tracked by flutter/flutter#148021.


flutter_ios_podfile_setup

target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths

pod 'OCMock','3.5'
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
403C71302C66A2E50034A230 /* OCMock in Frameworks */ = {isa = PBXBuildFile; productRef = 403C712F2C66A2E50034A230 /* OCMock */; };
5C6F5A6E1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C6F5A6D1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m */; };
78A36DA12AF5761E00CBFD43 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */; };
7ACDFB0E1E8944C400BE2D00 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7ACDFB0D1E8944C400BE2D00 /* AppFrameworkInfo.plist */; };
Expand Down Expand Up @@ -94,6 +95,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
403C71302C66A2E50034A230 /* OCMock in Frameworks */,
C56D3B06A42F3B35C1F47A43 /* libPods-RunnerTests.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -245,6 +247,9 @@
F76AC1A82666D0540040C8BC /* PBXTargetDependency */,
);
name = RunnerTests;
packageProductDependencies = (
403C712F2C66A2E50034A230 /* OCMock */,
);
productName = RunnerTests;
productReference = F76AC1A22666D0540040C8BC /* RunnerTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
Expand Down Expand Up @@ -300,6 +305,9 @@
Base,
);
mainGroup = 97C146E51CF9000F007C117D;
packageReferences = (
403C712E2C66A2E50034A230 /* XCRemoteSwiftPackageReference "ocmock" */,
);
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -639,6 +647,7 @@
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -673,6 +682,7 @@
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner";
WARNING_CFLAGS = "-Wno-incomplete-umbrella";
};
name = Debug;
};
Expand All @@ -691,6 +701,7 @@
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner";
WARNING_CFLAGS = "-Wno-incomplete-umbrella";
};
name = Release;
};
Expand Down Expand Up @@ -766,6 +777,25 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
403C712E2C66A2E50034A230 /* XCRemoteSwiftPackageReference "ocmock" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/erikdoe/ocmock";
requirement = {
kind = revision;
revision = fe1661a3efed11831a6452f4b1a0c5e6ddc08c3d;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
403C712F2C66A2E50034A230 /* OCMock */ = {
isa = XCSwiftPackageProductDependency;
package = 403C712E2C66A2E50034A230 /* XCRemoteSwiftPackageReference "ocmock" */;
productName = OCMock;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ target 'Runner' do
target 'RunnerTests' do
inherit! :search_paths
end

pod 'OCMock','3.5'
end

post_install do |installer|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
403C71332C66A4F70034A230 /* OCMock in Frameworks */ = {isa = PBXBuildFile; productRef = 403C71322C66A4F70034A230 /* OCMock */; };
D7B8415A3D20001DE212873D /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A19720E5189178660264EC3F /* Pods_Runner.framework */; };
F107B1B7E4ECB85727EC4286 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0BD1DCE969A7E7C76D9CF93C /* Pods_RunnerTests.framework */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -97,6 +98,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
403C71332C66A4F70034A230 /* OCMock in Frameworks */,
F107B1B7E4ECB85727EC4286 /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -229,6 +231,9 @@
331C80DA294CF71000263BE5 /* PBXTargetDependency */,
);
name = RunnerTests;
packageProductDependencies = (
403C71322C66A4F70034A230 /* OCMock */,
);
productName = RunnerTests;
productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
Expand Down Expand Up @@ -294,6 +299,9 @@
Base,
);
mainGroup = 33CC10E42044A3C60003C045;
packageReferences = (
403C71312C66A4F70034A230 /* XCRemoteSwiftPackageReference "ocmock" */,
);
productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -486,6 +494,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/google_sign_in_ios_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/google_sign_in_ios_example";
WARNING_CFLAGS = "-Wno-incomplete-umbrella";
};
name = Debug;
};
Expand All @@ -501,6 +510,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/google_sign_in_ios_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/google_sign_in_ios_example";
WARNING_CFLAGS = "-Wno-incomplete-umbrella";
};
name = Release;
};
Expand All @@ -516,6 +526,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/google_sign_in_ios_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/google_sign_in_ios_example";
WARNING_CFLAGS = "-Wno-incomplete-umbrella";
};
name = Profile;
};
Expand Down Expand Up @@ -790,6 +801,25 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
403C71312C66A4F70034A230 /* XCRemoteSwiftPackageReference "ocmock" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/erikdoe/ocmock";
requirement = {
kind = revision;
revision = fe1661a3efed11831a6452f4b1a0c5e6ddc08c3d;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
403C71322C66A4F70034A230 /* OCMock */ = {
isa = XCSwiftPackageProductDependency;
package = 403C71312C66A4F70034A230 /* XCRemoteSwiftPackageReference "ocmock" */;
productName = OCMock;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 33CC10E52044A3C60003C045 /* Project object */;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ import 'package:pigeon/pigeon.dart';

@ConfigurePigeon(PigeonOptions(
dartOut: 'lib/src/messages.g.dart',
objcOptions: ObjcOptions(prefix: 'FSI'),
objcHeaderOut: 'darwin/Classes/messages.g.h',
objcSourceOut: 'darwin/Classes/messages.g.m',
objcHeaderOut:
'darwin/google_sign_in_ios/Sources/google_sign_in/include/google_sign_in/messages.g.h',
objcSourceOut:
'darwin/google_sign_in_ios/Sources/google_sign_in/messages.g.m',
objcOptions: ObjcOptions(
prefix: 'FSI',
headerIncludePath: './include/google_sign_in/messages.g.h',
),
copyrightHeader: 'pigeons/copyright.txt',
))

Expand Down
2 changes: 1 addition & 1 deletion packages/google_sign_in/google_sign_in_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_sign_in_ios
description: iOS implementation of the google_sign_in plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 5.7.8
version: 5.8.0

environment:
sdk: ^3.3.0
Expand Down
2 changes: 2 additions & 0 deletions script/configs/exclude_xcode_analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Depends on AppAuth-iOS which emits analysis warnings.
- google_sign_in_ios
2 changes: 2 additions & 0 deletions script/configs/exclude_xcode_deprecation.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# TODO(louisehsu): Remove deprecation check when StoreKit 2 is adopted. https://github.com/flutter/flutter/issues/116383
- in_app_purchase_storekit
# Depends on AppAuth-iOS which uses deprecated APIs.
- google_sign_in_ios
3 changes: 2 additions & 1 deletion script/tool/lib/src/native_test_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,8 @@ this command.
extraFlags: <String>[
if (testTarget != null) '-only-testing:$testTarget',
...extraFlags,
'GCC_TREAT_WARNINGS_AS_ERRORS=YES',
// TODO(loicsharma): THIS IS A TEST - UNDO!
'GCC_TREAT_WARNINGS_AS_ERRORS=NO',
],
);

Expand Down