Quellcode durchsuchen

[v11] RC stringValue is now nonull (#13065)

Paul Beusterien vor 1 Jahr
Ursprung
Commit
059b921122

+ 4 - 1
FirebaseRemoteConfig/CHANGELOG.md

@@ -1,4 +1,7 @@
-# 10.25.0
+# 11.0.0
+- [fixed] RemoteConfigValue stringValue is now `nonnull`. This may break some builds. (#10870)
+
+  # 10.25.0
 - [fixed] Fixed bug preventing Remote Config from working with a custom sqlite3
   dependency (#10884).
 

+ 2 - 2
FirebaseRemoteConfig/Sources/FIRConfigValue.m

@@ -41,8 +41,8 @@
 }
 
 /// The string is a UTF-8 representation of NSData.
-- (NSString *)stringValue {
-  return [[NSString alloc] initWithData:_data encoding:NSUTF8StringEncoding];
+- (nonnull NSString *)stringValue {
+  return [[NSString alloc] initWithData:_data encoding:NSUTF8StringEncoding] ?: @"";
 }
 
 /// Number representation of a UTF-8 string.

+ 1 - 1
FirebaseRemoteConfig/Sources/Public/FirebaseRemoteConfig/FIRRemoteConfig.h

@@ -138,7 +138,7 @@ typedef void (^FIRRemoteConfigFetchAndActivateCompletion)(
 NS_SWIFT_NAME(RemoteConfigValue)
 @interface FIRRemoteConfigValue : NSObject <NSCopying>
 /// Gets the value as a string.
-@property(nonatomic, readonly, nullable) NSString *stringValue;
+@property(nonatomic, readonly, nonnull) NSString *stringValue;
 /// Gets the value as a number value.
 @property(nonatomic, readonly, nonnull) NSNumber *numberValue;
 /// Gets the value as a NSData object.

+ 1 - 1
FirebaseRemoteConfig/Swift/FirebaseRemoteConfigValueDecoderHelper.swift

@@ -35,7 +35,7 @@ struct FirebaseRemoteConfigValueDecoderHelper: FirebaseRemoteConfigValueDecoding
   }
 
   func stringValue() -> String {
-    return value.stringValue ?? ""
+    return value.stringValue
   }
 
   func dataValue() -> Data {

+ 7 - 26
FirebaseRemoteConfigSwift/Tests/SwiftAPI/APITests.swift

@@ -188,12 +188,7 @@ class APITests: APITestBase {
 
     config.fetchAndActivate { status, error in
       XCTAssertNil(error, "Fetch & Activate Error \(error!)")
-
-      if let configValue = self.config.configValue(forKey: Constants.jedi).stringValue {
-        XCTAssertEqual(configValue, Constants.obiwan)
-      } else {
-        XCTFail("Could not unwrap config value for key: \(Constants.jedi)")
-      }
+      XCTAssertEqual(self.config.configValue(forKey: Constants.jedi).stringValue, Constants.obiwan)
       expectation.fulfill()
     }
     waitForExpectations()
@@ -204,13 +199,7 @@ class APITests: APITestBase {
     let expectation2 = self.expectation(description: #function + "2")
     config.fetchAndActivate { status, error in
       XCTAssertNil(error, "Fetch & Activate Error \(error!)")
-
-      if let configValue = self.config.configValue(forKey: Constants.jedi).stringValue {
-        XCTAssertEqual(configValue, Constants.yoda)
-      } else {
-        XCTFail("Could not unwrap config value for key: \(Constants.jedi)")
-      }
-
+      XCTAssertEqual(self.config.configValue(forKey: Constants.jedi).stringValue, Constants.yoda)
       expectation2.fulfill()
     }
     waitForExpectations()
@@ -239,13 +228,10 @@ class APITests: APITestBase {
 
     config.fetchAndActivate { status, error in
       XCTAssertNil(error, "Fetch & Activate Error \(error!)")
-
-      if let configValue = self.config.configValue(forKey: Constants.sith).stringValue {
-        XCTAssertEqual(configValue, Constants.darthSidious)
-      } else {
-        XCTFail("Could not unwrap config value for key: \(Constants.sith)")
-      }
-
+      XCTAssertEqual(
+        self.config.configValue(forKey: Constants.sith).stringValue,
+        Constants.darthSidious
+      )
       expectation2.fulfill()
     }
     waitForExpectations()
@@ -258,12 +244,7 @@ class APITests: APITestBase {
 
     config.fetchAndActivate { status, error in
       XCTAssertNil(error, "Fetch & Activate Error \(error!)")
-
-      if let configValue = self.config.configValue(forKey: Constants.jedi).stringValue {
-        XCTAssertEqual(configValue, Constants.obiwan)
-      } else {
-        XCTFail("Could not unwrap config value for key: \(Constants.jedi)")
-      }
+      XCTAssertEqual(self.config.configValue(forKey: Constants.jedi).stringValue, Constants.obiwan)
       expectation.fulfill()
     }
     waitForExpectations()