Skip to content
Merged
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
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ jobs:
if: needs.changes.outputs.swift == 'true'
uses: ./.github/workflows/swift-lint.yml

swift-sample-package-paths:
name: Swift Sample Package Paths
needs: changes
if: needs.changes.outputs.swift == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- run: platforms/swift/Scripts/check_sample_package_paths

rn-test:
name: React Native
needs: changes
Expand Down Expand Up @@ -182,6 +191,7 @@ jobs:
- swift-test-package
- swift-build-samples
- swift-lint
- swift-sample-package-paths
- rn-test
- rn-test-android
- rn-test-ios
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "ShopifyCheckoutKit",
platforms: [
.iOS(.v13)
.iOS(.v15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand Down
2 changes: 1 addition & 1 deletion ShopifyCheckoutKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|

s.swift_version = "5.0"

s.ios.deployment_target = "13.0"
s.ios.deployment_target = "15.0"

s.pod_target_xcconfig = {
'OTHER_SWIFT_FLAGS' => '-package-name ShopifyCheckoutKit -DCOCOAPODS'
Expand Down
6 changes: 3 additions & 3 deletions platforms/react-native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ experiences.
## Platform Requirements

- **React Native** - Minimum version `0.77` (v4+) / `0.70` (v3 and earlier)
- **iOS** - Minimum version iOS 13
- **iOS** - Minimum version iOS 15
- **Android** - Minimum Java 11, Android SDK version `24`, and Kotlin `2.0+`

## Version Compatibility
Expand Down Expand Up @@ -133,12 +133,12 @@ buildscript {
### 3. Minimum iOS requirements

Check the `platform :ios` property of your `ios/Podfile` to ensure that the
minimum version number is at least `13`.
minimum version number is at least `15`.

```diff
# ios/Podfile
- platform :ios, min_ios_version_supported
+ platform :ios, 13
+ platform :ios, 15
```

## Basic Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Pod::Spec.new do |s|
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => "13.0" }
s.platforms = { :ios => "15.0" }
s.source = { :git => "https://github.com/Shopify/checkout-kit.git", :tag => "react-native/#{s.version}" }

s.source_files = "ios/*.{h,m,mm,swift}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PackageDescription

let package = Package(
name: "RNShopifyCheckoutKitProtocolRelay",
platforms: [.iOS(.v13), .macOS(.v10_15)],
platforms: [.iOS(.v15), .macOS(.v10_15)],
products: [
.library(name: "RNShopifyCheckoutKitProtocolRelay", targets: ["RNShopifyCheckoutKitProtocolRelay"])
],
Expand Down
2 changes: 1 addition & 1 deletion platforms/react-native/sample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2996,7 +2996,7 @@ SPEC CHECKSUMS:
RNGestureHandler: eeb622199ef1fb3a076243131095df1c797072f0
RNReanimated: 237d420b7bb4378ef1dacc7d7a5c674fddb4b5d2
RNScreens: 3fc29af06302e1f1c18a7829fe57cbc2c0259912
RNShopifyCheckoutKit: e19eba6efb68ed31936d7e7b413a02fdb104a053
RNShopifyCheckoutKit: 8e021434b6a080b78cd6c4123eb7b0c1659d641f
RNVectorIcons: be4d047a76ad307ffe54732208fb0498fcb8477f
ShopifyCheckoutKit: ffd719db529ac48907536d855182d7c57c85659f
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Expand Down
2 changes: 1 addition & 1 deletion platforms/swift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
## Requirements

- Swift Package Manager with Swift tools 5.9+
- iOS 13.0+ for `ShopifyCheckoutKit`
- iOS 15.0+ for `ShopifyCheckoutKit`
- iOS 16.0+ for `ShopifyAcceleratedCheckouts`
- A checkout URL from `cart.checkoutUrl` or a cart permalink

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
mainGroup = 4EBBA75E2A5F0CE200193E19;
packageReferences = (
CB00000012345678 /* XCRemoteSwiftPackageReference "apollo-ios" */,
CB2370002FB21BF100F0D914 /* XCLocalSwiftPackageReference "../../../../../checkout-kit" */,
CB2370002FB21BF100F0D914 /* XCLocalSwiftPackageReference "../../../.." */,
);
productRefGroup = 4EBBA7682A5F0CE200193E19 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -279,7 +279,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -337,7 +337,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -367,7 +367,7 @@
INFOPLIST_KEY_UIStatusBarHidden = NO;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -402,7 +402,7 @@
INFOPLIST_KEY_UIStatusBarHidden = NO;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -443,9 +443,9 @@
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
CB2370002FB21BF100F0D914 /* XCLocalSwiftPackageReference "../../../../../checkout-kit" */ = {
CB2370002FB21BF100F0D914 /* XCLocalSwiftPackageReference "../../../.." */ = {
isa = XCLocalSwiftPackageReference;
relativePath = "../../../../../checkout-kit";
relativePath = ../../../..;
};
/* End XCLocalSwiftPackageReference section */

Expand Down Expand Up @@ -473,17 +473,17 @@
};
CB001E302F3CDA0300286F69 /* ShopifyCheckoutProtocol */ = {
isa = XCSwiftPackageProductDependency;
package = CB2370002FB21BF100F0D914 /* XCLocalSwiftPackageReference "../../../../../checkout-kit" */;
package = CB2370002FB21BF100F0D914 /* XCLocalSwiftPackageReference "../../../.." */;
productName = ShopifyCheckoutProtocol;
};
CB1B10B42E4CDDB0001713F8 /* ShopifyCheckoutKit */ = {
isa = XCSwiftPackageProductDependency;
package = CB2370002FB21BF100F0D914 /* XCLocalSwiftPackageReference "../../../../../checkout-kit" */;
package = CB2370002FB21BF100F0D914 /* XCLocalSwiftPackageReference "../../../.." */;
productName = ShopifyCheckoutKit;
};
CBED2D4E2F3F5D1B00EC866A /* ShopifyAcceleratedCheckouts */ = {
isa = XCSwiftPackageProductDependency;
package = CB2370002FB21BF100F0D914 /* XCLocalSwiftPackageReference "../../../../../checkout-kit" */;
package = CB2370002FB21BF100F0D914 /* XCLocalSwiftPackageReference "../../../.." */;
productName = ShopifyAcceleratedCheckouts;
};
/* End XCSwiftPackageProductDependency section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,61 @@ import Foundation
final class Network: Sendable {
static let shared = Network()

private static var currentLanguageCode: String? {
if #available(iOS 16.0, *) {
return Locale.current.language.languageCode?.identifier
} else {
return Locale.current.languageCode
}
}

private static var currentScriptCode: String? {
if #available(iOS 16.0, *) {
return Locale.current.language.script?.identifier
} else {
return Locale.current.scriptCode
}
}

private static var currentRegionCode: String? {
if #available(iOS 16.0, *) {
return Locale.current.region?.identifier
} else {
return Locale.current.regionCode
}
}

private static func getLanguageCode() -> GraphQLEnum<Storefront.LanguageCode> {
if let languageCode = Locale.current.language.languageCode?.identifier {
let code = languageCode.uppercased()
switch code {
case "ZH":
if let scriptCode = Locale.current.language.script?.identifier {
return GraphQLEnum(scriptCode == "Hans" ? Storefront.LanguageCode.zhCn : Storefront.LanguageCode.zhTw)
}
return GraphQLEnum(Storefront.LanguageCode.zhCn)
case "PT":
if let regionCode = Locale.current.language.region?.identifier {
return GraphQLEnum(regionCode == "BR" ? Storefront.LanguageCode.ptBr : Storefront.LanguageCode.ptPt)
}
return GraphQLEnum(Storefront.LanguageCode.pt)
default:
if let mappedCode = Storefront.LanguageCode(rawValue: code) {
return GraphQLEnum(mappedCode)
}
let baseLanguage = String(code.prefix(2))
if let mappedCode = Storefront.LanguageCode(rawValue: baseLanguage) {
return GraphQLEnum(mappedCode)
}
guard let languageCode = currentLanguageCode?.uppercased() else {
return GraphQLEnum(Storefront.LanguageCode.en)
}

switch languageCode {
case "ZH":
if let scriptCode = currentScriptCode {
return GraphQLEnum(scriptCode == "Hans" ? Storefront.LanguageCode.zhCn : Storefront.LanguageCode.zhTw)
}
return GraphQLEnum(Storefront.LanguageCode.zhCn)
case "PT":
if let regionCode = currentRegionCode?.uppercased() {
return GraphQLEnum(regionCode == "BR" ? Storefront.LanguageCode.ptBr : Storefront.LanguageCode.ptPt)
}
return GraphQLEnum(Storefront.LanguageCode.pt)
default:
if let mappedCode = Storefront.LanguageCode(rawValue: languageCode) {
return GraphQLEnum(mappedCode)
}
let baseLanguage = String(languageCode.prefix(2))
if let mappedCode = Storefront.LanguageCode(rawValue: baseLanguage) {
return GraphQLEnum(mappedCode)
}
}

return GraphQLEnum(Storefront.LanguageCode.en)
}

var countryCode: GraphQLEnum<Storefront.CountryCode> {
GraphQLEnum(Storefront.CountryCode(rawValue: Locale.current.region?.identifier ?? "US") ?? .us)
GraphQLEnum(Storefront.CountryCode(rawValue: Network.currentRegionCode ?? "US") ?? .us)
}

var languageCode: GraphQLEnum<Storefront.LanguageCode> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ extension UIApplication {
.compactMap { $0 as? UIWindowScene }
.filter { $0.activationState == .foregroundActive }

if #available(iOS 15.0, *) {
return activeScenes.compactMap(\.keyWindow).first
} else {
return activeScenes.flatMap(\.windows).first { $0.isKeyWindow }
}
return activeScenes.compactMap(\.keyWindow).first
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,29 @@ struct CartView: View {

VStack(spacing: DesignSystem.buttonSpacing) {
if let cartID = cartManager.cart?.id {
AcceleratedCheckoutButtons(cartID: cartID)
.onFail { error in
print("[AcceleratedCheckout] Failed: \(error)")
}
.onCancel {
print("[AcceleratedCheckout] Cancelled")
}
.connect(client)
.environmentObject(
ShopifyAcceleratedCheckouts.Configuration(
storefrontDomain: InfoDictionary.shared.domain,
storefrontAccessToken: InfoDictionary.shared.accessToken
if #available(iOS 16, *) {
AcceleratedCheckoutButtons(cartID: cartID)
.applePayStyle(applePayStyle.style)
.onFail { error in
print("[AcceleratedCheckout] Failed: \(error)")
}
.onCancel {
print("[AcceleratedCheckout] Cancelled")
}
.connect(client)
.environmentObject(
ShopifyAcceleratedCheckouts.Configuration(
storefrontDomain: InfoDictionary.shared.domain,
storefrontAccessToken: InfoDictionary.shared.accessToken
)
)
)
.environmentObject(
ShopifyAcceleratedCheckouts.ApplePayConfiguration(
merchantIdentifier: InfoDictionary.shared.merchantIdentifier,
contactFields: [.email, .phone]
.environmentObject(
ShopifyAcceleratedCheckouts.ApplePayConfiguration(
merchantIdentifier: InfoDictionary.shared.merchantIdentifier,
contactFields: [.email, .phone]
)
)
)
}
}

Button(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@preconcurrency import ShopifyCheckoutKit
import SwiftUI

@available(iOS 15.0, *)
struct LogsView: View {
@State private var logs: [String?] = LogReader.shared.readLogs(limit: 100) ?? []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,29 @@ struct ProductView: View {
.disabled(!variant.availableForSale || loading)

if variant.availableForSale {
AcceleratedCheckoutButtons(variantID: variant.id, quantity: 1)
.wallets([.applePay])
.onFail { error in
print("[AcceleratedCheckout] Failed: \(error)")
}
.onCancel {
print("[AcceleratedCheckout] Cancelled")
}
.environmentObject(
ShopifyAcceleratedCheckouts.Configuration(
storefrontDomain: InfoDictionary.shared.domain,
storefrontAccessToken: InfoDictionary.shared.accessToken
if #available(iOS 16, *) {
AcceleratedCheckoutButtons(variantID: variant.id, quantity: 1)
.wallets([.applePay])
.applePayStyle(applePayStyle.style)
.onFail { error in
print("[AcceleratedCheckout] Failed: \(error)")
}
.onCancel {
print("[AcceleratedCheckout] Cancelled")
}
.environmentObject(
ShopifyAcceleratedCheckouts.Configuration(
storefrontDomain: InfoDictionary.shared.domain,
storefrontAccessToken: InfoDictionary.shared.accessToken
)
)
)
.environmentObject(
ShopifyAcceleratedCheckouts.ApplePayConfiguration(
merchantIdentifier: InfoDictionary.shared.merchantIdentifier,
contactFields: [.email, .phone]
.environmentObject(
ShopifyAcceleratedCheckouts.ApplePayConfiguration(
merchantIdentifier: InfoDictionary.shared.merchantIdentifier,
contactFields: [.email, .phone]
)
)
)
}
}
}.padding([.leading, .trailing], 15)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ enum ApplePayStyleOption: String, CaseIterable {
}
}

@available(iOS 16.0, *)
var style: PayWithApplePayButtonStyle {
switch self {
case .automatic: return .automatic
Expand Down
2 changes: 1 addition & 1 deletion platforms/swift/Scripts/api
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SWIFT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
PACKAGE_ROOT="$(cd "$SWIFT_ROOT/../.." && pwd)"
BASELINE_DIR="$SWIFT_ROOT/api"
MODULES=(ShopifyCheckoutProtocol ShopifyCheckoutKit ShopifyAcceleratedCheckouts)
TARGET="arm64-apple-ios13.0-simulator"
TARGET="arm64-apple-ios15.0-simulator"

if [[ ! -f "$PACKAGE_ROOT/Package.swift" ]]; then
echo "Error: Package.swift not found at $PACKAGE_ROOT" >&2
Expand Down
Loading
Loading