Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Sources/SuperwallKit/Superwall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,27 @@ public final class Superwall: NSObject, ObservableObject {
super.init()
}

static func makeDependencyContainer(
apiKey: String,
purchaseController: PurchaseController? = nil,
options: SuperwallOptions? = nil
) -> DependencyContainer {
let dependencyContainer = DependencyContainer(
purchaseController: purchaseController,
options: options
)
dependencyContainer.storage.configure(apiKey: apiKey)
return dependencyContainer
}

private convenience init(
apiKey: String,
purchaseController: PurchaseController? = nil,
options: SuperwallOptions? = nil,
completion: (() -> Void)?
) {
let dependencyContainer = DependencyContainer(
let dependencyContainer = Self.makeDependencyContainer(
apiKey: apiKey,
purchaseController: purchaseController,
options: options
)
Expand All @@ -407,8 +421,6 @@ public final class Superwall: NSObject, ObservableObject {
#endif
}

dependencyContainer.storage.configure(apiKey: apiKey)

dependencyContainer.storage.recordAppInstall(trackPlacement: track)

async let fetchConfig: () = await dependencyContainer.configManager.fetchConfiguration()
Expand Down
7 changes: 6 additions & 1 deletion Tests/SuperwallKitTests/Storage/StorageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import XCTest
@testable import SuperwallKit

class StorageTests: XCTestCase {
func test_makeDependencyContainer_configuresApiKeySynchronously() {
let dependencyContainer = Superwall.makeDependencyContainer(apiKey: "pk_test_123")

XCTAssertEqual(dependencyContainer.storage.apiKey, "pk_test_123")
}
Comment on lines 12 to +17
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 New test uses XCTest instead of Swift Testing

CLAUDE.md explicitly requires: "This project uses Swift's Testing framework (not XCTest) for all unit tests. Always use the Testing framework when writing new tests."

The new test was added to the existing XCTestCase subclass rather than creating a new Swift Testing file. It should live in its own file using import Testing with @Test and #expect.

Context Used: CLAUDE.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: Tests/SuperwallKitTests/Storage/StorageTests.swift
Line: 12-17

Comment:
**New test uses XCTest instead of Swift Testing**

`CLAUDE.md` explicitly requires: *"This project uses Swift's Testing framework (not XCTest) for all unit tests. Always use the Testing framework when writing new tests."*

The new test was added to the existing `XCTestCase` subclass rather than creating a new Swift Testing file. It should live in its own file using `import Testing` with `@Test` and `#expect`.

**Context Used:** CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=ae0afcf7-0b55-482b-9764-29f361e46714))

How can I resolve this? If you propose a fix, please make it concise.


func test_overwriteAssignments() {
let dependencyContainer = DependencyContainer()
let storage = Storage(factory: dependencyContainer)
Expand All @@ -36,4 +42,3 @@ class StorageTests: XCTestCase {
XCTAssertTrue(retrievedAssignments2.isEmpty)
}
}

Loading