Skip to content

Try: ship ShopifyCheckoutProtocol as its own pod, depend on it from the kit#77

Closed
kieran-osgood-shopify wants to merge 17 commits into
mainfrom
kieran-osgood/ko/protocol-as-separate-podspec
Closed

Try: ship ShopifyCheckoutProtocol as its own pod, depend on it from the kit#77
kieran-osgood-shopify wants to merge 17 commits into
mainfrom
kieran-osgood/ko/protocol-as-separate-podspec

Conversation

@kieran-osgood-shopify
Copy link
Copy Markdown
Contributor

Reverts the file move from PR #65 so ShopifyCheckoutProtocol stays under
protocol/languages/swift/, restores its standalone Package.swift, and adds a
new sibling cocoapod:

protocol/languages/swift/ShopifyCheckoutProtocol.podspec

ShopifyCheckoutKit.podspec then declares a regular pod dependency:

core.dependency 'ShopifyCheckoutProtocol', "= #{s.version}"

This mirrors the SwiftPM target split exactly: in both worlds (SwiftPM and
CocoaPods) ShopifyCheckoutKit is a separate module that imports
ShopifyCheckoutProtocol, so the #if !COCOAPODS shims that PR #65 added
around import ShopifyCheckoutProtocol can be removed (done here in
CheckoutViewController.swift, CheckoutWebView.swift, ShopifyCheckoutKit.swift).

RESULT: works.

Lint the protocol pod first

cd protocol/languages/swift
BUNDLE_GEMFILE=../../../platforms/swift/Gemfile bundle exec pod lib lint
ShopifyCheckoutProtocol.podspec --allow-warnings
-> ShopifyCheckoutProtocol passed validation.

Then the kit pod, told where to find the local protocol pod

cd platforms/swift
BUNDLE_GEMFILE=Gemfile bundle exec pod lib lint ShopifyCheckoutKit.podspec
--allow-warnings
--include-podspecs=../../protocol/languages/swift/ShopifyCheckoutProtocol.podspec
-> ShopifyCheckoutKit passed validation.

Both Core and AcceleratedCheckouts subspecs build cleanly. Same JSONAny
Sendable warnings as the baseline.

Trade-offs vs PR #65:

  • Single source of truth: protocol files live in protocol/languages/swift,
    reachable by Swift consumers (SwiftPM standalone Package, the umbrella
    Package, CocoaPods, and Android via the protocol/ scripts).
  • No source-import #if shims; the module exists in both worlds.
  • ShopifyCheckoutProtocol becomes independently consumable by other Swift
    apps that want UCP types without pulling in the WebView kit.
  • Two pods to publish and version. Release flow needs to push
    ShopifyCheckoutProtocol to trunk before ShopifyCheckoutKit (and they
    must share s.version, which is enforced via = #{s.version} in the
    dependency declaration).
  • CONTRIBUTING.md release docs need a follow-up note about pushing both
    podspecs (not done in this commit; intentionally left for a follow-up
    once we settle on the approach).

Note: pod lib lint of ShopifyCheckoutKit requires --include-podspecs because
the protocol pod has not been published to trunk yet. Once published, that
flag is no longer needed.

markmur and others added 17 commits May 12, 2026 21:28
CocoaPods silently drops source_files paths outside the spec dir, so
'../../protocol/languages/swift/...' globs were not bundled and 'pod
lib lint' failed with 6 'cannot find CheckoutProtocol in scope' errors.
Move the Swift protocol sources physically under
platforms/swift/Sources/ShopifyCheckoutProtocol and replace the SPM
location with a symlink so the SPM target path stays inside its
package root.

The earlier sed rename in generate_models.sh anchored on a trailing
space ('struct Binding ') but quicktype emits 'struct Binding:' with
no whitespace, so the rename never fired and the SwiftUI sample app
failed with 'Binding is ambiguous'. Switch to BSD word-boundary
anchors so all identifier sites get rewritten, and regenerate
Models.swift.
Keep one copy of the Swift protocol sources under
protocol/languages/swift/Sources/ShopifyCheckoutProtocol (their
conceptual home, alongside the schemas and other language ports) and
expose them inside the podspec dir via a symlink at
platforms/swift/Sources/ShopifyCheckoutProtocol. CocoaPods' source_files
glob follows the symlink, so the Core subspec still compiles them.

Point the generator OUTPUT back at the canonical path.
…he kit

Reverts the file move from PR #65 so ShopifyCheckoutProtocol stays under
protocol/languages/swift/, restores its standalone Package.swift, and adds a
new sibling cocoapod:

  protocol/languages/swift/ShopifyCheckoutProtocol.podspec

ShopifyCheckoutKit.podspec then declares a regular pod dependency:

    core.dependency 'ShopifyCheckoutProtocol', "= #{s.version}"

This mirrors the SwiftPM target split exactly: in both worlds (SwiftPM and
CocoaPods) ShopifyCheckoutKit is a separate module that imports
ShopifyCheckoutProtocol, so the `#if !COCOAPODS` shims that PR #65 added
around `import ShopifyCheckoutProtocol` can be removed (done here in
CheckoutViewController.swift, CheckoutWebView.swift, ShopifyCheckoutKit.swift).

RESULT: works.

  # Lint the protocol pod first
  cd protocol/languages/swift
  BUNDLE_GEMFILE=../../../platforms/swift/Gemfile bundle exec pod lib lint \
    ShopifyCheckoutProtocol.podspec --allow-warnings
    -> ShopifyCheckoutProtocol passed validation.

  # Then the kit pod, told where to find the local protocol pod
  cd platforms/swift
  BUNDLE_GEMFILE=Gemfile bundle exec pod lib lint ShopifyCheckoutKit.podspec \
    --allow-warnings \
    --include-podspecs=../../protocol/languages/swift/ShopifyCheckoutProtocol.podspec
    -> ShopifyCheckoutKit passed validation.

Both Core and AcceleratedCheckouts subspecs build cleanly. Same JSONAny
Sendable warnings as the baseline.

Trade-offs vs PR #65:
  + Single source of truth: protocol files live in protocol/languages/swift,
    reachable by Swift consumers (SwiftPM standalone Package, the umbrella
    Package, CocoaPods, and Android via the protocol/ scripts).
  + No source-import #if shims; the module exists in both worlds.
  + ShopifyCheckoutProtocol becomes independently consumable by other Swift
    apps that want UCP types without pulling in the WebView kit.
  - Two pods to publish and version. Release flow needs to push
    ShopifyCheckoutProtocol to trunk before ShopifyCheckoutKit (and they
    must share s.version, which is enforced via `= #{s.version}` in the
    dependency declaration).
  - CONTRIBUTING.md release docs need a follow-up note about pushing both
    podspecs (not done in this commit; intentionally left for a follow-up
    once we settle on the approach).

Note: pod lib lint of ShopifyCheckoutKit requires --include-podspecs because
the protocol pod has not been published to trunk yet. Once published, that
flag is no longer needed.
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/ko/protocol-as-separate-podspec branch from 0a2b9fd to 8b9ef8d Compare May 13, 2026 10:15
@markmur markmur force-pushed the swift/remove-delegations branch 2 times, most recently from e1e9d50 to 3241a78 Compare May 13, 2026 11:50
Base automatically changed from swift/remove-delegations to main May 13, 2026 11:56
An error occurred while trying to automatically change base from swift/remove-delegations to main May 13, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants