Skip to content

Commit

Permalink
Fix client factory
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Oct 18, 2022
1 parent 2d3b9d3 commit c7d6ab7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ConfigCat.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = "ConfigCat"
spec.version = "9.1.1"
spec.version = "9.1.2"
spec.summary = "ConfigCat Swift SDK"
spec.swift_version = "4.2"

Expand Down
2 changes: 1 addition & 1 deletion ConfigCat.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator watchos watchsimulator app
SWIFT_VERSION = 4.2

// ConfigCat SDK version
MARKETING_VERSION = 9.1.1
MARKETING_VERSION = 9.1.2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ If you want to use ConfigCat in a [SwiftPM](https://swift.org/package-manager/)

``` swift
dependencies: [
.package(url: "https://github.com/configcat/swift-sdk", from: "9.1.1")
.package(url: "https://github.com/configcat/swift-sdk", from: "9.1.2")
]
```

Expand Down
10 changes: 6 additions & 4 deletions Sources/ConfigCat/ConfigCatClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ public final class ConfigCatClient: NSObject, ConfigCatClientProtocol {
defer {
mutex.unlock()
}
if let client = instances[sdkKey]?.get(), options != nil {
client.log.warning(message: String(format: """
Client for '%@' is already created and will be reused; options passed are being ignored.
""", sdkKey))
if let client = instances[sdkKey]?.get() {
if options != nil {
client.log.warning(message: String(format: """
Client for '%@' is already created and will be reused; options passed are being ignored.
""", sdkKey))
}
return client
}
let opts = options ?? ClientOptions.default
Expand Down
2 changes: 1 addition & 1 deletion Sources/ConfigCat/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension Date {
}

class Constants {
static let version: String = "9.1.1"
static let version: String = "9.1.2"
static let configJsonName: String = "config_v5"
static let globalBaseUrl: String = "https://cdn-global.configcat.com"
static let euOnlyBaseUrl: String = "https://cdn-eu.configcat.com"
Expand Down
12 changes: 12 additions & 0 deletions Tests/ConfigCatTests/ConfigCatClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,18 @@ class ConfigCatClientTests: XCTestCase {
}
}

func testSingleton() {
var client1 = ConfigCatClient.get(sdkKey: "test")
let client2 = ConfigCatClient.get(sdkKey: "test")

XCTAssertEqual(client1, client2)

ConfigCatClient.closeAll()
client1 = ConfigCatClient.get(sdkKey: "test")

XCTAssertNotEqual(client1, client2)
}

private func createClient(offline: Bool = false) -> ConfigCatClient {
ConfigCatClient(sdkKey: "test", refreshMode: PollingModes.manualPoll(), session: MockHTTP.session(), offline: offline)
}
Expand Down

0 comments on commit c7d6ab7

Please sign in to comment.