Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit e7f8587

Browse files
committed
chore: only include version check when SWIFT_PACKAGE
1 parent 2a3787f commit e7f8587

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Sources/OpenIapVersion.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,45 @@ public struct OpenIapVersion {
2323
}()
2424

2525
private static func loadVersionFromJSON() -> String? {
26+
#if SWIFT_PACKAGE
2627
guard let url = Bundle.module.url(forResource: "openiap-versions", withExtension: "json"),
2728
let data = try? Data(contentsOf: url),
2829
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
2930
let version = json["apple"] as? String else {
3031
return nil
3132
}
3233
return version
34+
#else
35+
// For CocoaPods or direct integration, use Bundle.main or return nil
36+
guard let url = Bundle.main.url(forResource: "openiap-versions", withExtension: "json"),
37+
let data = try? Data(contentsOf: url),
38+
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
39+
let version = json["apple"] as? String else {
40+
return nil
41+
}
42+
return version
43+
#endif
3344
}
3445

3546
private static func loadGQLVersionFromJSON() -> String? {
47+
#if SWIFT_PACKAGE
3648
guard let url = Bundle.module.url(forResource: "openiap-versions", withExtension: "json"),
3749
let data = try? Data(contentsOf: url),
3850
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
3951
let version = json["gql"] as? String else {
4052
return nil
4153
}
4254
return version
55+
#else
56+
// For CocoaPods or direct integration, use Bundle.main or return nil
57+
guard let url = Bundle.main.url(forResource: "openiap-versions", withExtension: "json"),
58+
let data = try? Data(contentsOf: url),
59+
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
60+
let version = json["gql"] as? String else {
61+
return nil
62+
}
63+
return version
64+
#endif
4365
}
4466
}
4567

0 commit comments

Comments
 (0)