From 120c7894d52105da2c7caad2b6d6c26d78678c21 Mon Sep 17 00:00:00 2001 From: Jonathan Baker Date: Mon, 20 Nov 2023 14:10:45 -0500 Subject: [PATCH 1/4] Add `podspec` and deploy action. --- .github/workflows/deploy.yml | 26 +++++++++ Gemfile | 3 + Gemfile.lock | 108 +++++++++++++++++++++++++++++++++++ ShopifyCheckoutKit.podspec | 24 ++++++++ 4 files changed, 161 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 ShopifyCheckoutKit.podspec diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..993ce7b9 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,26 @@ +name: Deploy + +on: + release: + types: + - published + workflow_dispatch: + +jobs: + cocoapods: + runs-on: macOS-latest + + steps: + - uses: actions/checkout@v3 + + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Deploy to Cocoapods + run: | + set -eo pipefail + bundle exec pod lib lint --allow-warnings --verbose + bundle exec pod trunk push --allow-warnings --verbose + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..d1bf7c6f --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gem "cocoapods" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..47f00e3b --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,108 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.6) + rexml + activesupport (7.1.2) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + addressable (2.8.5) + public_suffix (>= 2.0.2, < 6.0) + algoliasearch (1.27.5) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + atomos (0.1.3) + base64 (0.2.0) + bigdecimal (3.1.4) + claide (1.1.0) + cocoapods (1.14.3) + addressable (~> 2.8) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.14.3) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 2.1, < 3.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.6.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.8.0) + nap (~> 1.0) + ruby-macho (>= 2.3.0, < 3.0) + xcodeproj (>= 1.23.0, < 2.0) + cocoapods-core (1.14.3) + activesupport (>= 5.0, < 8) + addressable (~> 2.8) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + public_suffix (~> 4.0) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.5) + cocoapods-downloader (2.1) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.1) + cocoapods-trunk (1.6.0) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.2.0) + colored2 (3.1.2) + concurrent-ruby (1.2.2) + connection_pool (2.4.1) + drb (2.2.0) + ruby2_keywords + escape (0.0.4) + ethon (0.16.0) + ffi (>= 1.15.0) + ffi (1.16.3) + fourflusher (2.3.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + httpclient (2.8.3) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + json (2.6.3) + minitest (5.20.0) + molinillo (0.8.0) + mutex_m (0.2.0) + nanaimo (0.3.0) + nap (1.1.0) + netrc (0.11.0) + public_suffix (4.0.7) + rexml (3.2.6) + ruby-macho (2.5.1) + ruby2_keywords (0.0.5) + typhoeus (1.4.1) + ethon (>= 0.9.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + xcodeproj (1.23.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.3.0) + rexml (~> 3.2.4) + +PLATFORMS + arm64-darwin-21 + x86_64-darwin-19 + +DEPENDENCIES + cocoapods + +BUNDLED WITH + 2.4.3 diff --git a/ShopifyCheckoutKit.podspec b/ShopifyCheckoutKit.podspec new file mode 100644 index 00000000..1122f991 --- /dev/null +++ b/ShopifyCheckoutKit.podspec @@ -0,0 +1,24 @@ +Pod::Spec.new do |s| + s.version = "0.6.0" + + s.name = "ShopifyCheckoutKit" + s.summary = "Enables Swift apps to embed the Shopify's highest converting, customizable, one-page checkout." + s.author = "Shopify Inc." + + s.homepage = "https://github.com/Shopify/checkout-kit-swift" + s.readme = "https://github.com/Shopify/checkout-kit-swift/blob/main/README.md" + s.changelog = "https://github.com/Shopify/checkout-kit-swift/blob/main/CHANGELOG.md" + s.license = { :type => "MIT", :file => "LICENSE" } + + s.source = { + :git => "https://github.com/Shopify/checkout-kit-swift.git", :tag => s.version.to_s + } + + s.swift_version = "5.0" + + s.ios.deployment_target = "13.0" + + s.source_files = "Sources/ShopifyCheckoutKit/**/*.swift" + + s.resources = "Sources/ShopifyCheckoutKit/**/*.xcassets" +end From f3ac7f320df813b6f2e177f4d68a17cbd3308da9 Mon Sep 17 00:00:00 2001 From: Jonathan Baker Date: Mon, 20 Nov 2023 15:02:30 -0500 Subject: [PATCH 2/4] Tweak bundle loading to support cocoapods. --- ShopifyCheckoutKit.podspec | 4 +- Sources/ShopifyCheckoutKit/Bundle.swift | 42 ++++++++++++++++++++ Sources/ShopifyCheckoutKit/SpinnerView.swift | 2 +- 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 Sources/ShopifyCheckoutKit/Bundle.swift diff --git a/ShopifyCheckoutKit.podspec b/ShopifyCheckoutKit.podspec index 1122f991..dbc8574d 100644 --- a/ShopifyCheckoutKit.podspec +++ b/ShopifyCheckoutKit.podspec @@ -20,5 +20,7 @@ Pod::Spec.new do |s| s.source_files = "Sources/ShopifyCheckoutKit/**/*.swift" - s.resources = "Sources/ShopifyCheckoutKit/**/*.xcassets" + s.resource_bundles = { + "ShopifyCheckoutKit" => ["Sources/ShopifyCheckoutKit/Assets.xcassets"] + } end diff --git a/Sources/ShopifyCheckoutKit/Bundle.swift b/Sources/ShopifyCheckoutKit/Bundle.swift new file mode 100644 index 00000000..7d3a34f7 --- /dev/null +++ b/Sources/ShopifyCheckoutKit/Bundle.swift @@ -0,0 +1,42 @@ +/* +MIT License + +Copyright 2023 - Present, Shopify Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +import Foundation + +internal class ShopifyBundleFinder {} + +extension Bundle { + static var shopifyCheckoutKit: Bundle { + #if COCOAPODS + guard let cocoapodsBundle = Bundle(for: ShopifyBundleFinder.self) + .url(forResource: "ShopifyCheckoutKit", withExtension: "bundle") + .flatMap({ Bundle(url: $0) }) + else { + fatalError("[cocoapods] unable to load resource bundle") + } + return cocoapodsBundle + #else + return .module // use Swift Package Manager's synthesized helper + #endif + } +} diff --git a/Sources/ShopifyCheckoutKit/SpinnerView.swift b/Sources/ShopifyCheckoutKit/SpinnerView.swift index 4b657c2c..9cde0045 100644 --- a/Sources/ShopifyCheckoutKit/SpinnerView.swift +++ b/Sources/ShopifyCheckoutKit/SpinnerView.swift @@ -26,7 +26,7 @@ import UIKit class SpinnerView: UIView { private lazy var imageView: UIImageView = { let view = UIImageView(image: UIImage( - named: "spinner", in: .module, with: nil + named: "spinner", in: .shopifyCheckoutKit, with: nil )) view.translatesAutoresizingMaskIntoConstraints = false return view From 4c64cda46abd57c469ce726c987d8675317318a6 Mon Sep 17 00:00:00 2001 From: Jonathan Baker Date: Mon, 20 Nov 2023 15:35:13 -0500 Subject: [PATCH 3/4] Update README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ed39c44d..92f777e9 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,12 @@ dependencies: [ For more details on managing Swift Package dependencies in Xcode, please see [Apple's documentation](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app). +#### Cocoapods + +```ruby +pod "ShopifyCheckoutKit", "~> 0.6" +``` + ### Basic Usage Once the SDK has been added as a dependency, you can import the library: From 3f6c27a0fbfa83cbe79ef4486bf7e352076e3fad Mon Sep 17 00:00:00 2001 From: Jonathan Baker Date: Mon, 20 Nov 2023 16:13:10 -0500 Subject: [PATCH 4/4] Add podspec linting. --- .github/workflows/lint.yml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f31d68ba..6ac06a32 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,19 +1,32 @@ -name: Run Lint Checks +name: Lint on: pull_request: workflow_dispatch: jobs: - lint: + swiftlint: + name: SwiftLint runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - - name: Run SwiftLint - uses: norio-nomura/action-swiftlint@3.2.1 + - uses: norio-nomura/action-swiftlint@3.2.1 with: args: --strict - - name: Check License Headers - run: ./Scripts/copy_license && git diff --name-only --exit-code + check-license-headers: + name: License Headers + runs-on: macOS-latest + steps: + - uses: actions/checkout@v3 + - run: ./Scripts/copy_license && git diff --name-only --exit-code + + lint-podspec: + name: CocoaPods + runs-on: macOS-latest + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - run: bundle exec pod lib lint --allow-warnings