Skip to content
Draft
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
14 changes: 7 additions & 7 deletions dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ commands:
desc: "Apollo GraphQL schema and code generation commands"
subcommands:
download_schema:
desc: "Download GraphQL schema. Usage: dev apollo download_schema <android|swift> [accelerated|mobile-buy|all]"
syntax: "<android|swift> [accelerated|mobile-buy|all]"
desc: "Download GraphQL schema. Usage: dev apollo download_schema <android|swift> [accelerated|swift|all]"
syntax: "<android|swift> [accelerated|swift|all]"
run: |
case "$1" in
android) cd platforms/android && ./scripts/apollo_download_schema ;;
swift) shift; cd platforms/swift && ./Scripts/apollo_download_schema "$@" ;;
*) echo "Usage: dev apollo download_schema <android|swift> [accelerated|mobile-buy|all]"; exit 1 ;;
*) echo "Usage: dev apollo download_schema <android|swift> [accelerated|swift|all]"; exit 1 ;;
esac
codegen:
desc: "Generate Apollo models. Usage: dev apollo codegen <android|swift> [accelerated|mobile-buy|all]"
syntax: "<android|swift> [accelerated|mobile-buy|all]"
desc: "Generate Apollo models. Usage: dev apollo codegen <android|swift> [accelerated|swift|all]"
syntax: "<android|swift> [accelerated|swift|all]"
run: |
case "$1" in
android) cd platforms/android && ./scripts/apollo_codegen ;;
swift) shift; cd platforms/swift && ./Scripts/apollo_codegen "$@" ;;
*) echo "Usage: dev apollo codegen <android|swift> [accelerated|mobile-buy|all]"; exit 1 ;;
*) echo "Usage: dev apollo codegen <android|swift> [accelerated|swift|all]"; exit 1 ;;
esac

# Protocol
Expand Down Expand Up @@ -273,7 +273,7 @@ commands:
# Sample apps have a "Run Script" build phase that runs during clean
# and exits non-zero when there is nothing to delete. Tolerate it so
# the second sample still gets cleaned.
../Scripts/xcode_run clean MobileBuyIntegration || true
../Scripts/xcode_run clean CheckoutKitSwiftDemo || true
../Scripts/xcode_run clean ShopifyAcceleratedCheckoutsApp || true

# React Native
Expand Down
2 changes: 1 addition & 1 deletion platforms/swift/.swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
--extensionacl on-declarations
--exclude Sources/ShopifyCheckoutKit/Models.swift
--exclude Sources/ShopifyCheckoutProtocol/Generated
--exclude Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/Generated
--exclude Samples/CheckoutKitSwiftDemo/CheckoutKitSwiftDemo/Sources/Generated
--exclude Samples/ShopifyAcceleratedCheckoutsApp/ShopifyAcceleratedCheckoutsApp/Generated
2 changes: 1 addition & 1 deletion platforms/swift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ Use `CheckoutProtocol.Client` through `.connect(client)` to observe checkout com

See [Samples](Samples/README.md):

- `MobileBuyIntegration` demonstrates a Storefront API cart flow, buyer identity modes, Customer Account API, checkout presentation, and protocol events.
- `CheckoutKitSwiftDemo` demonstrates a Storefront API cart flow, buyer identity modes, Customer Account API, checkout presentation, and protocol events.
- `ShopifyAcceleratedCheckoutsApp` demonstrates Shop Pay and Apple Pay accelerated checkout buttons.

## Contributing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
MobileBuyIntegration:
CheckoutKitSwiftDemo:
- 'Run SwiftLint: 4ECA613D2AC5D304005A59A7'
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

/* Begin PBXFileReference section */
2147F3E52B502AFD005546F3 /* checkout-kit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "checkout-kit"; path = ../..; sourceTree = "<group>"; };
4EBBA7672A5F0CE200193E19 /* MobileBuyIntegration.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MobileBuyIntegration.app; sourceTree = BUILT_PRODUCTS_DIR; };
4EBBA7672A5F0CE200193E19 /* CheckoutKitSwiftDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CheckoutKitSwiftDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
4EBBA7732A5F0CE200193E19 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4EBBA7762A5F0CE200193E19 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4EBBA7782A5F0CE200193E19 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4EBBA7A72A5F10C400193E19 /* Storefront.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Storefront.xcconfig; sourceTree = SOURCE_ROOT; };
6AE865492CE3BB6500A4971C /* MobileBuyIntegration.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MobileBuyIntegration.entitlements; sourceTree = "<group>"; };
6AE865492CE3BB6500A4971C /* CheckoutKitSwiftDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = CheckoutKitSwiftDemo.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFileSystemSynchronizedRootGroup section */
Expand All @@ -49,7 +49,7 @@
4EBBA75E2A5F0CE200193E19 = {
isa = PBXGroup;
children = (
4EBBA7692A5F0CE200193E19 /* MobileBuyIntegration */,
4EBBA7692A5F0CE200193E19 /* CheckoutKitSwiftDemo */,
4EBBA7B32A5F230900193E19 /* Packages */,
4EBBA7682A5F0CE200193E19 /* Products */,
4EBBA7B52A5F231500193E19 /* Frameworks */,
Expand All @@ -59,18 +59,18 @@
4EBBA7682A5F0CE200193E19 /* Products */ = {
isa = PBXGroup;
children = (
4EBBA7672A5F0CE200193E19 /* MobileBuyIntegration.app */,
4EBBA7672A5F0CE200193E19 /* CheckoutKitSwiftDemo.app */,
);
name = Products;
sourceTree = "<group>";
};
4EBBA7692A5F0CE200193E19 /* MobileBuyIntegration */ = {
4EBBA7692A5F0CE200193E19 /* CheckoutKitSwiftDemo */ = {
isa = PBXGroup;
children = (
CB236EDA2FB219C500F0D914 /* Sources */,
4EBBA77E2A5F0D8E00193E19 /* Resources */,
);
path = MobileBuyIntegration;
path = CheckoutKitSwiftDemo;
sourceTree = "<group>";
};
4EBBA77E2A5F0D8E00193E19 /* Resources */ = {
Expand All @@ -80,7 +80,7 @@
4EBBA7732A5F0CE200193E19 /* Assets.xcassets */,
4EBBA7752A5F0CE200193E19 /* LaunchScreen.storyboard */,
4EBBA7782A5F0CE200193E19 /* Info.plist */,
6AE865492CE3BB6500A4971C /* MobileBuyIntegration.entitlements */,
6AE865492CE3BB6500A4971C /* CheckoutKitSwiftDemo.entitlements */,
);
name = Resources;
sourceTree = "<group>";
Expand All @@ -103,9 +103,9 @@
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
4EBBA7662A5F0CE200193E19 /* MobileBuyIntegration */ = {
4EBBA7662A5F0CE200193E19 /* CheckoutKitSwiftDemo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 4EBBA77B2A5F0CE200193E19 /* Build configuration list for PBXNativeTarget "MobileBuyIntegration" */;
buildConfigurationList = 4EBBA77B2A5F0CE200193E19 /* Build configuration list for PBXNativeTarget "CheckoutKitSwiftDemo" */;
buildPhases = (
4EBBA7632A5F0CE200193E19 /* Sources */,
4EBBA7642A5F0CE200193E19 /* Frameworks */,
Expand All @@ -119,16 +119,16 @@
fileSystemSynchronizedGroups = (
CB236EDA2FB219C500F0D914 /* Sources */,
);
name = MobileBuyIntegration;
name = CheckoutKitSwiftDemo;
packageProductDependencies = (
CB00000012345679 /* Apollo */,
CB00000012345680 /* ApolloAPI */,
CB001E302F3CDA0300286F69 /* ShopifyCheckoutProtocol */,
CB1B10B42E4CDDB0001713F8 /* ShopifyCheckoutKit */,
CBED2D4E2F3F5D1B00EC866A /* ShopifyAcceleratedCheckouts */,
);
productName = MobileBuyIntegration;
productReference = 4EBBA7672A5F0CE200193E19 /* MobileBuyIntegration.app */;
productName = CheckoutKitSwiftDemo;
productReference = 4EBBA7672A5F0CE200193E19 /* CheckoutKitSwiftDemo.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
Expand All @@ -146,7 +146,7 @@
};
};
};
buildConfigurationList = 4EBBA7622A5F0CE200193E19 /* Build configuration list for PBXProject "MobileBuyIntegration" */;
buildConfigurationList = 4EBBA7622A5F0CE200193E19 /* Build configuration list for PBXProject "CheckoutKitSwiftDemo" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
Expand All @@ -165,7 +165,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
4EBBA7662A5F0CE200193E19 /* MobileBuyIntegration */,
4EBBA7662A5F0CE200193E19 /* CheckoutKitSwiftDemo */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -353,12 +353,12 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = MobileBuyIntegration/MobileBuyIntegration.entitlements;
CODE_SIGN_ENTITLEMENTS = CheckoutKitSwiftDemo/CheckoutKitSwiftDemo.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = A7XGC83MZE;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MobileBuyIntegration/Info.plist;
INFOPLIST_FILE = CheckoutKitSwiftDemo/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Plant;
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Your location may be required to locate pickup points near you when you request this shipping option.";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand All @@ -373,7 +373,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.example.MobileBuyIntegration;
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.checkoutkit.swiftdemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
Expand All @@ -388,12 +388,12 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = MobileBuyIntegration/MobileBuyIntegration.entitlements;
CODE_SIGN_ENTITLEMENTS = CheckoutKitSwiftDemo/CheckoutKitSwiftDemo.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = A7XGC83MZE;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MobileBuyIntegration/Info.plist;
INFOPLIST_FILE = CheckoutKitSwiftDemo/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Plant;
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Your location may be required to locate pickup points near you when you request this shipping option.";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand All @@ -409,7 +409,7 @@
);
MARKETING_VERSION = 1.0;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.example.MobileBuyIntegration;
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.checkoutkit.swiftdemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
Expand All @@ -422,7 +422,7 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
4EBBA7622A5F0CE200193E19 /* Build configuration list for PBXProject "MobileBuyIntegration" */ = {
4EBBA7622A5F0CE200193E19 /* Build configuration list for PBXProject "CheckoutKitSwiftDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4EBBA7792A5F0CE200193E19 /* Debug */,
Expand All @@ -431,7 +431,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
4EBBA77B2A5F0CE200193E19 /* Build configuration list for PBXNativeTarget "MobileBuyIntegration" */ = {
4EBBA77B2A5F0CE200193E19 /* Build configuration list for PBXNativeTarget "CheckoutKitSwiftDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4EBBA77C2A5F0CE200193E19 /* Debug */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4EBBA7662A5F0CE200193E19"
BuildableName = "MobileBuyIntegration.app"
BlueprintName = "MobileBuyIntegration"
ReferencedContainer = "container:MobileBuyIntegration.xcodeproj">
BuildableName = "CheckoutKitSwiftDemo.app"
BlueprintName = "CheckoutKitSwiftDemo"
ReferencedContainer = "container:CheckoutKitSwiftDemo.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
Expand All @@ -33,9 +33,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4EBBA7662A5F0CE200193E19"
BuildableName = "MobileBuyIntegration.app"
BlueprintName = "MobileBuyIntegration"
ReferencedContainer = "container:MobileBuyIntegration.xcodeproj">
BuildableName = "CheckoutKitSwiftDemo.app"
BlueprintName = "CheckoutKitSwiftDemo"
ReferencedContainer = "container:CheckoutKitSwiftDemo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -62,9 +62,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4EBBA7662A5F0CE200193E19"
BuildableName = "MobileBuyIntegration.app"
BlueprintName = "MobileBuyIntegration"
ReferencedContainer = "container:MobileBuyIntegration.xcodeproj">
BuildableName = "CheckoutKitSwiftDemo.app"
BlueprintName = "CheckoutKitSwiftDemo"
ReferencedContainer = "container:CheckoutKitSwiftDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
Expand All @@ -79,9 +79,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4EBBA7662A5F0CE200193E19"
BuildableName = "MobileBuyIntegration.app"
BlueprintName = "MobileBuyIntegration"
ReferencedContainer = "container:MobileBuyIntegration.xcodeproj">
BuildableName = "CheckoutKitSwiftDemo.app"
BlueprintName = "CheckoutKitSwiftDemo"
ReferencedContainer = "container:CheckoutKitSwiftDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>com.apple.developer.in-app-payments</key>
<array>
<string>merchant.com.shopify.example.MobileBuyIntegration.ApplePay</string>
<string>merchant.com.shopify.checkoutkit.swiftdemo</string>
</array>
<key>com.apple.developer.associated-domains</key>
<array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
$0.logLevel = checkoutKitLogLevel
}

print("[MobileBuyIntegration] CheckoutKit Log level set to \(checkoutKitLogLevel)")
print("[CheckoutKitSwiftDemo] CheckoutKit Log level set to \(checkoutKitLogLevel)")

UIBarButtonItem.appearance().tintColor = ColorPalette.primaryColor

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MobileBuyIntegration Sample App
# CheckoutKitSwiftDemo Sample App

This sample demonstrates how to integrate Checkout Kit with the Shopify Storefront API using Apollo iOS.

Expand All @@ -17,8 +17,8 @@ This sample demonstrates how to integrate Checkout Kit with the Shopify Storefro
The app uses Apollo iOS for Storefront API communication. GraphQL operations are defined as `.graphql` files, and Apollo's code generation tool produces type-safe Swift code from them.

```text
MobileBuyIntegration/
|-- MobileBuyIntegration/
CheckoutKitSwiftDemo/
|-- CheckoutKitSwiftDemo/
| |-- Sources/
| | |-- Api/ Source of truth - edit these files
| | | |-- Queries/
Expand Down Expand Up @@ -102,10 +102,10 @@ Open the project in Xcode, let Swift Package Manager resolve dependencies, then
3. Download the schema. This introspects your store's Storefront API and writes `schema.<version>.graphqls` into the sample app directory.

```sh
dev apollo download_schema swift mobile-buy
dev apollo download_schema swift swift
```

4. Update `.graphql` operations if the schema changed. For example, add a product field to `MobileBuyIntegration/Sources/Api/Queries/GetProducts.graphql` before regenerating types:
4. Update `.graphql` operations if the schema changed. For example, add a product field to `CheckoutKitSwiftDemo/Sources/Api/Queries/GetProducts.graphql` before regenerating types:

```graphql
query GetProducts(...) {
Expand All @@ -119,10 +119,10 @@ Open the project in Xcode, let Swift Package Manager resolve dependencies, then
}
```

5. Regenerate Swift types with the Apollo iOS CLI and this sample's `apollo-codegen-config.json`. This reads the schema and `.graphql` files, then regenerates Swift code in `MobileBuyIntegration/Sources/Generated/`.
5. Regenerate Swift types with the Apollo iOS CLI and this sample's `apollo-codegen-config.json`. This reads the schema and `.graphql` files, then regenerates Swift code in `CheckoutKitSwiftDemo/Sources/Generated/`.

```sh
dev apollo codegen swift mobile-buy
dev apollo codegen swift swift
```

6. Build in Xcode and fix any compile errors from schema changes.
Expand All @@ -133,8 +133,8 @@ All commands are run from the **repo root** (`checkout-kit/`):

| Command | Description |
|---------|-------------|
| `dev apollo download_schema swift mobile-buy` | Download the Storefront API schema for this sample app |
| `dev apollo codegen swift mobile-buy` | Regenerate Swift types from `.graphql` files |
| `dev apollo download_schema swift swift` | Download the Storefront API schema for this sample app |
| `dev apollo codegen swift swift` | Regenerate Swift types from `.graphql` files |
| `dev apollo codegen swift all` | Regenerate for all sample apps |
| `dev swift lint` | Run SwiftLint + SwiftFormat checks |
| `dev swift format` | Auto-format and apply safe lint autocorrections |
Expand All @@ -147,9 +147,9 @@ All commands are run from the **repo root** (`checkout-kit/`):
| `Storefront.xcconfig` | Generated sample config from the repo-root `.env` (not checked into git). |
| `schema.<version>.graphqls` | Storefront API schema downloaded with the Apollo iOS CLI. |
| `apollo-codegen-config.json` | Apollo code generation configuration. |
| `MobileBuyIntegration/Sources/Api/Network.swift` | Apollo client setup and authentication interceptor. |
| `MobileBuyIntegration/Sources/Api/StorefrontClient.swift` | Cart input creation and buyer identity mapping. |
| `MobileBuyIntegration/Sources/App/CartManager.swift` | Cart state and Storefront API mutations. |
| `MobileBuyIntegration/Sources/App/CheckoutCoordinator.swift` | Checkout presentation. |
| `MobileBuyIntegration/Sources/CheckoutProtocolClient.swift` | Typed checkout lifecycle handlers. |
| `CheckoutKitSwiftDemo/Sources/Api/Network.swift` | Apollo client setup and authentication interceptor. |
| `CheckoutKitSwiftDemo/Sources/Api/StorefrontClient.swift` | Cart input creation and buyer identity mapping. |
| `CheckoutKitSwiftDemo/Sources/App/CartManager.swift` | Cart state and Storefront API mutations. |
| `CheckoutKitSwiftDemo/Sources/App/CheckoutCoordinator.swift` | Checkout presentation. |
| `CheckoutKitSwiftDemo/Sources/CheckoutProtocolClient.swift` | Typed checkout lifecycle handlers. |
| `Scripts/generate_entitlements.sh` | Generates Associated Domains entitlements for checkout and offsite-payment return links. |
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -e
CONFIG_FILE="Storefront.xcconfig"
STOREFRONT_DOMAIN=$(grep '^[[:space:]]*STOREFRONT_DOMAIN' "$CONFIG_FILE" | cut -d '=' -f2 | tr -d ' ')

TEMPLATE_FILE="MobileBuyIntegration/MobileBuyIntegration.entitlements.template"
OUTPUT_FILE="MobileBuyIntegration/MobileBuyIntegration.entitlements"
TEMPLATE_FILE="CheckoutKitSwiftDemo/CheckoutKitSwiftDemo.entitlements.template"
OUTPUT_FILE="CheckoutKitSwiftDemo/CheckoutKitSwiftDemo.entitlements"

if [ -z "$STOREFRONT_DOMAIN" ]; then
echo "Error: STOREFRONT_DOMAIN is not set in Storefront.xcconfig"
Expand Down
Loading
Loading