From 46a55ee2351b82a577e41824a2279c5601b08066 Mon Sep 17 00:00:00 2001
From: sgr-ksmt <suguru-kishimoto@cookpad.com>
Date: Wed, 3 Jul 2019 17:20:17 +0900
Subject: [PATCH] upgrade to firebase v6.3.

---
 Demo/Demo.xcodeproj/project.pbxproj           |   2 -
 Demo/Podfile.lock                             | 108 ++++++------------
 Lobster.podspec                               |   4 +-
 Lobster.xcodeproj/project.pbxproj             |   1 +
 .../xcshareddata/xcschemes/Lobster.xcscheme   |   2 +-
 Podfile                                       |   2 +-
 Podfile.lock                                  | 107 ++++++-----------
 README.md                                     |   4 +-
 Sources/Lobster.swift                         |  20 ++--
 9 files changed, 87 insertions(+), 163 deletions(-)

diff --git a/Demo/Demo.xcodeproj/project.pbxproj b/Demo/Demo.xcodeproj/project.pbxproj
index a9b8493..5529af9 100644
--- a/Demo/Demo.xcodeproj/project.pbxproj
+++ b/Demo/Demo.xcodeproj/project.pbxproj
@@ -197,13 +197,11 @@
 				"${PODS_ROOT}/Target Support Files/Pods-Demo/Pods-Demo-frameworks.sh",
 				"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
 				"${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework",
-				"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
 			);
 			name = "[CP] Embed Pods Frameworks";
 			outputPaths = (
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework",
-				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
diff --git a/Demo/Podfile.lock b/Demo/Podfile.lock
index d7b4f88..b72ec65 100644
--- a/Demo/Podfile.lock
+++ b/Demo/Podfile.lock
@@ -1,67 +1,35 @@
 PODS:
-  - Firebase/Core (5.8.0):
+  - Firebase/CoreOnly (6.3.0):
+    - FirebaseCore (= 6.0.3)
+  - Firebase/RemoteConfig (6.3.0):
     - Firebase/CoreOnly
-    - FirebaseAnalytics (= 5.1.2)
-  - Firebase/CoreOnly (5.8.0):
-    - FirebaseCore (= 5.1.3)
-  - Firebase/RemoteConfig (5.8.0):
-    - Firebase/Core
-    - FirebaseRemoteConfig (= 3.0.1)
-  - FirebaseABTesting (2.0.0):
-    - FirebaseCore (~> 5.0)
+    - FirebaseRemoteConfig (~> 4.1.0)
+  - FirebaseABTesting (3.0.0):
+    - FirebaseCore (~> 6.0)
     - Protobuf (~> 3.5)
-  - FirebaseAnalytics (5.1.2):
-    - FirebaseCore (~> 5.1)
-    - FirebaseInstanceID (~> 3.2)
-    - GoogleAppMeasurement (~> 5.1)
-    - GoogleUtilities/AppDelegateSwizzler (~> 5.2.0)
-    - GoogleUtilities/MethodSwizzler (~> 5.2.0)
-    - GoogleUtilities/Network (~> 5.2)
-    - "GoogleUtilities/NSData+zlib (~> 5.2)"
-    - nanopb (~> 0.3)
-  - FirebaseCore (5.1.3):
-    - GoogleUtilities/Logger (~> 5.2)
-  - FirebaseInstanceID (3.2.1):
-    - FirebaseCore (~> 5.1)
-    - GoogleUtilities/Environment (~> 5.2)
-  - FirebaseRemoteConfig (3.0.1):
-    - FirebaseABTesting (~> 2.0)
-    - FirebaseAnalytics (~> 5.1)
-    - FirebaseCore (~> 5.1)
-    - FirebaseInstanceID (~> 3.2)
-    - GoogleUtilities/Environment (~> 5.2)
-    - "GoogleUtilities/NSData+zlib (~> 5.2)"
+  - FirebaseCore (6.0.3):
+    - GoogleUtilities/Environment (~> 6.0)
+    - GoogleUtilities/Logger (~> 6.0)
+  - FirebaseInstanceID (4.2.0):
+    - FirebaseCore (~> 6.0)
+    - GoogleUtilities/Environment (~> 6.0)
+    - GoogleUtilities/UserDefaults (~> 6.0)
+  - FirebaseRemoteConfig (4.1.0):
+    - FirebaseABTesting (~> 3.0)
+    - FirebaseCore (~> 6.0)
+    - FirebaseInstanceID (~> 4.2)
+    - GoogleUtilities/Environment (~> 6.0)
+    - "GoogleUtilities/NSData+zlib (~> 6.0)"
     - Protobuf (~> 3.5)
-  - GoogleAppMeasurement (5.1.2):
-    - GoogleUtilities/AppDelegateSwizzler (~> 5.2.0)
-    - GoogleUtilities/MethodSwizzler (~> 5.2.0)
-    - GoogleUtilities/Network (~> 5.2)
-    - "GoogleUtilities/NSData+zlib (~> 5.2)"
-    - nanopb (~> 0.3)
-  - GoogleUtilities/AppDelegateSwizzler (5.2.3):
+  - GoogleUtilities/Environment (6.2.1)
+  - GoogleUtilities/Logger (6.2.1):
     - GoogleUtilities/Environment
+  - "GoogleUtilities/NSData+zlib (6.2.1)"
+  - GoogleUtilities/UserDefaults (6.2.1):
     - GoogleUtilities/Logger
-    - GoogleUtilities/Network
-  - GoogleUtilities/Environment (5.2.3)
-  - GoogleUtilities/Logger (5.2.3):
-    - GoogleUtilities/Environment
-  - GoogleUtilities/MethodSwizzler (5.2.3):
-    - GoogleUtilities/Logger
-  - GoogleUtilities/Network (5.2.3):
-    - GoogleUtilities/Logger
-    - "GoogleUtilities/NSData+zlib"
-    - GoogleUtilities/Reachability
-  - "GoogleUtilities/NSData+zlib (5.2.3)"
-  - GoogleUtilities/Reachability (5.2.3):
-    - GoogleUtilities/Logger
-  - Lobster (2.0):
-    - Firebase/RemoteConfig (~> 5.0)
-  - nanopb (0.3.8):
-    - nanopb/decode (= 0.3.8)
-    - nanopb/encode (= 0.3.8)
-  - nanopb/decode (0.3.8)
-  - nanopb/encode (0.3.8)
-  - Protobuf (3.6.1)
+  - Lobster (2.2):
+    - Firebase/RemoteConfig (~> 6.0)
+  - Protobuf (3.8.0)
 
 DEPENDENCIES:
   - Lobster (from `../`)
@@ -70,13 +38,10 @@ SPEC REPOS:
   https://github.com/cocoapods/specs.git:
     - Firebase
     - FirebaseABTesting
-    - FirebaseAnalytics
     - FirebaseCore
     - FirebaseInstanceID
     - FirebaseRemoteConfig
-    - GoogleAppMeasurement
     - GoogleUtilities
-    - nanopb
     - Protobuf
 
 EXTERNAL SOURCES:
@@ -84,18 +49,15 @@ EXTERNAL SOURCES:
     :path: "../"
 
 SPEC CHECKSUMS:
-  Firebase: 25812f43e7a53b11ae2f0a5f4c6d12faeb1f7cd7
-  FirebaseABTesting: 1f50b8d50f5e3469eea54e7463a7b7fe221d1f5e
-  FirebaseAnalytics: df15839e9c6ca6bd14d2e8ab6b0c672e6c49097e
-  FirebaseCore: 27bd80e5bfaaf9552a1f5cacb4c7e8bb925bab22
-  FirebaseInstanceID: ea5af6920d0a4a29b40459d055bebe4a6c1333c4
-  FirebaseRemoteConfig: 7b6d675dfb11f0e0e638caee00908b06af150d56
-  GoogleAppMeasurement: fc4a4c3fe0144db9313cbf443ffe62e6b1d6268c
-  GoogleUtilities: 6f681e27050c5e130325e89fa0316dfca826f954
-  Lobster: fd1c1322233a5de3a9c2aa33124e65d37e04d657
-  nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
-  Protobuf: 1eb9700044745f00181c136ef21b8ff3ad5a0fd5
+  Firebase: 8432d732974498afd5987e9001a05f90f1a3d625
+  FirebaseABTesting: a32c488eb75089a61eb3d86db061dfb909d765db
+  FirebaseCore: 68f8a7f50cdae542715d4e86afa37c4067217dcb
+  FirebaseInstanceID: f20243a1d828e0e9a3798b995174dedc16f1b32a
+  FirebaseRemoteConfig: 7c64ecec5ca63d7c6b304509c3a6f9a036d403d4
+  GoogleUtilities: c7a0b08bda3bf808be823ed151f0e28ac6866e71
+  Lobster: b7c48cf6ff48e80f269715ce80cdc3e087c7b501
+  Protobuf: 3f617b9a6e73605565086864c9bc26b2bf2dd5a3
 
 PODFILE CHECKSUM: c6efd56fba58da5968399c93e6f38bb7f1692d81
 
-COCOAPODS: 1.6.1
+COCOAPODS: 1.7.2
diff --git a/Lobster.podspec b/Lobster.podspec
index 4bc9ced..361a2ff 100644
--- a/Lobster.podspec
+++ b/Lobster.podspec
@@ -1,6 +1,6 @@
 Pod::Spec.new do |s|
   s.name             = "Lobster"
-  s.version          = "2.1"
+  s.version          = "2.2"
   s.summary          = "Type-safe Firebase-RemoteConfig helper library"
   s.homepage         = "https://github.com/sgr-ksmt/Lobster"
   s.license          = 'MIT'
@@ -11,5 +11,5 @@ Pod::Spec.new do |s|
   s.source_files     = "Sources/**/*"
   s.static_framework = true
   s.swift_version    = '5.0'
-  s.dependency "Firebase/RemoteConfig", "~> 5.0"
+  s.dependency "Firebase/RemoteConfig", "~> 6.0"
 end
diff --git a/Lobster.xcodeproj/project.pbxproj b/Lobster.xcodeproj/project.pbxproj
index 3b25742..3ef53d7 100644
--- a/Lobster.xcodeproj/project.pbxproj
+++ b/Lobster.xcodeproj/project.pbxproj
@@ -253,6 +253,7 @@
 			hasScannedForEncodings = 0;
 			knownRegions = (
 				en,
+				Base,
 			);
 			mainGroup = 163143F51FA8BE8600D25996;
 			productRefGroup = 163144001FA8BE8600D25996 /* Products */;
diff --git a/Lobster.xcodeproj/xcshareddata/xcschemes/Lobster.xcscheme b/Lobster.xcodeproj/xcshareddata/xcschemes/Lobster.xcscheme
index 3bed53a..9b2aa0a 100644
--- a/Lobster.xcodeproj/xcshareddata/xcschemes/Lobster.xcscheme
+++ b/Lobster.xcodeproj/xcshareddata/xcschemes/Lobster.xcscheme
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "0930"
+   LastUpgradeVersion = "1020"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "YES"
diff --git a/Podfile b/Podfile
index a776d83..a744b6e 100644
--- a/Podfile
+++ b/Podfile
@@ -4,7 +4,7 @@ inhibit_all_warnings!
 use_frameworks!
 
 target 'Lobster' do
-  pod 'Firebase/RemoteConfig', '~> 5.0'
+  pod 'Firebase/RemoteConfig', '~> 6.0'
   target 'LobsterTests' do
     inherit! :search_paths
   end
diff --git a/Podfile.lock b/Podfile.lock
index 0410766..01ac7b6 100644
--- a/Podfile.lock
+++ b/Podfile.lock
@@ -1,97 +1,56 @@
 PODS:
-  - Firebase/Core (5.18.0):
+  - Firebase/CoreOnly (6.3.0):
+    - FirebaseCore (= 6.0.3)
+  - Firebase/RemoteConfig (6.3.0):
     - Firebase/CoreOnly
-    - FirebaseAnalytics (= 5.7.0)
-  - Firebase/CoreOnly (5.18.0):
-    - FirebaseCore (= 5.3.1)
-  - Firebase/RemoteConfig (5.18.0):
-    - Firebase/Core
-    - FirebaseRemoteConfig (= 3.1.0)
-  - FirebaseABTesting (2.0.0):
-    - FirebaseCore (~> 5.0)
+    - FirebaseRemoteConfig (~> 4.1.0)
+  - FirebaseABTesting (3.0.0):
+    - FirebaseCore (~> 6.0)
     - Protobuf (~> 3.5)
-  - FirebaseAnalytics (5.7.0):
-    - FirebaseCore (~> 5.3)
-    - FirebaseInstanceID (~> 3.6)
-    - GoogleAppMeasurement (= 5.7.0)
-    - GoogleUtilities/AppDelegateSwizzler (~> 5.2)
-    - GoogleUtilities/MethodSwizzler (~> 5.2)
-    - GoogleUtilities/Network (~> 5.2)
-    - "GoogleUtilities/NSData+zlib (~> 5.2)"
-    - nanopb (~> 0.3)
-  - FirebaseCore (5.3.1):
-    - GoogleUtilities/Logger (~> 5.2)
-  - FirebaseInstanceID (3.7.0):
-    - FirebaseCore (~> 5.2)
-    - GoogleUtilities/Environment (~> 5.2)
-    - GoogleUtilities/UserDefaults (~> 5.2)
-  - FirebaseRemoteConfig (3.1.0):
-    - FirebaseABTesting (~> 2.0)
-    - FirebaseAnalytics (~> 5.3)
-    - FirebaseCore (~> 5.1)
-    - FirebaseInstanceID (~> 3.3)
-    - GoogleUtilities/Environment (~> 5.2)
-    - "GoogleUtilities/NSData+zlib (~> 5.2)"
+  - FirebaseCore (6.0.3):
+    - GoogleUtilities/Environment (~> 6.0)
+    - GoogleUtilities/Logger (~> 6.0)
+  - FirebaseInstanceID (4.2.0):
+    - FirebaseCore (~> 6.0)
+    - GoogleUtilities/Environment (~> 6.0)
+    - GoogleUtilities/UserDefaults (~> 6.0)
+  - FirebaseRemoteConfig (4.1.0):
+    - FirebaseABTesting (~> 3.0)
+    - FirebaseCore (~> 6.0)
+    - FirebaseInstanceID (~> 4.2)
+    - GoogleUtilities/Environment (~> 6.0)
+    - "GoogleUtilities/NSData+zlib (~> 6.0)"
     - Protobuf (~> 3.5)
-  - GoogleAppMeasurement (5.7.0):
-    - GoogleUtilities/AppDelegateSwizzler (~> 5.2)
-    - GoogleUtilities/MethodSwizzler (~> 5.2)
-    - GoogleUtilities/Network (~> 5.2)
-    - "GoogleUtilities/NSData+zlib (~> 5.2)"
-    - nanopb (~> 0.3)
-  - GoogleUtilities/AppDelegateSwizzler (5.5.0):
+  - GoogleUtilities/Environment (6.2.1)
+  - GoogleUtilities/Logger (6.2.1):
     - GoogleUtilities/Environment
+  - "GoogleUtilities/NSData+zlib (6.2.1)"
+  - GoogleUtilities/UserDefaults (6.2.1):
     - GoogleUtilities/Logger
-    - GoogleUtilities/Network
-  - GoogleUtilities/Environment (5.5.0)
-  - GoogleUtilities/Logger (5.5.0):
-    - GoogleUtilities/Environment
-  - GoogleUtilities/MethodSwizzler (5.5.0):
-    - GoogleUtilities/Logger
-  - GoogleUtilities/Network (5.5.0):
-    - GoogleUtilities/Logger
-    - "GoogleUtilities/NSData+zlib"
-    - GoogleUtilities/Reachability
-  - "GoogleUtilities/NSData+zlib (5.5.0)"
-  - GoogleUtilities/Reachability (5.5.0):
-    - GoogleUtilities/Logger
-  - GoogleUtilities/UserDefaults (5.5.0):
-    - GoogleUtilities/Logger
-  - nanopb (0.3.901):
-    - nanopb/decode (= 0.3.901)
-    - nanopb/encode (= 0.3.901)
-  - nanopb/decode (0.3.901)
-  - nanopb/encode (0.3.901)
-  - Protobuf (3.7.0)
+  - Protobuf (3.8.0)
 
 DEPENDENCIES:
-  - Firebase/RemoteConfig (~> 5.0)
+  - Firebase/RemoteConfig (~> 6.0)
 
 SPEC REPOS:
   https://github.com/cocoapods/specs.git:
     - Firebase
     - FirebaseABTesting
-    - FirebaseAnalytics
     - FirebaseCore
     - FirebaseInstanceID
     - FirebaseRemoteConfig
-    - GoogleAppMeasurement
     - GoogleUtilities
-    - nanopb
     - Protobuf
 
 SPEC CHECKSUMS:
-  Firebase: 02f3281965c075426141a0ce1277e9de6649cab9
-  FirebaseABTesting: 1f50b8d50f5e3469eea54e7463a7b7fe221d1f5e
-  FirebaseAnalytics: 23851fe602c872130a2c5c55040b302120346cc2
-  FirebaseCore: 52f851b30e11360f1e67cf04b1edfebf0a47a2d3
-  FirebaseInstanceID: bd6fc5a258884e206fd5c474ebe4f5b00e21770e
-  FirebaseRemoteConfig: 7e11c65f0769c09bff6947997c209515058c5318
-  GoogleAppMeasurement: 6cf307834da065863f9faf4c0de0a936d81dd832
-  GoogleUtilities: 6481e6318c5fcabaaa8513ef8120f329055d7c10
-  nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
-  Protobuf: 7a877b7f3e5964e3fce995e2eb323dbc6831bb5a
+  Firebase: 8432d732974498afd5987e9001a05f90f1a3d625
+  FirebaseABTesting: a32c488eb75089a61eb3d86db061dfb909d765db
+  FirebaseCore: 68f8a7f50cdae542715d4e86afa37c4067217dcb
+  FirebaseInstanceID: f20243a1d828e0e9a3798b995174dedc16f1b32a
+  FirebaseRemoteConfig: 7c64ecec5ca63d7c6b304509c3a6f9a036d403d4
+  GoogleUtilities: c7a0b08bda3bf808be823ed151f0e28ac6866e71
+  Protobuf: 3f617b9a6e73605565086864c9bc26b2bf2dd5a3
 
-PODFILE CHECKSUM: 6434246e86875f87cb87a53d5f214d06ff00ef26
+PODFILE CHECKSUM: 36c0843f8e15305700f7260d1eadafe9175ca89d
 
 COCOAPODS: 1.6.1
diff --git a/README.md b/README.md
index 7718c25..c89c753 100644
--- a/README.md
+++ b/README.md
@@ -294,7 +294,7 @@ $ open Demo.xcworkspace
 ## Requirements
 - iOS 11.0+
 - Xcode 10+
-- Swift 4.2
+- Swift 5.0
 
 ## Installation
 ### CocoaPods
@@ -302,7 +302,7 @@ $ open Demo.xcworkspace
 it, simply add the following line to your Podfile:
 
 ```ruby
-pod 'Lobster', '~> 2.1'
+pod 'Lobster', '~> 2.2'
 ```
 
 and run `pod install`
diff --git a/Sources/Lobster.swift b/Sources/Lobster.swift
index fc37ed8..8a19b31 100644
--- a/Sources/Lobster.swift
+++ b/Sources/Lobster.swift
@@ -17,8 +17,11 @@ public class Lobster {
     /// Returns FIRRemoteConfig instance.
     public let remoteConfig = RemoteConfig.remoteConfig()
 
+    /// Default expiration duration. (12 hours)
+    public static let defaultExpirationDuration: TimeInterval = 43_200.0
+
     /// Expiration duration for cache. Default duration is 12 hours
-    public var fetchExpirationDuration: TimeInterval = 43_200.0
+    public var fetchExpirationDuration: TimeInterval = Lobster.defaultExpirationDuration
 
     /// The flag whether to do stale check. Default is `true`.
     public var useStaleChecker: Bool = true
@@ -41,7 +44,7 @@ public class Lobster {
     /// NOTE: It must be false on production.
     public var debugMode: Bool = false {
         didSet {
-            remoteConfig.configSettings = RemoteConfigSettings(developerModeEnabled: debugMode)
+            remoteConfig.configSettings.minimumFetchInterval = debugMode ? 0 : Lobster.defaultExpirationDuration
         }
     }
     public private(set) var fetchStatus: RemoteConfigFetchStatus = .noFetchYet
@@ -57,13 +60,14 @@ public class Lobster {
     public func fetch(completion: @escaping (Error?) -> Void = { _ in }) {
         let duration = getExpirationDuration()
         remoteConfig.fetch(withExpirationDuration: duration) { [unowned self] (status, error) in
-            if error == nil {
-                RemoteConfig.remoteConfig().activateFetched()
+            var fetchError: Error? = error
+            RemoteConfig.remoteConfig().activate { (error) in
+                fetchError = error ?? fetchError
+                self.fetchStatus = status
+                self.isStaled = false
+                completion(fetchError)
+                NotificationCenter.default.post(name: Lobster.didFetchConfig, object: error)
             }
-            self.fetchStatus = status
-            self.isStaled = false
-            completion(error)
-            NotificationCenter.default.post(name: Lobster.didFetchConfig, object: error)
         }
     }