From fd7f03619543e7462b6c72aa8091bf166a3ed1c0 Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Tue, 26 Jan 2021 15:56:19 -0500 Subject: [PATCH 01/17] Update .gitignore --- .gitignore | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..0302e5ae --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# OS X +.DS_Store + +# Xcode +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ +*.xccheckout +profile +*.moved-aside +DerivedData +*.hmap +*.ipa + +# Swift Package Manager +*/.build + +# CocoaPods generate +gen/ From bf1a1e66d9fbd795c72f2072e4af2e2a5a839c8d Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Wed, 27 Jan 2021 11:46:42 -0500 Subject: [PATCH 02/17] MulticastAppDelegate introduced --- GoogleUtilities.podspec | 4 ++ .../MulticastAppDelegate.swift | 58 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift diff --git a/GoogleUtilities.podspec b/GoogleUtilities.podspec index 1f340c58..997ee248 100644 --- a/GoogleUtilities.podspec +++ b/GoogleUtilities.podspec @@ -97,6 +97,10 @@ other Google CocoaPods. They're not intended for direct public usage. adss.dependency 'GoogleUtilities/Environment' end + s.subspec 'MulticastAppDelegate' do |mad| + mad.source_files = 'GoogleUtilities/MulticastAppDelegate/**/*.swift' + end + s.subspec 'ISASwizzler' do |iss| iss.source_files = 'GoogleUtilities/ISASwizzler/**/*.[mh]', 'GoogleUtilities/Common/*.h' iss.public_header_files = 'GoogleUtilities/ISASwizzler/Public/GoogleUtilities/*.h' diff --git a/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift b/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift new file mode 100644 index 00000000..c758db27 --- /dev/null +++ b/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift @@ -0,0 +1,58 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import UIKit + +@objc +public protocol MulticastAppDelegateProtocol: NSObjectProtocol { + typealias Delegate = UIApplicationDelegate + + func addInterceptor(_ interceptor: Delegate) + func removeInterceptor(_ interceptor: Delegate) +} + +@objc +public class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate { + private var interceptors: [MulticastAppDelegateProtocol.Delegate] = [] + + @objc + public func addInterceptor(_ interceptor: Delegate) { + interceptors.append(interceptor) + } + + @objc + public func removeInterceptor(_ interceptor: Delegate) { + interceptors = interceptors.filter { $0 !== interceptor } + } +} + +extension MulticastAppDelegate: MulticastAppDelegateProtocol { + + public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + var result = false + + for interceptor in interceptors { + result = result || interceptor.application?(app, open: url, options: options) ?? false + } + + return result + } + + public func application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { + for interceptor in interceptors { + interceptor.application?(application, didReceiveRemoteNotification: notification, fetchCompletionHandler:completionHandler) + } + } + +} From f0487b6cc6ad4e0a60f80cd8e849643ba45f12d7 Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Fri, 12 Feb 2021 15:57:25 -0500 Subject: [PATCH 03/17] WIP --- .../MulticastAppDelegate/MulticastAppDelegate.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift b/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift index c758db27..4516e0ce 100644 --- a/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift +++ b/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift @@ -24,7 +24,17 @@ public protocol MulticastAppDelegateProtocol: NSObjectProtocol { @objc public class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate { + private var appDelegate: MulticastAppDelegateProtocol.Delegate? private var interceptors: [MulticastAppDelegateProtocol.Delegate] = [] + private var allInterceptors: [MulticastAppDelegateProtocol.Delegate] { + var allInterceptors: [MulticastAppDelegateProtocol.Delegate] = appDelegate != nil ? [appDelegate!] : [] + return allInterceptors + } + + public init(appDelegate: MulticastAppDelegateProtocol.Delegate) { + super.init() + self.appDelegate = appDelegate + } @objc public func addInterceptor(_ interceptor: Delegate) { @@ -35,6 +45,8 @@ public class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delega public func removeInterceptor(_ interceptor: Delegate) { interceptors = interceptors.filter { $0 !== interceptor } } + + } extension MulticastAppDelegate: MulticastAppDelegateProtocol { From 9a144334bddca18614fdb06feff7e6cdf4f58a5b Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Fri, 12 Feb 2021 17:10:51 -0500 Subject: [PATCH 04/17] A sample app --- .../project.pbxproj | 414 ++++++++++++++++++ .../AppDelegateSample/AppDelegate.swift | 44 ++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 98 +++++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../Base.lproj/Main.storyboard | 24 + .../AppDelegateSample/Info.plist | 66 +++ .../AppDelegateSample/SceneDelegate.swift | 52 +++ .../AppDelegateSample/ViewController.swift | 19 + .../AppDelegateSample/main.swift | 11 + AppDelegateSample/Podfile | 11 + .../MulticastAppDelegate.swift | 12 +- 13 files changed, 792 insertions(+), 1 deletion(-) create mode 100644 AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj create mode 100644 AppDelegateSample/AppDelegateSample/AppDelegate.swift create mode 100644 AppDelegateSample/AppDelegateSample/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 AppDelegateSample/AppDelegateSample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 AppDelegateSample/AppDelegateSample/Assets.xcassets/Contents.json create mode 100644 AppDelegateSample/AppDelegateSample/Base.lproj/LaunchScreen.storyboard create mode 100644 AppDelegateSample/AppDelegateSample/Base.lproj/Main.storyboard create mode 100644 AppDelegateSample/AppDelegateSample/Info.plist create mode 100644 AppDelegateSample/AppDelegateSample/SceneDelegate.swift create mode 100644 AppDelegateSample/AppDelegateSample/ViewController.swift create mode 100644 AppDelegateSample/AppDelegateSample/main.swift create mode 100644 AppDelegateSample/Podfile diff --git a/AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj b/AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj new file mode 100644 index 00000000..0e2177ac --- /dev/null +++ b/AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj @@ -0,0 +1,414 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + 0E3536E73AC7531C0781E543 /* Pods_AppDelegateSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EBFC65FD063BF93267C9B957 /* Pods_AppDelegateSample.framework */; }; + 9AF8E6C025C35F800084E9E2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AF8E6BF25C35F800084E9E2 /* AppDelegate.swift */; }; + 9AF8E6C225C35F800084E9E2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AF8E6C125C35F800084E9E2 /* SceneDelegate.swift */; }; + 9AF8E6C425C35F800084E9E2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AF8E6C325C35F800084E9E2 /* ViewController.swift */; }; + 9AF8E6C725C35F800084E9E2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9AF8E6C525C35F800084E9E2 /* Main.storyboard */; }; + 9AF8E6C925C35F830084E9E2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9AF8E6C825C35F830084E9E2 /* Assets.xcassets */; }; + 9AF8E6CC25C35F830084E9E2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9AF8E6CA25C35F830084E9E2 /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 9AF8E6BC25C35F800084E9E2 /* AppDelegateSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AppDelegateSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 9AF8E6BF25C35F800084E9E2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 9AF8E6C125C35F800084E9E2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 9AF8E6C325C35F800084E9E2 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 9AF8E6C625C35F800084E9E2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 9AF8E6C825C35F830084E9E2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 9AF8E6CB25C35F830084E9E2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 9AF8E6CD25C35F830084E9E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + CF546BA22ECF73FD9F04FB80 /* Pods-AppDelegateSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppDelegateSample.debug.xcconfig"; path = "Target Support Files/Pods-AppDelegateSample/Pods-AppDelegateSample.debug.xcconfig"; sourceTree = ""; }; + EBFC65FD063BF93267C9B957 /* Pods_AppDelegateSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AppDelegateSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + FD1D158F357E0539EE8E7E7D /* Pods-AppDelegateSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppDelegateSample.release.xcconfig"; path = "Target Support Files/Pods-AppDelegateSample/Pods-AppDelegateSample.release.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9AF8E6B925C35F800084E9E2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0E3536E73AC7531C0781E543 /* Pods_AppDelegateSample.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0D9480B88DAD8B72D5244C37 /* Frameworks */ = { + isa = PBXGroup; + children = ( + EBFC65FD063BF93267C9B957 /* Pods_AppDelegateSample.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 80858BFCE9E0B612173E6EDA /* Pods */ = { + isa = PBXGroup; + children = ( + CF546BA22ECF73FD9F04FB80 /* Pods-AppDelegateSample.debug.xcconfig */, + FD1D158F357E0539EE8E7E7D /* Pods-AppDelegateSample.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + 9AF8E6B325C35F800084E9E2 = { + isa = PBXGroup; + children = ( + 9AF8E6BE25C35F800084E9E2 /* AppDelegateSample */, + 9AF8E6BD25C35F800084E9E2 /* Products */, + 80858BFCE9E0B612173E6EDA /* Pods */, + 0D9480B88DAD8B72D5244C37 /* Frameworks */, + ); + sourceTree = ""; + }; + 9AF8E6BD25C35F800084E9E2 /* Products */ = { + isa = PBXGroup; + children = ( + 9AF8E6BC25C35F800084E9E2 /* AppDelegateSample.app */, + ); + name = Products; + sourceTree = ""; + }; + 9AF8E6BE25C35F800084E9E2 /* AppDelegateSample */ = { + isa = PBXGroup; + children = ( + 9AF8E6BF25C35F800084E9E2 /* AppDelegate.swift */, + 9AF8E6C125C35F800084E9E2 /* SceneDelegate.swift */, + 9AF8E6C325C35F800084E9E2 /* ViewController.swift */, + 9AF8E6C525C35F800084E9E2 /* Main.storyboard */, + 9AF8E6C825C35F830084E9E2 /* Assets.xcassets */, + 9AF8E6CA25C35F830084E9E2 /* LaunchScreen.storyboard */, + 9AF8E6CD25C35F830084E9E2 /* Info.plist */, + ); + path = AppDelegateSample; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9AF8E6BB25C35F800084E9E2 /* AppDelegateSample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9AF8E6D025C35F830084E9E2 /* Build configuration list for PBXNativeTarget "AppDelegateSample" */; + buildPhases = ( + 5077B86BDDE805542F9F4853 /* [CP] Check Pods Manifest.lock */, + 9AF8E6B825C35F800084E9E2 /* Sources */, + 9AF8E6B925C35F800084E9E2 /* Frameworks */, + 9AF8E6BA25C35F800084E9E2 /* Resources */, + E3791509D629949AE08392A8 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AppDelegateSample; + productName = AppDelegateSample; + productReference = 9AF8E6BC25C35F800084E9E2 /* AppDelegateSample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9AF8E6B425C35F800084E9E2 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1230; + LastUpgradeCheck = 1230; + TargetAttributes = { + 9AF8E6BB25C35F800084E9E2 = { + CreatedOnToolsVersion = 12.3; + }; + }; + }; + buildConfigurationList = 9AF8E6B725C35F800084E9E2 /* Build configuration list for PBXProject "AppDelegateSample" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 9AF8E6B325C35F800084E9E2; + productRefGroup = 9AF8E6BD25C35F800084E9E2 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9AF8E6BB25C35F800084E9E2 /* AppDelegateSample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 9AF8E6BA25C35F800084E9E2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9AF8E6CC25C35F830084E9E2 /* LaunchScreen.storyboard in Resources */, + 9AF8E6C925C35F830084E9E2 /* Assets.xcassets in Resources */, + 9AF8E6C725C35F800084E9E2 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 5077B86BDDE805542F9F4853 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-AppDelegateSample-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + 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; + }; + E3791509D629949AE08392A8 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-AppDelegateSample/Pods-AppDelegateSample-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-AppDelegateSample/Pods-AppDelegateSample-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AppDelegateSample/Pods-AppDelegateSample-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 9AF8E6B825C35F800084E9E2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9AF8E6C425C35F800084E9E2 /* ViewController.swift in Sources */, + 9AF8E6C025C35F800084E9E2 /* AppDelegate.swift in Sources */, + 9AF8E6C225C35F800084E9E2 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 9AF8E6C525C35F800084E9E2 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9AF8E6C625C35F800084E9E2 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 9AF8E6CA25C35F830084E9E2 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9AF8E6CB25C35F830084E9E2 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 9AF8E6CE25C35F830084E9E2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.3; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 9AF8E6CF25C35F830084E9E2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.3; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 9AF8E6D125C35F830084E9E2 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = CF546BA22ECF73FD9F04FB80 /* Pods-AppDelegateSample.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = AppDelegateSample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = firebase.google.com.AppDelegateSample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 9AF8E6D225C35F830084E9E2 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FD1D158F357E0539EE8E7E7D /* Pods-AppDelegateSample.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = AppDelegateSample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = firebase.google.com.AppDelegateSample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9AF8E6B725C35F800084E9E2 /* Build configuration list for PBXProject "AppDelegateSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9AF8E6CE25C35F830084E9E2 /* Debug */, + 9AF8E6CF25C35F830084E9E2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9AF8E6D025C35F830084E9E2 /* Build configuration list for PBXNativeTarget "AppDelegateSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9AF8E6D125C35F830084E9E2 /* Debug */, + 9AF8E6D225C35F830084E9E2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9AF8E6B425C35F800084E9E2 /* Project object */; +} diff --git a/AppDelegateSample/AppDelegateSample/AppDelegate.swift b/AppDelegateSample/AppDelegateSample/AppDelegate.swift new file mode 100644 index 00000000..96b46a44 --- /dev/null +++ b/AppDelegateSample/AppDelegateSample/AppDelegate.swift @@ -0,0 +1,44 @@ +// +// AppDelegate.swift +// AppDelegateSample +// +// Created by Maksym Malyhin on 2021-01-28. +// + +import UIKit + +import GoogleUtilities + +@UIApplicationMain +class MulticastAppDelegate: GoogleUtilities.MulticastAppDelegate { + override init() { + super.init() + self.addInterceptor(AppDelegate()) + } +} + + +class AppDelegate: UIResponder, UIApplicationDelegate { + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/AppDelegateSample/AppDelegateSample/Assets.xcassets/AccentColor.colorset/Contents.json b/AppDelegateSample/AppDelegateSample/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/AppDelegateSample/AppDelegateSample/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/AppDelegateSample/AppDelegateSample/Assets.xcassets/AppIcon.appiconset/Contents.json b/AppDelegateSample/AppDelegateSample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9221b9bb --- /dev/null +++ b/AppDelegateSample/AppDelegateSample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/AppDelegateSample/AppDelegateSample/Assets.xcassets/Contents.json b/AppDelegateSample/AppDelegateSample/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/AppDelegateSample/AppDelegateSample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/AppDelegateSample/AppDelegateSample/Base.lproj/LaunchScreen.storyboard b/AppDelegateSample/AppDelegateSample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/AppDelegateSample/AppDelegateSample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AppDelegateSample/AppDelegateSample/Base.lproj/Main.storyboard b/AppDelegateSample/AppDelegateSample/Base.lproj/Main.storyboard new file mode 100644 index 00000000..25a76385 --- /dev/null +++ b/AppDelegateSample/AppDelegateSample/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AppDelegateSample/AppDelegateSample/Info.plist b/AppDelegateSample/AppDelegateSample/Info.plist new file mode 100644 index 00000000..5b531f7b --- /dev/null +++ b/AppDelegateSample/AppDelegateSample/Info.plist @@ -0,0 +1,66 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/AppDelegateSample/AppDelegateSample/SceneDelegate.swift b/AppDelegateSample/AppDelegateSample/SceneDelegate.swift new file mode 100644 index 00000000..19f3e7d2 --- /dev/null +++ b/AppDelegateSample/AppDelegateSample/SceneDelegate.swift @@ -0,0 +1,52 @@ +// +// SceneDelegate.swift +// AppDelegateSample +// +// Created by Maksym Malyhin on 2021-01-28. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/AppDelegateSample/AppDelegateSample/ViewController.swift b/AppDelegateSample/AppDelegateSample/ViewController.swift new file mode 100644 index 00000000..d09b77ac --- /dev/null +++ b/AppDelegateSample/AppDelegateSample/ViewController.swift @@ -0,0 +1,19 @@ +// +// ViewController.swift +// AppDelegateSample +// +// Created by Maksym Malyhin on 2021-01-28. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + +} + diff --git a/AppDelegateSample/AppDelegateSample/main.swift b/AppDelegateSample/AppDelegateSample/main.swift new file mode 100644 index 00000000..f946c149 --- /dev/null +++ b/AppDelegateSample/AppDelegateSample/main.swift @@ -0,0 +1,11 @@ +// +// main.swift +// AppDelegateSample +// +// Created by Maksym Malyhin on 2021-01-28. +// + +import UIKit +import GoogleUtilities + +//UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, nil, NSStringFromClass(MulticastAppDelegate.self)) diff --git a/AppDelegateSample/Podfile b/AppDelegateSample/Podfile new file mode 100644 index 00000000..d5e89ba9 --- /dev/null +++ b/AppDelegateSample/Podfile @@ -0,0 +1,11 @@ +# Uncomment the next line to define a global platform for your project +# platform :ios, '9.0' + +target 'AppDelegateSample' do + # Comment the next line if you don't want to use dynamic frameworks + use_frameworks! + + # Pods for AppDelegateSample + + pod 'GoogleUtilities', :path=>'../' +end diff --git a/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift b/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift index c758db27..a77e4c8c 100644 --- a/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift +++ b/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift @@ -23,7 +23,7 @@ public protocol MulticastAppDelegateProtocol: NSObjectProtocol { } @objc -public class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate { +open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate { private var interceptors: [MulticastAppDelegateProtocol.Delegate] = [] @objc @@ -39,6 +39,16 @@ public class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delega extension MulticastAppDelegate: MulticastAppDelegateProtocol { + public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + var result = false + + for interceptor in interceptors { + result = result || interceptor.application?(application, didFinishLaunchingWithOptions: launchOptions) ?? false + } + + return result + } + public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { var result = false From 9142473ba758de6114b97b703a2a57bc74eb2144 Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Fri, 12 Feb 2021 17:25:11 -0500 Subject: [PATCH 05/17] Forward all unknown messages to the original app delegate --- .../MulticastAppDelegate.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift b/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift index 27e7d312..fb923fcf 100644 --- a/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift +++ b/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift @@ -27,7 +27,12 @@ open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate private var appDelegate: MulticastAppDelegateProtocol.Delegate? private var interceptors: [MulticastAppDelegateProtocol.Delegate] = [] private var allInterceptors: [MulticastAppDelegateProtocol.Delegate] { - var allInterceptors: [MulticastAppDelegateProtocol.Delegate] = appDelegate != nil ? [appDelegate!] : [] + guard let appDelegate = appDelegate else { + return interceptors + } + + var allInterceptors = [appDelegate] + allInterceptors.append(contentsOf: interceptors) return allInterceptors } @@ -46,7 +51,18 @@ open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate interceptors = interceptors.filter { $0 !== interceptor } } + // Forward all unknown messages to the original app delegate. + public override func responds(to aSelector: Selector!) -> Bool { + if type(of: self).instancesRespond(to: aSelector) { + return true + } + + return appDelegate?.responds(to: aSelector) ?? false + } + open override func forwardingTarget(for aSelector: Selector!) -> Any? { + return appDelegate + } } extension MulticastAppDelegate: MulticastAppDelegateProtocol { From 721bb3006c2b17c65ac5651513342f810f152179 Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Fri, 12 Feb 2021 17:42:08 -0500 Subject: [PATCH 06/17] Define a separate GoogleMulticastAppDelegate package --- GoogleMulticastAppDelegate.podspec | 70 +++++++++++++++++++ .../project.pbxproj | 0 .../AppDelegateSample/AppDelegate.swift | 0 .../AccentColor.colorset/Contents.json | 0 .../AppIcon.appiconset/Contents.json | 0 .../Assets.xcassets/Contents.json | 0 .../Base.lproj/LaunchScreen.storyboard | 0 .../Base.lproj/Main.storyboard | 0 .../AppDelegateSample/Info.plist | 0 .../AppDelegateSample/SceneDelegate.swift | 0 .../AppDelegateSample/ViewController.swift | 0 .../AppDelegateSample/main.swift | 0 .../Apps/AppDelegateSample}/Podfile | 0 .../Sources}/MulticastAppDelegate.swift | 0 14 files changed, 70 insertions(+) create mode 100644 GoogleMulticastAppDelegate.podspec rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample.xcodeproj/project.pbxproj (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample/AppDelegate.swift (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample/Assets.xcassets/AccentColor.colorset/Contents.json (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample/Assets.xcassets/Contents.json (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample/Base.lproj/LaunchScreen.storyboard (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample/Base.lproj/Main.storyboard (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample/Info.plist (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample/SceneDelegate.swift (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample/ViewController.swift (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/AppDelegateSample/main.swift (100%) rename {AppDelegateSample => GoogleMulticastAppDelegate/Apps/AppDelegateSample}/Podfile (100%) rename {GoogleUtilities/MulticastAppDelegate => GoogleMulticastAppDelegate/Sources}/MulticastAppDelegate.swift (100%) diff --git a/GoogleMulticastAppDelegate.podspec b/GoogleMulticastAppDelegate.podspec new file mode 100644 index 00000000..15f88446 --- /dev/null +++ b/GoogleMulticastAppDelegate.podspec @@ -0,0 +1,70 @@ +Pod::Spec.new do |s| + # TODO: Is `GoogleMulticastAppDelegate` name fine? + s.name = 'GoogleMulticastAppDelegate' + s.version = '7.2.2' + s.summary = 'GoogleMulticastAppDelegate' + + s.description = <<-DESC + GoogleMulticastAppDelegate + DESC + + s.homepage = 'https://github.com/google/GoogleUtilities' + s.license = { :type => 'Apache', :file => 'LICENSE' } + s.authors = 'Google, Inc.' + + s.source = { + :git => 'https://github.com/google/GoogleUtilities.git', + :tag => 'CocoaPods-' + s.version.to_s + } + + ios_deployment_target = '9.0' + osx_deployment_target = '10.12' + tvos_deployment_target = '10.0' + watchos_deployment_target = '6.0' + + s.ios.deployment_target = ios_deployment_target + s.osx.deployment_target = osx_deployment_target + s.tvos.deployment_target = tvos_deployment_target + s.watchos.deployment_target = watchos_deployment_target + + s.cocoapods_version = '>= 1.4.0' + s.prefix_header_file = false + + s.pod_target_xcconfig = { + 'GCC_C_LANGUAGE_STANDARD' => 'c99', + 'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"', + } + + base_dir = "GoogleMulticastAppDelegate/" + s.source_files = [ + base_dir + 'Sources/**/*.swift', + ] + + # s.test_spec 'unit' do |unit_tests| + # unit_tests.scheme = { :code_coverage => true } + # unit_tests.platforms = { + # :ios => ios_deployment_target, + # :osx => osx_deployment_target, + # :tvos => tvos_deployment_target + # } + # unit_tests.source_files = [ + # base_dir + 'Tests/Unit/**/*.[mh]', + # ] + # unit_tests.requires_app_host = true + # unit_tests.dependency 'OCMock' + # end + + # s.test_spec 'unit-swift' do |unit_tests_swift| + # unit_tests_swift.scheme = { :code_coverage => true } + # unit_tests_swift.platforms = { + # :ios => ios_deployment_target, + # :osx => osx_deployment_target, + # :tvos => tvos_deployment_target + # } + # unit_tests_swift.source_files = [ + # base_dir + 'Tests/Unit/**/*.swift', + # ] + + # unit_tests_swift.requires_app_host = true + # end +end diff --git a/AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj similarity index 100% rename from AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj diff --git a/AppDelegateSample/AppDelegateSample/AppDelegate.swift b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/AppDelegate.swift similarity index 100% rename from AppDelegateSample/AppDelegateSample/AppDelegate.swift rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/AppDelegate.swift diff --git a/AppDelegateSample/AppDelegateSample/Assets.xcassets/AccentColor.colorset/Contents.json b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from AppDelegateSample/AppDelegateSample/Assets.xcassets/AccentColor.colorset/Contents.json rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/AppDelegateSample/AppDelegateSample/Assets.xcassets/AppIcon.appiconset/Contents.json b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from AppDelegateSample/AppDelegateSample/Assets.xcassets/AppIcon.appiconset/Contents.json rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/AppDelegateSample/AppDelegateSample/Assets.xcassets/Contents.json b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Assets.xcassets/Contents.json similarity index 100% rename from AppDelegateSample/AppDelegateSample/Assets.xcassets/Contents.json rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Assets.xcassets/Contents.json diff --git a/AppDelegateSample/AppDelegateSample/Base.lproj/LaunchScreen.storyboard b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from AppDelegateSample/AppDelegateSample/Base.lproj/LaunchScreen.storyboard rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Base.lproj/LaunchScreen.storyboard diff --git a/AppDelegateSample/AppDelegateSample/Base.lproj/Main.storyboard b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Base.lproj/Main.storyboard similarity index 100% rename from AppDelegateSample/AppDelegateSample/Base.lproj/Main.storyboard rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Base.lproj/Main.storyboard diff --git a/AppDelegateSample/AppDelegateSample/Info.plist b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Info.plist similarity index 100% rename from AppDelegateSample/AppDelegateSample/Info.plist rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/Info.plist diff --git a/AppDelegateSample/AppDelegateSample/SceneDelegate.swift b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/SceneDelegate.swift similarity index 100% rename from AppDelegateSample/AppDelegateSample/SceneDelegate.swift rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/SceneDelegate.swift diff --git a/AppDelegateSample/AppDelegateSample/ViewController.swift b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/ViewController.swift similarity index 100% rename from AppDelegateSample/AppDelegateSample/ViewController.swift rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/ViewController.swift diff --git a/AppDelegateSample/AppDelegateSample/main.swift b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/main.swift similarity index 100% rename from AppDelegateSample/AppDelegateSample/main.swift rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample/main.swift diff --git a/AppDelegateSample/Podfile b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/Podfile similarity index 100% rename from AppDelegateSample/Podfile rename to GoogleMulticastAppDelegate/Apps/AppDelegateSample/Podfile diff --git a/GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift similarity index 100% rename from GoogleUtilities/MulticastAppDelegate/MulticastAppDelegate.swift rename to GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift From 2fa7d37b604f112fc185a656c4687231fccf9c0d Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Mon, 22 Feb 2021 16:03:17 -0500 Subject: [PATCH 07/17] MulticastAppDelegate fixes --- .../Sources/MulticastAppDelegate.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift index fb923fcf..6164978e 100644 --- a/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift +++ b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift @@ -24,7 +24,7 @@ public protocol MulticastAppDelegateProtocol: NSObjectProtocol { @objc open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate { - private var appDelegate: MulticastAppDelegateProtocol.Delegate? + public var appDelegate: MulticastAppDelegateProtocol.Delegate? private var interceptors: [MulticastAppDelegateProtocol.Delegate] = [] private var allInterceptors: [MulticastAppDelegateProtocol.Delegate] { guard let appDelegate = appDelegate else { @@ -36,6 +36,10 @@ open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate return allInterceptors } + public override init() { + super.init() + } + public init(appDelegate: MulticastAppDelegateProtocol.Delegate) { super.init() self.appDelegate = appDelegate @@ -70,7 +74,7 @@ extension MulticastAppDelegate: MulticastAppDelegateProtocol { public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { var result = false - for interceptor in interceptors { + for interceptor in allInterceptors { result = result || interceptor.application?(application, didFinishLaunchingWithOptions: launchOptions) ?? false } @@ -80,7 +84,7 @@ extension MulticastAppDelegate: MulticastAppDelegateProtocol { public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { var result = false - for interceptor in interceptors { + for interceptor in allInterceptors { result = result || interceptor.application?(app, open: url, options: options) ?? false } @@ -88,7 +92,7 @@ extension MulticastAppDelegate: MulticastAppDelegateProtocol { } public func application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { - for interceptor in interceptors { + for interceptor in allInterceptors { interceptor.application?(application, didReceiveRemoteNotification: notification, fetchCompletionHandler:completionHandler) } } From edbaff895c4724db3c943d47c04b877f5e7f0c70 Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Mon, 22 Feb 2021 16:10:18 -0500 Subject: [PATCH 08/17] TODO --- GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift index 6164978e..efedd412 100644 --- a/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift +++ b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift @@ -93,6 +93,7 @@ extension MulticastAppDelegate: MulticastAppDelegateProtocol { public func application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { for interceptor in allInterceptors { + // TODO: Make sure completionHandler is called once. interceptor.application?(application, didReceiveRemoteNotification: notification, fetchCompletionHandler:completionHandler) } } From 1b80aa0064810d04187507c44668adfff1cd92dc Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Mon, 22 Feb 2021 16:12:22 -0500 Subject: [PATCH 09/17] Swift UI sample app --- .../project.pbxproj | 180 ++++++++++++++++++ .../Apps/AppDelegateSample/Podfile | 13 +- .../AccentColor.colorset/Contents.json | 11 ++ .../AppIcon.appiconset/Contents.json | 98 ++++++++++ .../SwiftUI-iOS/Assets.xcassets/Contents.json | 6 + .../SwiftUI-iOS/ContentView.swift | 21 ++ .../AppDelegateSample/SwiftUI-iOS/Info.plist | 50 +++++ .../Preview Assets.xcassets/Contents.json | 6 + .../SwiftUI-iOS/SwiftUI_iOSApp.swift | 35 ++++ 9 files changed, 413 insertions(+), 7 deletions(-) create mode 100644 GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/Contents.json create mode 100644 GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/ContentView.swift create mode 100644 GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Info.plist create mode 100644 GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/SwiftUI_iOSApp.swift diff --git a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj index 0e2177ac..3ae76a2d 100644 --- a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj +++ b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/AppDelegateSample.xcodeproj/project.pbxproj @@ -8,6 +8,11 @@ /* Begin PBXBuildFile section */ 0E3536E73AC7531C0781E543 /* Pods_AppDelegateSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EBFC65FD063BF93267C9B957 /* Pods_AppDelegateSample.framework */; }; + 6E084AE3778AAE4EBF48930C /* Pods_SwiftUI_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F504297D39756043ED4C7A12 /* Pods_SwiftUI_iOS.framework */; }; + 9A2090D125E451B800A2E7D1 /* SwiftUI_iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A2090D025E451B800A2E7D1 /* SwiftUI_iOSApp.swift */; }; + 9A2090D325E451B800A2E7D1 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A2090D225E451B800A2E7D1 /* ContentView.swift */; }; + 9A2090D525E451B900A2E7D1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9A2090D425E451B900A2E7D1 /* Assets.xcassets */; }; + 9A2090D825E451B900A2E7D1 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9A2090D725E451B900A2E7D1 /* Preview Assets.xcassets */; }; 9AF8E6C025C35F800084E9E2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AF8E6BF25C35F800084E9E2 /* AppDelegate.swift */; }; 9AF8E6C225C35F800084E9E2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AF8E6C125C35F800084E9E2 /* SceneDelegate.swift */; }; 9AF8E6C425C35F800084E9E2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AF8E6C325C35F800084E9E2 /* ViewController.swift */; }; @@ -17,6 +22,12 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 9A2090CE25E451B800A2E7D1 /* SwiftUI-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SwiftUI-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 9A2090D025E451B800A2E7D1 /* SwiftUI_iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUI_iOSApp.swift; sourceTree = ""; }; + 9A2090D225E451B800A2E7D1 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 9A2090D425E451B900A2E7D1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 9A2090D725E451B900A2E7D1 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 9A2090D925E451B900A2E7D1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9AF8E6BC25C35F800084E9E2 /* AppDelegateSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AppDelegateSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 9AF8E6BF25C35F800084E9E2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 9AF8E6C125C35F800084E9E2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -25,12 +36,23 @@ 9AF8E6C825C35F830084E9E2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 9AF8E6CB25C35F830084E9E2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 9AF8E6CD25C35F830084E9E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + BA05767CBCFA6A35F8E3DD64 /* Pods-SwiftUI-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftUI-iOS.release.xcconfig"; path = "Target Support Files/Pods-SwiftUI-iOS/Pods-SwiftUI-iOS.release.xcconfig"; sourceTree = ""; }; CF546BA22ECF73FD9F04FB80 /* Pods-AppDelegateSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppDelegateSample.debug.xcconfig"; path = "Target Support Files/Pods-AppDelegateSample/Pods-AppDelegateSample.debug.xcconfig"; sourceTree = ""; }; + EA77D7A3FC6896C7A2A93B7A /* Pods-SwiftUI-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftUI-iOS.debug.xcconfig"; path = "Target Support Files/Pods-SwiftUI-iOS/Pods-SwiftUI-iOS.debug.xcconfig"; sourceTree = ""; }; EBFC65FD063BF93267C9B957 /* Pods_AppDelegateSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AppDelegateSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F504297D39756043ED4C7A12 /* Pods_SwiftUI_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftUI_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; FD1D158F357E0539EE8E7E7D /* Pods-AppDelegateSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppDelegateSample.release.xcconfig"; path = "Target Support Files/Pods-AppDelegateSample/Pods-AppDelegateSample.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 9A2090CB25E451B800A2E7D1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6E084AE3778AAE4EBF48930C /* Pods_SwiftUI_iOS.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 9AF8E6B925C35F800084E9E2 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -46,6 +68,7 @@ isa = PBXGroup; children = ( EBFC65FD063BF93267C9B957 /* Pods_AppDelegateSample.framework */, + F504297D39756043ED4C7A12 /* Pods_SwiftUI_iOS.framework */, ); name = Frameworks; sourceTree = ""; @@ -55,14 +78,37 @@ children = ( CF546BA22ECF73FD9F04FB80 /* Pods-AppDelegateSample.debug.xcconfig */, FD1D158F357E0539EE8E7E7D /* Pods-AppDelegateSample.release.xcconfig */, + EA77D7A3FC6896C7A2A93B7A /* Pods-SwiftUI-iOS.debug.xcconfig */, + BA05767CBCFA6A35F8E3DD64 /* Pods-SwiftUI-iOS.release.xcconfig */, ); path = Pods; sourceTree = ""; }; + 9A2090CF25E451B800A2E7D1 /* SwiftUI-iOS */ = { + isa = PBXGroup; + children = ( + 9A2090D025E451B800A2E7D1 /* SwiftUI_iOSApp.swift */, + 9A2090D225E451B800A2E7D1 /* ContentView.swift */, + 9A2090D425E451B900A2E7D1 /* Assets.xcassets */, + 9A2090D925E451B900A2E7D1 /* Info.plist */, + 9A2090D625E451B900A2E7D1 /* Preview Content */, + ); + path = "SwiftUI-iOS"; + sourceTree = ""; + }; + 9A2090D625E451B900A2E7D1 /* Preview Content */ = { + isa = PBXGroup; + children = ( + 9A2090D725E451B900A2E7D1 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; 9AF8E6B325C35F800084E9E2 = { isa = PBXGroup; children = ( 9AF8E6BE25C35F800084E9E2 /* AppDelegateSample */, + 9A2090CF25E451B800A2E7D1 /* SwiftUI-iOS */, 9AF8E6BD25C35F800084E9E2 /* Products */, 80858BFCE9E0B612173E6EDA /* Pods */, 0D9480B88DAD8B72D5244C37 /* Frameworks */, @@ -73,6 +119,7 @@ isa = PBXGroup; children = ( 9AF8E6BC25C35F800084E9E2 /* AppDelegateSample.app */, + 9A2090CE25E451B800A2E7D1 /* SwiftUI-iOS.app */, ); name = Products; sourceTree = ""; @@ -94,6 +141,25 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 9A2090CD25E451B800A2E7D1 /* SwiftUI-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9A2090DC25E451B900A2E7D1 /* Build configuration list for PBXNativeTarget "SwiftUI-iOS" */; + buildPhases = ( + F0F6E6CAE5DCF214722D804D /* [CP] Check Pods Manifest.lock */, + 9A2090CA25E451B800A2E7D1 /* Sources */, + 9A2090CB25E451B800A2E7D1 /* Frameworks */, + 9A2090CC25E451B800A2E7D1 /* Resources */, + A5641932CD7FB26C434EE9C7 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "SwiftUI-iOS"; + productName = "SwiftUI-iOS"; + productReference = 9A2090CE25E451B800A2E7D1 /* SwiftUI-iOS.app */; + productType = "com.apple.product-type.application"; + }; 9AF8E6BB25C35F800084E9E2 /* AppDelegateSample */ = { isa = PBXNativeTarget; buildConfigurationList = 9AF8E6D025C35F830084E9E2 /* Build configuration list for PBXNativeTarget "AppDelegateSample" */; @@ -122,6 +188,9 @@ LastSwiftUpdateCheck = 1230; LastUpgradeCheck = 1230; TargetAttributes = { + 9A2090CD25E451B800A2E7D1 = { + CreatedOnToolsVersion = 12.3; + }; 9AF8E6BB25C35F800084E9E2 = { CreatedOnToolsVersion = 12.3; }; @@ -141,11 +210,21 @@ projectRoot = ""; targets = ( 9AF8E6BB25C35F800084E9E2 /* AppDelegateSample */, + 9A2090CD25E451B800A2E7D1 /* SwiftUI-iOS */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 9A2090CC25E451B800A2E7D1 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9A2090D825E451B900A2E7D1 /* Preview Assets.xcassets in Resources */, + 9A2090D525E451B900A2E7D1 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 9AF8E6BA25C35F800084E9E2 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -181,6 +260,23 @@ 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; }; + A5641932CD7FB26C434EE9C7 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-SwiftUI-iOS/Pods-SwiftUI-iOS-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-SwiftUI-iOS/Pods-SwiftUI-iOS-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SwiftUI-iOS/Pods-SwiftUI-iOS-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; E3791509D629949AE08392A8 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -198,9 +294,40 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AppDelegateSample/Pods-AppDelegateSample-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + F0F6E6CAE5DCF214722D804D /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-SwiftUI-iOS-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + 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; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 9A2090CA25E451B800A2E7D1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9A2090D325E451B800A2E7D1 /* ContentView.swift in Sources */, + 9A2090D125E451B800A2E7D1 /* SwiftUI_iOSApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 9AF8E6B825C35F800084E9E2 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -233,6 +360,50 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 9A2090DA25E451B900A2E7D1 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = EA77D7A3FC6896C7A2A93B7A /* Pods-SwiftUI-iOS.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "\"SwiftUI-iOS/Preview Content\""; + ENABLE_PREVIEWS = YES; + INFOPLIST_FILE = "SwiftUI-iOS/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "firebase.google.com.SwiftUI-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 9A2090DB25E451B900A2E7D1 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = BA05767CBCFA6A35F8E3DD64 /* Pods-SwiftUI-iOS.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "\"SwiftUI-iOS/Preview Content\""; + ENABLE_PREVIEWS = YES; + INFOPLIST_FILE = "SwiftUI-iOS/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "firebase.google.com.SwiftUI-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; 9AF8E6CE25C35F830084E9E2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -390,6 +561,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 9A2090DC25E451B900A2E7D1 /* Build configuration list for PBXNativeTarget "SwiftUI-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9A2090DA25E451B900A2E7D1 /* Debug */, + 9A2090DB25E451B900A2E7D1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 9AF8E6B725C35F800084E9E2 /* Build configuration list for PBXProject "AppDelegateSample" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/Podfile b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/Podfile index d5e89ba9..eea09c7b 100644 --- a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/Podfile +++ b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/Podfile @@ -1,11 +1,10 @@ -# Uncomment the next line to define a global platform for your project -# platform :ios, '9.0' -target 'AppDelegateSample' do - # Comment the next line if you don't want to use dynamic frameworks - use_frameworks! +use_frameworks! - # Pods for AppDelegateSample +pod 'GoogleMulticastAppDelegate', :path=>'../../../' - pod 'GoogleUtilities', :path=>'../' +target 'AppDelegateSample' do end + +target 'SwiftUI-iOS' do +end \ No newline at end of file diff --git a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/AccentColor.colorset/Contents.json b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9221b9bb --- /dev/null +++ b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/Contents.json b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/ContentView.swift b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/ContentView.swift new file mode 100644 index 00000000..d2d08244 --- /dev/null +++ b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/ContentView.swift @@ -0,0 +1,21 @@ +// +// ContentView.swift +// SwiftUI-iOS +// +// Created by Maksym Malyhin on 2021-02-22. +// + +import SwiftUI + +struct ContentView: View { + var body: some View { + Text("Hello, world!") + .padding() + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} diff --git a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Info.plist b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Info.plist new file mode 100644 index 00000000..efc211a0 --- /dev/null +++ b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Info.plist @@ -0,0 +1,50 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + + UIApplicationSupportsIndirectInputEvents + + UILaunchScreen + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Preview Content/Preview Assets.xcassets/Contents.json b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/SwiftUI_iOSApp.swift b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/SwiftUI_iOSApp.swift new file mode 100644 index 00000000..a28cfe4c --- /dev/null +++ b/GoogleMulticastAppDelegate/Apps/AppDelegateSample/SwiftUI-iOS/SwiftUI_iOSApp.swift @@ -0,0 +1,35 @@ +// +// SwiftUI_iOSApp.swift +// SwiftUI-iOS +// +// Created by Maksym Malyhin on 2021-02-22. +// + +import SwiftUI +import GoogleMulticastAppDelegate + +@objc +class AppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate { + func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { + return true + } +} + +@main +struct SwiftUI_iOSApp: App { + // Set `MulticastAppDelegate` as an App Delegate. + @UIApplicationDelegateAdaptor(MulticastAppDelegate.self) var delegate + + init() { + // Register the app's own App Delegate as an interceptor. + self.delegate.appDelegate = AppDelegate() + } + + + var body: some Scene { + WindowGroup { + ContentView() + } + } +} From 9e9f29f7fe540336a6dbfb69baa775aa89b2641b Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Mon, 22 Feb 2021 16:23:50 -0500 Subject: [PATCH 10/17] Use a separate tag for GoogleMulticastAppDelegate --- GoogleMulticastAppDelegate.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GoogleMulticastAppDelegate.podspec b/GoogleMulticastAppDelegate.podspec index 15f88446..718e238e 100644 --- a/GoogleMulticastAppDelegate.podspec +++ b/GoogleMulticastAppDelegate.podspec @@ -14,7 +14,7 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/google/GoogleUtilities.git', - :tag => 'CocoaPods-' + s.version.to_s + :tag => 'MulticastAppDelegate-' + s.version.to_s } ios_deployment_target = '9.0' From 7a7a230dc9f169ffe526e58c2708b061682dbde7 Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Mon, 22 Feb 2021 16:32:32 -0500 Subject: [PATCH 11/17] Exclude macOS and watchOS temporary --- GoogleMulticastAppDelegate.podspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GoogleMulticastAppDelegate.podspec b/GoogleMulticastAppDelegate.podspec index 718e238e..17d147a4 100644 --- a/GoogleMulticastAppDelegate.podspec +++ b/GoogleMulticastAppDelegate.podspec @@ -23,9 +23,9 @@ Pod::Spec.new do |s| watchos_deployment_target = '6.0' s.ios.deployment_target = ios_deployment_target - s.osx.deployment_target = osx_deployment_target - s.tvos.deployment_target = tvos_deployment_target - s.watchos.deployment_target = watchos_deployment_target + # s.osx.deployment_target = osx_deployment_target + # s.tvos.deployment_target = tvos_deployment_target + # s.watchos.deployment_target = watchos_deployment_target s.cocoapods_version = '>= 1.4.0' s.prefix_header_file = false From f830bd4a7773307abf44be6a50c5e3051fcd0364 Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Tue, 23 Feb 2021 17:02:15 -0500 Subject: [PATCH 12/17] MulticastAppDelegate: prepare for Auth use case --- .../Sources/MulticastAppDelegate.swift | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift index efedd412..654013da 100644 --- a/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift +++ b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift @@ -14,7 +14,10 @@ import UIKit -@objc +private typealias Application = UIApplication +private typealias ApplicationDelegate = UIApplicationDelegate + +@objc(GULMulticastAppDelegateProtocol) public protocol MulticastAppDelegateProtocol: NSObjectProtocol { typealias Delegate = UIApplicationDelegate @@ -22,8 +25,8 @@ public protocol MulticastAppDelegateProtocol: NSObjectProtocol { func removeInterceptor(_ interceptor: Delegate) } -@objc -open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate { +@objc(GULMulticastAppDelegate) +open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol { public var appDelegate: MulticastAppDelegateProtocol.Delegate? private var interceptors: [MulticastAppDelegateProtocol.Delegate] = [] private var allInterceptors: [MulticastAppDelegateProtocol.Delegate] { @@ -64,12 +67,23 @@ open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol.Delegate return appDelegate?.responds(to: aSelector) ?? false } - open override func forwardingTarget(for aSelector: Selector!) -> Any? { + open override func forwardingTarget(for aSelector: Selector) -> Any? { return appDelegate } } -extension MulticastAppDelegate: MulticastAppDelegateProtocol { +extension MulticastAppDelegate { + @objc + public class func installedMulticastDelegate() -> MulticastAppDelegateProtocol? { + guard let multicastDelegate = Application.shared.delegate as? MulticastAppDelegateProtocol else { + return nil + } + + return multicastDelegate + } +} + +extension MulticastAppDelegate: MulticastAppDelegateProtocol.Delegate { public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { var result = false @@ -91,6 +105,18 @@ extension MulticastAppDelegate: MulticastAppDelegateProtocol { return result } + public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { + for interceptor in allInterceptors { + interceptor.application?(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) + } + } + + public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { + for interceptor in allInterceptors { + interceptor.application?(application, didFailToRegisterForRemoteNotificationsWithError: error) + } + } + public func application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { for interceptor in allInterceptors { // TODO: Make sure completionHandler is called once. From a23952fe6910712bbe947c43897ce1e773fbc69b Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Fri, 16 Jul 2021 11:28:01 -0400 Subject: [PATCH 13/17] Bump version to 7.5.0 --- GoogleMulticastAppDelegate.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GoogleMulticastAppDelegate.podspec b/GoogleMulticastAppDelegate.podspec index 17d147a4..24819072 100644 --- a/GoogleMulticastAppDelegate.podspec +++ b/GoogleMulticastAppDelegate.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| # TODO: Is `GoogleMulticastAppDelegate` name fine? s.name = 'GoogleMulticastAppDelegate' - s.version = '7.2.2' + s.version = '7.5.0' s.summary = 'GoogleMulticastAppDelegate' s.description = <<-DESC From 7de3a2b82e7026f6dacbd8c992b97c00abe7e979 Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Fri, 16 Jul 2021 12:03:06 -0400 Subject: [PATCH 14/17] Cleanup --- .../Sources/MulticastAppDelegate.swift | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift index 654013da..7681fde3 100644 --- a/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift +++ b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift @@ -85,16 +85,7 @@ extension MulticastAppDelegate { extension MulticastAppDelegate: MulticastAppDelegateProtocol.Delegate { - public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - var result = false - - for interceptor in allInterceptors { - result = result || interceptor.application?(application, didFinishLaunchingWithOptions: launchOptions) ?? false - } - - return result - } - + // MARK: - Open URL public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { var result = false @@ -105,6 +96,7 @@ extension MulticastAppDelegate: MulticastAppDelegateProtocol.Delegate { return result } + // MARK: - APNS methods public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { for interceptor in allInterceptors { interceptor.application?(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) From b05faa9af0a33c00a654af9324bf9113b9be10db Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Fri, 16 Jul 2021 12:13:30 -0400 Subject: [PATCH 15/17] SPM definition --- Package.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Package.swift b/Package.swift index 3316c85f..2e117251 100644 --- a/Package.swift +++ b/Package.swift @@ -61,6 +61,10 @@ let package = Package( name: "GULUserDefaults", targets: ["GoogleUtilities_UserDefaults"] ), + .library( + name: "GULMulticastAppDelegate", + targets: ["GoogleUtilities_MulticastAppDelegate"] + ), ], dependencies: [ .package(name: "Promises", url: "https://github.com/google/promises.git", "1.2.8" ..< "3.0.0"), @@ -189,6 +193,14 @@ let package = Package( .headerSearchPath("../../"), ] ), + + // MARK: - Multicast App Delegate targets + .target( + name: "GoogleUtilities_MulticastAppDelegate", + path: "GoogleMulticastAppDelegate/Sources" + ), + + // MARK: - Tests .testTarget( name: "swift-test", dependencies: [ From 395df6c0815e3bc7bbc911040c8a7a1596bc2b35 Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Tue, 20 Jul 2021 11:36:29 -0400 Subject: [PATCH 16/17] Fix MulticastAppDelegate for SwiftUI @UIApplicationDelegateAdaptor. Style. --- .../Sources/MulticastAppDelegate.swift | 60 +++++++++++++++---- 1 file changed, 47 insertions(+), 13 deletions(-) diff --git a/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift index 7681fde3..d5e5c9fd 100644 --- a/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift +++ b/GoogleMulticastAppDelegate/Sources/MulticastAppDelegate.swift @@ -39,7 +39,7 @@ open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol { return allInterceptors } - public override init() { + override public init() { super.init() } @@ -59,7 +59,7 @@ open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol { } // Forward all unknown messages to the original app delegate. - public override func responds(to aSelector: Selector!) -> Bool { + override public func responds(to aSelector: Selector!) -> Bool { if type(of: self).instancesRespond(to: aSelector) { return true } @@ -67,26 +67,46 @@ open class MulticastAppDelegate: NSObject, MulticastAppDelegateProtocol { return appDelegate?.responds(to: aSelector) ?? false } - open override func forwardingTarget(for aSelector: Selector) -> Any? { + override open func forwardingTarget(for aSelector: Selector) -> Any? { return appDelegate } } +// MARK: - Multicast App Delegate detection + extension MulticastAppDelegate { + /// Returns an instance of app delegate if it conforms to `MulticastAppDelegateProtocol` @objc public class func installedMulticastDelegate() -> MulticastAppDelegateProtocol? { - guard let multicastDelegate = Application.shared.delegate as? MulticastAppDelegateProtocol else { + guard let appDelegate = Application.shared.delegate else { return nil } - return multicastDelegate + if let multicastDelegate = appDelegate as? MulticastAppDelegateProtocol { + return multicastDelegate + } + + // SwiftUI `UIApplicationDelegateAdaptor` doesn't allow easily check if the actual app delegate confirms to a protocol. But any method call is eventually forwarded to the original app delegate instance, so it can be used as a type-safe workaround. + if appDelegate.responds(to: #selector(gulMulticastDelegate)) { + return appDelegate.perform(#selector(gulMulticastDelegate)) + .takeRetainedValue() as? MulticastAppDelegateProtocol + } + + return nil + } + + /// The method is used to test if calls to `Application.shared.delegate` are forwarded to a `MulticastAppDelegate` subclass. + @objc + public func gulMulticastDelegate() -> MulticastAppDelegateProtocol { + return self } } extension MulticastAppDelegate: MulticastAppDelegateProtocol.Delegate { - // MARK: - Open URL - public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + + public func application(_ app: UIApplication, open url: URL, + options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { var result = false for interceptor in allInterceptors { @@ -97,23 +117,37 @@ extension MulticastAppDelegate: MulticastAppDelegateProtocol.Delegate { } // MARK: - APNS methods - public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { + + public func application(_ application: UIApplication, + didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { for interceptor in allInterceptors { - interceptor.application?(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) + interceptor.application?( + application, + didRegisterForRemoteNotificationsWithDeviceToken: deviceToken + ) } } - public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { + public func application(_ application: UIApplication, + didFailToRegisterForRemoteNotificationsWithError error: Error) { for interceptor in allInterceptors { interceptor.application?(application, didFailToRegisterForRemoteNotificationsWithError: error) } } - public func application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { + public func application(_ application: UIApplication, + didReceiveRemoteNotification notification: [AnyHashable: Any], + fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) + -> Void) { for interceptor in allInterceptors { // TODO: Make sure completionHandler is called once. - interceptor.application?(application, didReceiveRemoteNotification: notification, fetchCompletionHandler:completionHandler) + interceptor.application?( + application, + didReceiveRemoteNotification: notification, + fetchCompletionHandler: completionHandler + ) } } - } + +extension MulticastAppDelegate {} From 6fd24d9da5fcc45e4bc22844b894288de608385e Mon Sep 17 00:00:00 2001 From: Maksym Malyhin Date: Wed, 11 Aug 2021 11:41:45 -0400 Subject: [PATCH 17/17] Specify Swift versions --- GoogleMulticastAppDelegate.podspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GoogleMulticastAppDelegate.podspec b/GoogleMulticastAppDelegate.podspec index 24819072..e698a2e5 100644 --- a/GoogleMulticastAppDelegate.podspec +++ b/GoogleMulticastAppDelegate.podspec @@ -27,6 +27,8 @@ Pod::Spec.new do |s| # s.tvos.deployment_target = tvos_deployment_target # s.watchos.deployment_target = watchos_deployment_target + s.swift_versions = ['5.0', '5.2'] + s.cocoapods_version = '>= 1.4.0' s.prefix_header_file = false