Skip to content

Commit d73ca4c

Browse files
committed
address review feedback (shadowenv, CONTRIBUTING dev tooling, swift clean/build)
1 parent 9800835 commit d73ca4c

11 files changed

Lines changed: 110 additions & 43 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ When in doubt about whether we will be interested in including a new feature, pl
3939
7. Ensure all checks (tests, lint) are passing in GitHub.
4040
8. Open a pull request with a detailed description of what is changing and why.
4141

42+
### Dev tooling
43+
44+
Shopify employees can use the root `dev.yml` from the repo root:
45+
46+
```bash
47+
dev up
48+
dev check
49+
```
50+
51+
Platform-scoped commands are available as `dev android <command>`, `dev swift <command>`, and `dev react-native <command>` (or `dev rn`). Protocol schema/model commands are available as `dev protocol <command>`. For cross-platform changes, use `dev lint`, `dev test`, `dev check`, `dev format`, and `dev build`.
52+
4253
---
4354

4455
## Swift (`platforms/swift/`)

AGENTS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ e2e/ # cross-platform end-to-end tests
1212

1313
## Dev workflow
1414

15+
> **AI agents:** All commands require the `shadowenv exec --` prefix to run inside the shadowenv-managed environment.
16+
>
17+
> ```
18+
> shadowenv exec --dir <repo_root> -- /opt/dev/bin/dev up
19+
> shadowenv exec --dir <repo_root> -- /opt/dev/bin/dev test [ARGS]
20+
> ```
21+
1522
Run `dev` commands from the repo root. Use `dev up` before running commands when
1623
the environment may not be provisioned.
1724
1825
For platform-scoped work, prefer the root `dev.yml` commands:
1926
2027
- Android: `dev android <command>`
2128
- Swift: `dev swift <command>`
22-
- Protocol: `dev protocol <command>`
2329
- React Native: `dev react-native <command>` or `dev rn <command>`
2430
31+
For protocol schema/model work, use `dev protocol <command>`.
32+
2533
For cross-platform changes, use the repo-wide aggregates: `dev lint`,
2634
`dev test`, `dev check`, `dev format`, and `dev build`. Use
2735
`dev <platform> format` for formatting; `fix` remains an alias for existing

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ Feature guides:
2727
- [Privacy compliance](https://shopify.dev/docs/storefronts/mobile/checkout-kit/privacy-compliance) - pass GDPR, CCPA, and ATT consent through to Shopify.
2828
- [Accelerated checkouts](https://shopify.dev/docs/storefronts/mobile/checkout-kit/accelerated-checkouts?extension=react-native) - Shop Pay and Apple Pay buttons for one-tap purchase on product and cart pages.
2929

30-
## Development
31-
32-
Shopify employees can use the root `dev.yml` from the repo root:
33-
34-
```bash
35-
dev up
36-
dev check
37-
```
38-
39-
Platform-scoped commands are available as `dev android <command>`, `dev swift <command>`, `dev protocol <command>`, and `dev react-native <command>` or `dev rn <command>`. For cross-platform changes, use `dev lint`, `dev test`, `dev check`, `dev format`, and `dev build`.
40-
4130
## Packages in this repo
4231

4332
Checkout Kit is a monorepo containing all the platforms Checkout Kit supports together.

dev.yml

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ check:
8989
react-native-license-headers: cd platforms/react-native && ./scripts/copy_license --check
9090
web-lint: cd platforms/web && pnpm lint
9191
web-test: cd platforms/web && pnpm test
92-
protocol-build: cd protocol/languages/swift && swift build
9392

9493
commands:
9594
# Repo-wide
@@ -99,7 +98,6 @@ commands:
9998
set -e
10099
/opt/dev/bin/dev android build
101100
/opt/dev/bin/dev swift build
102-
/opt/dev/bin/dev protocol build
103101
/opt/dev/bin/dev react-native build
104102
105103
codegen:
@@ -135,7 +133,6 @@ commands:
135133
set -e
136134
/opt/dev/bin/dev android test
137135
/opt/dev/bin/dev swift test
138-
/opt/dev/bin/dev protocol test
139136
/opt/dev/bin/dev react-native test
140137
141138
apollo:
@@ -164,13 +161,13 @@ commands:
164161
desc: "Checkout protocol commands"
165162
subcommands:
166163
build:
167-
desc: Build the Swift protocol package
164+
desc: Build the Swift protocol target
168165
run: cd protocol/languages/swift && swift build
169166
test:
170-
desc: Run Swift protocol package tests
171-
run: cd protocol/languages/swift && swift test
167+
desc: Build the Swift protocol test target
168+
run: cd protocol/languages/swift && swift build --build-tests
172169
check:
173-
desc: Build and test the Swift protocol package
170+
desc: Build the Swift protocol target and test target
174171
run: |
175172
set -e
176173
/opt/dev/bin/dev protocol build
@@ -257,12 +254,34 @@ commands:
257254
aliases: [fix]
258255
run: cd platforms/swift && ./Scripts/lint fix
259256
clean:
260-
desc: Clean Swift package build artifacts
261-
run: cd platforms/swift && ./Scripts/xcode_run clean ShopifyCheckoutKit-Package
257+
desc: Clean Swift packages and sample app build artifacts
258+
run: |
259+
set -e
260+
cd platforms/swift
261+
# ShopifyCheckoutKit-Package is the SPM-wide scheme: it cleans all
262+
# library targets in Package.swift (ShopifyCheckoutKit,
263+
# ShopifyAcceleratedCheckouts, ShopifyCheckoutProtocol) in one pass.
264+
./Scripts/xcode_run clean ShopifyCheckoutKit-Package
265+
cd Samples
266+
# Sample apps have a "Run Script" build phase that runs during clean
267+
# and exits non-zero when there is nothing to delete. Tolerate it so
268+
# the second sample still gets cleaned.
269+
../Scripts/xcode_run clean MobileBuyIntegration || true
270+
../Scripts/xcode_run clean ShopifyAcceleratedCheckoutsApp || true
262271
build:
263-
desc: Build the Swift package
264-
run: cd platforms/swift && ./Scripts/xcode_run build ShopifyCheckoutKit-Package
272+
desc: Build all Swift packages and sample apps
273+
run: |
274+
set -e
275+
cd platforms/swift
276+
# ShopifyCheckoutKit-Package builds every library target in
277+
# Package.swift in one xcodebuild invocation. The sample apps act as
278+
# integration compilation checks against the built libraries.
279+
./Scripts/xcode_run build ShopifyCheckoutKit-Package
280+
./Scripts/build_samples
265281
subcommands:
282+
packages:
283+
desc: Build Swift package targets
284+
run: cd platforms/swift && ./Scripts/xcode_run build ShopifyCheckoutKit-Package
266285
samples:
267286
desc: Build all sample applications to verify integration
268287
run: cd platforms/swift && ./Scripts/build_samples
@@ -364,13 +383,13 @@ commands:
364383
desc: Lint Swift code via SwiftLint
365384
run: cd platforms/react-native && ./scripts/lint_swift
366385
module:
367-
desc: Lint the @shopify/checkout-sheet-kit module
386+
desc: Lint the @shopify/checkout-kit-react-native module
368387
run: cd platforms/react-native && pnpm module lint
369388
sample:
370389
desc: Lint the sample app
371390
run: cd platforms/react-native && pnpm sample lint
372391
format:
373-
desc: Auto-fix Swift lint and format issues
392+
desc: Auto-format and apply safe lint autocorrections (Swift bridge only)
374393
aliases: [fix]
375394
run: cd platforms/react-native && ./scripts/lint_swift fix
376395
api:
@@ -401,6 +420,15 @@ commands:
401420
desc: Check React Native module license headers
402421
run: cd platforms/react-native && ./scripts/copy_license --check
403422

423+
rn:
424+
desc: "Alias for React Native Checkout Kit commands"
425+
long_desc: |
426+
Alias for `dev react-native ...`. Use `dev help react-native` for the
427+
full subcommand list.
428+
syntax:
429+
optional: "[command] [args]"
430+
run: /opt/dev/bin/dev react-native "$@"
431+
404432
# Web
405433
web:
406434
desc: "Web Checkout Kit commands"

platforms/android/scripts/check_license_headers.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
files = []
55

66
Find.find('.') do |path|
7-
next if path.include?('build/generated')
7+
if File.directory?(path) && ['.gradle', 'build'].include?(File.basename(path))
8+
Find.prune
9+
end
10+
811
next unless File.file?(path) && path.end_with?('.kt')
912

1013
lines = File.readlines(path)

platforms/react-native/modules/@shopify/checkout-kit-react-native/ios/AcceleratedCheckoutButtons.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ class RCTAcceleratedCheckoutButtonsView: UIView {
159159
hostingController?.view.frame = bounds
160160
}
161161

162-
// Deprecated in iOS 17 — superseded by registerForTraitChanges in setupView().
163-
// Remove this override when dropping iOS 16 support.
162+
/// Deprecated in iOS 17 — superseded by registerForTraitChanges in setupView().
163+
/// Remove this override when dropping iOS 16 support.
164164
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
165165
super.traitCollectionDidChange(previousTraitCollection)
166166
if #unavailable(iOS 17.0) {

platforms/react-native/sample/src/screens/SettingsScreen.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ function BuyerIdentityDetails({
361361
if (authenticated) {
362362
return (
363363
<View style={styles.sectionFooter}>
364-
<Text style={[styles.sectionFooterText, {color: '#f5a623'}]}>
364+
<Text style={[styles.sectionFooterText, styles.warningText]}>
365365
Changing Buyer Identity will log you out.
366366
</Text>
367367
<View style={styles.detailRow}>
@@ -449,6 +449,9 @@ function createStyles(colors: Colors) {
449449
fontSize: 12,
450450
color: colors.textSubdued,
451451
},
452+
warningText: {
453+
color: '#f5a623',
454+
},
452455
detailRow: {
453456
flexDirection: 'row',
454457
alignItems: 'center',

platforms/react-native/scripts/lint_swift

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
DIR=modules/@shopify/checkout-kit-react-native
44
MODE="${1:-check}"
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
REPO_ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel)"
7+
SWIFT_TOOLS_DIR="$REPO_ROOT/platforms/swift"
58

69
# Validate the mode
710
if [[ "$MODE" != "check" && "$MODE" != "fix" ]]; then
@@ -16,20 +19,33 @@ fi
1619
print_install_instructions() {
1720
echo "🔧 FIX:"
1821
echo " Shopify employee? Run 'dev up'"
19-
echo " Not a Shopify employee? Install via homebrew:"
20-
echo " - SwiftLint: 'brew install swiftlint' / https://github.com/realm/SwiftLint"
21-
echo " - SwiftFormat: 'brew install swiftformat' / https://github.com/nicklockwood/SwiftFormat"
22+
echo " Not a Shopify employee? Install Mint and run 'mint bootstrap' from platforms/swift"
23+
echo " Homebrew also works: 'brew install swiftlint swiftformat'"
2224
}
2325

24-
# Check for SwiftLint
25-
if ! which swiftlint >/dev/null; then
26+
resolve_tool() {
27+
local command_name=$1
28+
29+
if which "$command_name" >/dev/null; then
30+
which "$command_name"
31+
return 0
32+
fi
33+
34+
if command -v mint >/dev/null; then
35+
(cd "$SWIFT_TOOLS_DIR" && mint which "$command_name")
36+
return $?
37+
fi
38+
39+
return 1
40+
}
41+
42+
if ! SWIFTLINT="$(resolve_tool swiftlint)"; then
2643
echo "⚠️ WARN: SwiftLint not installed"
2744
print_install_instructions
2845
exit 1
2946
fi
3047

31-
# Check for SwiftFormat
32-
if ! which swiftformat >/dev/null; then
48+
if ! SWIFTFORMAT="$(resolve_tool swiftformat)"; then
3349
echo "⚠️ WARN: SwiftFormat not installed"
3450
print_install_instructions
3551
exit 1
@@ -38,23 +54,23 @@ fi
3854
# Run SwiftLint
3955
if [[ "$MODE" == "check" ]]; then
4056
echo "🔄 Running SwiftLint in check mode..."
41-
swiftlint lint --strict $DIR --config .swiftlint.yml
57+
"$SWIFTLINT" lint --strict $DIR --config .swiftlint.yml
4258
LINT_STATUS=$?
4359
else
4460
echo "🔄 Running SwiftLint in fix mode..."
45-
swiftlint lint --fix $DIR --config .swiftlint.yml
61+
"$SWIFTLINT" lint --fix $DIR --config .swiftlint.yml
4662
LINT_STATUS=$?
4763
fi
4864
echo "SwiftLint exit status: $LINT_STATUS"
4965

5066
# Run SwiftFormat
5167
if [[ "$MODE" == "check" ]]; then
5268
echo "🔄 Running SwiftFormat in check mode..."
53-
swiftformat $DIR --lint --config .swiftformat
69+
"$SWIFTFORMAT" $DIR --lint --config .swiftformat
5470
FORMAT_STATUS=$?
5571
else
5672
echo "🔄 Running SwiftFormat in fix mode..."
57-
swiftformat $DIR --config .swiftformat
73+
"$SWIFTFORMAT" $DIR --config .swiftformat
5874
FORMAT_STATUS=$?
5975
fi
6076
echo "SwiftFormat exit status: $FORMAT_STATUS"

platforms/swift/.cursor/rules/swift-development.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ alwaysApply: true
2626
Key commands for verification:
2727
- `dev swift lint` (alias: `dev swift style`) - Check format & lint issues
2828
- `dev swift format` - Auto-format and apply safe lint autocorrections
29-
- `dev swift build packages` - Build both packages
29+
- `dev swift build packages` - Build Swift package targets
3030
- `dev swift test` - Run all tests
3131

3232
## Concurrency Best Practices

platforms/swift/Scripts/lint

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ if [[ "$MODE" == "check" && "$SKIP_POD" == "false" ]]; then
169169
# platforms/swift/ and protocol/languages/swift/. Run lint from the
170170
# repo root.
171171
REPO_ROOT="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"
172+
export BUNDLE_GEMFILE="${BUNDLE_GEMFILE:-$REPO_ROOT/platforms/swift/Gemfile}"
172173
POD_LOG=""
173174
if [[ "$VERBOSE" == "true" ]]; then
174175
(cd "$REPO_ROOT" && bundle exec pod lib lint ShopifyCheckoutKit.podspec --allow-warnings)
@@ -188,7 +189,7 @@ if [[ "$MODE" == "check" && "$SKIP_POD" == "false" ]]; then
188189

189190
echo "❌ CocoaPods lint exit status: $POD_STATUS"
190191
echo "❌ CocoaPods detected issues that need to be fixed."
191-
echo "🔧 Run 'bundle exec pod lib lint ShopifyCheckoutKit.podspec --allow-warnings --verbose' from the repo root for details"
192+
echo "🔧 Run 'BUNDLE_GEMFILE=platforms/swift/Gemfile bundle exec pod lib lint ShopifyCheckoutKit.podspec --allow-warnings --verbose' from the repo root for details"
192193
exit 1
193194
fi
194195

0 commit comments

Comments
 (0)