From 45ee1ac390c138a81703305430a9570eee1343de Mon Sep 17 00:00:00 2001 From: Mel <78050250+mludowise-stripe@users.noreply.github.com> Date: Thu, 1 Jul 2021 13:46:14 -0700 Subject: [PATCH] MOBILESDK-318: Add StripeCore dependency to Stripe (#273) - Add a dependency on `StripeCore` for the StripeiOS target, Carthage, SPM, and Cocoapods - Update `StripeCore.podspec` to use a tag instead of a branch - Shared `StripeCore.xcscheme` so Carthage builds StripeCore - Modified `build_documentation.sh` to pass a temporary local podspec repo so it can find `StripeCore` --- Package.swift | 2 +- Stripe.podspec | 1 + Stripe.xcodeproj/project.pbxproj | 4 + StripeCore.podspec | 4 +- .../xcschemes/StripeCore.xcscheme | 77 +++++++++++++++++++ .../CarthageTest.xcodeproj/project.pbxproj | 4 + .../cocoapods/with_frameworks_objc/Podfile | 1 + .../cocoapods/with_frameworks_swift/Podfile | 1 + .../cocoapods/without_frameworks_objc/Podfile | 1 + ci_scripts/build_documentation.sh | 15 +++- ci_scripts/make_temp_spec_repo.sh | 44 +++++++++++ 11 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 StripeCore/StripeCore.xcodeproj/xcshareddata/xcschemes/StripeCore.xcscheme create mode 100755 ci_scripts/make_temp_spec_repo.sh diff --git a/Package.swift b/Package.swift index 1c4e88f7f4..651f6466f7 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,7 @@ let package = Package( targets: [ .target( name: "Stripe", - dependencies: ["Stripe3DS2"], + dependencies: ["Stripe3DS2", "StripeCore"], path: "Stripe", exclude: ["Info.plist"], resources: [ diff --git a/Stripe.podspec b/Stripe.podspec index 1afa684706..f3e2c58db5 100644 --- a/Stripe.podspec +++ b/Stripe.podspec @@ -18,6 +18,7 @@ Pod::Spec.new do |s| s.weak_framework = 'SwiftUI' s.source_files = 'Stripe/*.swift', 'Stripe/PanModal/**/*.swift' s.ios.resource_bundle = { 'Stripe' => 'Stripe/Resources/**/*.{lproj,json,png,xcassets}' } + s.dependency 'StripeCore', "#{s.version}" s.subspec 'Stripe3DS2' do |sp| sp.source_files = 'Stripe3DS2/Stripe3DS2/**/*.{h,m}' sp.resource_bundles = { 'Stripe3DS2' => ['Stripe3DS2/Stripe3DS2/Resources/**/*.{lproj,png}'] } diff --git a/Stripe.xcodeproj/project.pbxproj b/Stripe.xcodeproj/project.pbxproj index 63668b4018..3d36eb85e9 100644 --- a/Stripe.xcodeproj/project.pbxproj +++ b/Stripe.xcodeproj/project.pbxproj @@ -677,6 +677,7 @@ E640A4C1265F26A500B31E91 /* Analytic+Payments.swift in Sources */ = {isa = PBXBuildFile; fileRef = E640A4C0265F26A500B31E91 /* Analytic+Payments.swift */; }; E69552D625CCDC0F00753FDA /* STPiDEALBank.swift in Sources */ = {isa = PBXBuildFile; fileRef = E69552D525CCDC0F00753FDA /* STPiDEALBank.swift */; }; E69552EB25D1E4F000753FDA /* STPGenericInputPickerField.swift in Sources */ = {isa = PBXBuildFile; fileRef = E69552EA25D1E4EF00753FDA /* STPGenericInputPickerField.swift */; }; + E6B0F5592686C0BA00055EAF /* StripeCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E6B0F5582686C0BA00055EAF /* StripeCore.framework */; }; E6B8971F25FC4FD6002428E1 /* MockAnalyticsClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6B8971E25FC4FD6002428E1 /* MockAnalyticsClient.swift */; }; E6B8972525FC532B002428E1 /* Analytic.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6B8972125FC5311002428E1 /* Analytic.swift */; }; F1122A7E1DFB84E000A8B1AF /* UINavigationBar+StripeTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F1122A7D1DFB84E000A8B1AF /* UINavigationBar+StripeTest.m */; }; @@ -1442,6 +1443,7 @@ E640A4C0265F26A500B31E91 /* Analytic+Payments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Analytic+Payments.swift"; sourceTree = ""; }; E69552D525CCDC0F00753FDA /* STPiDEALBank.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPiDEALBank.swift; sourceTree = ""; }; E69552EA25D1E4EF00753FDA /* STPGenericInputPickerField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPGenericInputPickerField.swift; sourceTree = ""; }; + E6B0F5582686C0BA00055EAF /* StripeCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = StripeCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E6B8971E25FC4FD6002428E1 /* MockAnalyticsClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockAnalyticsClient.swift; sourceTree = ""; }; E6B8972125FC5311002428E1 /* Analytic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Analytic.swift; sourceTree = ""; }; ED627D57207EA348007EFC56 /* nb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = nb; path = Localizations/nb.lproj/Localizable.strings; sourceTree = ""; }; @@ -1499,6 +1501,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + E6B0F5592686C0BA00055EAF /* StripeCore.framework in Frameworks */, F15232311EA93E6800D65C67 /* Contacts.framework in Frameworks */, 31EFEE0E258AE3F40069BC5F /* Stripe3DS2.framework in Frameworks */, F1D765CE1EDE331500F37005 /* CoreLocation.framework in Frameworks */, @@ -1644,6 +1647,7 @@ 11C74B9A164043050071C2CA /* Frameworks */ = { isa = PBXGroup; children = ( + E6B0F5582686C0BA00055EAF /* StripeCore.framework */, 31EFEE0D258AE3F40069BC5F /* Stripe3DS2.framework */, 310FCA922582F1C6005FB2AE /* Stripe3DS2.framework */, 04E01F7921A8C37C0061402F /* OHHTTPStubs.xcframework */, diff --git a/StripeCore.podspec b/StripeCore.podspec index 615deed69b..db4f01560b 100644 --- a/StripeCore.podspec +++ b/StripeCore.podspec @@ -10,9 +10,7 @@ Pod::Spec.new do |s| s.license = { :type => 'MIT', :file => 'LICENSE' } s.homepage = 'https://stripe.com/docs/mobile/ios' s.authors = { 'Stripe' => 'support+github@stripe.com' } - # TODO(mludowise|MOBILESDK-265): Temporarily publish to branch so `pod lib lint` can pass. - # Change from branch back to `:tag => "#{s.version}"` before next deploy. - s.source = { :git => 'https://github.com/stripe/stripe-ios.git', :branch => "StripeCore-#{s.version}" } + s.source = { :git => 'https://github.com/stripe/stripe-ios.git', :tag => "#{s.version}" } s.frameworks = 'Foundation', 'Security', 'WebKit', 'PassKit', 'Contacts', 'CoreLocation' s.requires_arc = true s.platform = :ios diff --git a/StripeCore/StripeCore.xcodeproj/xcshareddata/xcschemes/StripeCore.xcscheme b/StripeCore/StripeCore.xcodeproj/xcshareddata/xcschemes/StripeCore.xcscheme new file mode 100644 index 0000000000..08fb73a695 --- /dev/null +++ b/StripeCore/StripeCore.xcodeproj/xcshareddata/xcschemes/StripeCore.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/installation_tests/carthage/CarthageTest.xcodeproj/project.pbxproj b/Tests/installation_tests/carthage/CarthageTest.xcodeproj/project.pbxproj index d28ef4e88d..52ceff1c12 100644 --- a/Tests/installation_tests/carthage/CarthageTest.xcodeproj/project.pbxproj +++ b/Tests/installation_tests/carthage/CarthageTest.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 31CA744B25CCC669007FE8BF /* Stripe3DS2.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31CA744A25CCC669007FE8BF /* Stripe3DS2.xcframework */; }; 31FF1DB1255FA383000EF4B0 /* Stripe.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04E6FD061B714DDF000C8759 /* Stripe.xcframework */; }; 31FF1DB2255FA383000EF4B0 /* Stripe.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 04E6FD061B714DDF000C8759 /* Stripe.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + E6F05EAA2687C76F00614D61 /* StripeCore.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E6F05EA92687C76F00614D61 /* StripeCore.xcframework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -55,6 +56,7 @@ 04E6FCFC1B714AC2000C8759 /* CarthageTestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarthageTestTests.swift; sourceTree = ""; }; 04E6FD061B714DDF000C8759 /* Stripe.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Stripe.xcframework; path = Carthage/Build/Stripe.xcframework; sourceTree = ""; }; 31CA744A25CCC669007FE8BF /* Stripe3DS2.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Stripe3DS2.xcframework; path = Carthage/Build/Stripe3DS2.xcframework; sourceTree = ""; }; + E6F05EA92687C76F00614D61 /* StripeCore.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = StripeCore.xcframework; path = Carthage/Build/StripeCore.xcframework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -63,6 +65,7 @@ buildActionMask = 2147483647; files = ( 31FF1DB1255FA383000EF4B0 /* Stripe.xcframework in Frameworks */, + E6F05EAA2687C76F00614D61 /* StripeCore.xcframework in Frameworks */, 31CA744B25CCC669007FE8BF /* Stripe3DS2.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -139,6 +142,7 @@ isa = PBXGroup; children = ( 31CA744A25CCC669007FE8BF /* Stripe3DS2.xcframework */, + E6F05EA92687C76F00614D61 /* StripeCore.xcframework */, ); name = Frameworks; sourceTree = ""; diff --git a/Tests/installation_tests/cocoapods/with_frameworks_objc/Podfile b/Tests/installation_tests/cocoapods/with_frameworks_objc/Podfile index a3aa57d8d6..ef9673efba 100644 --- a/Tests/installation_tests/cocoapods/with_frameworks_objc/Podfile +++ b/Tests/installation_tests/cocoapods/with_frameworks_objc/Podfile @@ -4,6 +4,7 @@ target 'CocoapodsTest' do platform :ios, '11.0' use_frameworks! pod 'Stripe', path: '../../../..' + pod 'StripeCore', path: '../../../..' post_install do |installer| installer.pods_project.build_configurations.each do |config| diff --git a/Tests/installation_tests/cocoapods/with_frameworks_swift/Podfile b/Tests/installation_tests/cocoapods/with_frameworks_swift/Podfile index a3aa57d8d6..ef9673efba 100644 --- a/Tests/installation_tests/cocoapods/with_frameworks_swift/Podfile +++ b/Tests/installation_tests/cocoapods/with_frameworks_swift/Podfile @@ -4,6 +4,7 @@ target 'CocoapodsTest' do platform :ios, '11.0' use_frameworks! pod 'Stripe', path: '../../../..' + pod 'StripeCore', path: '../../../..' post_install do |installer| installer.pods_project.build_configurations.each do |config| diff --git a/Tests/installation_tests/cocoapods/without_frameworks_objc/Podfile b/Tests/installation_tests/cocoapods/without_frameworks_objc/Podfile index 4b542cbd3e..5b407b0a52 100644 --- a/Tests/installation_tests/cocoapods/without_frameworks_objc/Podfile +++ b/Tests/installation_tests/cocoapods/without_frameworks_objc/Podfile @@ -1,6 +1,7 @@ target 'CocoapodsTest' do pod 'Stripe', path: '../../../..' + pod 'StripeCore', path: '../../../..' post_install do |installer| installer.pods_project.build_configurations.each do |config| diff --git a/ci_scripts/build_documentation.sh b/ci_scripts/build_documentation.sh index 9ccfce9a9a..a6ab16b97f 100755 --- a/ci_scripts/build_documentation.sh +++ b/ci_scripts/build_documentation.sh @@ -29,6 +29,15 @@ if [[ "${jazzy_version_local}" != "${jazzy_version_remote}" ]]; then die "Please update jazzy: \`gem update jazzy\`" fi +# Create temp podspec directory +temp_spec_dir="$(/bin/bash "$script_dir/make_temp_spec_repo.sh")" +make_dir_status=$? + +if [ $make_dir_status -ne 0 ]; then + die "$temp_spec_dir" +fi +echo "Sucessfully created podspec repo at \`$temp_spec_dir\`" + # Execute jazzy release_version="$(cat "${script_dir}/../VERSION")" @@ -36,7 +45,11 @@ info "Executing jazzy..." jazzy \ --config "${script_dir}/../.jazzy.yaml" \ --github-file-prefix "https://github.com/stripe/stripe-ios/tree/${release_version}" \ - --podspec Stripe.podspec + --podspec Stripe.podspec \ + --pod-sources "file://$temp_spec_dir" + +# Cleanup temp podspec directory +rm -rf "$temp_spec_dir" # Verify jazzy exit code jazzy_exit_code="$?" diff --git a/ci_scripts/make_temp_spec_repo.sh b/ci_scripts/make_temp_spec_repo.sh new file mode 100755 index 0000000000..e7126162ad --- /dev/null +++ b/ci_scripts/make_temp_spec_repo.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# This script is used from `build_documentation.sh` as a workaround for a jazzy +# limitation so we can specify pod dependencies using the local source directory. +# It creates a temp git repo mimicing the directory structure of a pod spec +# repo containing modified versions of our *.podspec files which use a local +# file:// URL as their source. It prints the resulting directory path which is +# passed to jazzy as its `--pod-sources` argument. +# +# Note: The temporary directory should be deleted after it's finished being used. + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +root_dir="$(realpath "${script_dir}/../")" + +release_version="$(cat "${root_dir}/VERSION")" + +# Create temp podspec directory +temp_spec_dir="$(mktemp -d)" + +# Copy and modify each podspec +for podspec in ${root_dir}/*.podspec +do + # Extract the name of the pod + filename="$(basename $podspec)" + podname="${filename%.*}" + + # Create expected directory structure for .podspec file + mkdir "$temp_spec_dir/$podname" + mkdir "$temp_spec_dir/$podname/$release_version" + + # Replace the s.source with file:// URL pointing to root_dir + cat $podspec \ + | sed -E "s|(s\.source *= *)\{(.*)\}|\1\{ :git => 'file://$root_dir' \}|" \ + > "$temp_spec_dir/$podname/$release_version/$filename" +done + +# Cocoapods needs this directory to be a git repo so it can clone it +cd "$temp_spec_dir" +git init -q > /dev/null +git add . > /dev/null +git commit -m "initial commit" > /dev/null + +# print dir path when we're done +echo $temp_spec_dir