Skip to content

Commit

Permalink
Merge pull request #10 from square/converge/2.0.0-beta2
Browse files Browse the repository at this point in the history
2.0.0-beta2 release
  • Loading branch information
brandonjenniges authored Aug 23, 2024
2 parents 6445564 + 13de320 commit 56356e1
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.build
Binary file modified Docs/MobilePaymentsSDK_DocC.zip
Binary file not shown.
8 changes: 2 additions & 6 deletions MockReaderUI.podspec
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
Pod::Spec.new do |s|
s.name = 'MockReaderUI'
s.version = '2.0.0-beta1'
s.version = '2.0.0-beta2'
s.license = {:type=>"Square Developer License", :text=>"Copyright (c) 2020-present, Square, Inc. All rights reserved.\n\nYour use of this software is subject to the Square Developer Terms of\nService (https://squareup.com/legal/developers). This copyright notice shall\nbe included in all copies or substantial portions of the software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"}
s.homepage = 'https://github.com/square/mobile-payments-sdk-ios'
s.authors = 'Square'
s.summary = 'Enables developers to build use mock readers for testing the MobilePaymentsSDK'

s.ios.deployment_target = '15.0'

s.source ={ :git => "https://github.com/square/mobile-payments-sdk-ios.git" , :tag => "2.0.0-beta1" }

s.source ={ :http => "https://d3eygymyzkbhx3.cloudfront.net/mpsdk/2.0.0-beta2/MockReaderUI_b854a2f0e98b.zip" }
s.vendored_frameworks = 'MockReaderUI.xcframework'
s.prepare_command = <<-CMD
unzip XCFrameworks/MockReaderUI_6432c60c8568.zip
CMD

end
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ let package = Package(
targets: [
.binaryTarget(
name: "SquareMobilePaymentsSDK",
path: "XCFrameworks/SquareMobilePaymentsSDK_6432c60c8568.zip"
url: "https://d3eygymyzkbhx3.cloudfront.net/mpsdk/2.0.0-beta2/SquareMobilePaymentsSDK_b854a2f0e98b.zip",
checksum: "0b7b6244183048b49cc8d392e6127bb5cf59bfc23de23b2715db7b51146fab15"
),
.binaryTarget(
name: "MockReaderUI",
path: "XCFrameworks/MockReaderUI_6432c60c8568.zip"
url: "https://d3eygymyzkbhx3.cloudfront.net/mpsdk/2.0.0-beta2/MockReaderUI_b854a2f0e98b.zip",
checksum: "4e22f18fe259e2e490d04f2c2e422415188469aae06185f6268dc9ded353707e"
),
]
)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Install with [Swift Package Manager](https://www.swift.org/documentation/package

1. Select `File > Add Package Dependencies...`.
2. Enter the repository URL: `https://github.com/square/mobile-payments-sdk-ios`.
3. Select the `Exact Version` dependency rule and specify the version as `2.0.0-beta1`.
3. Select the `Exact Version` dependency rule and specify the version as `2.0.0-beta2`.
4. Ensure the `SquareMobilePaymentsSDK` product is added to your target.

Optionally, you can also add the `MockReaderUI` product to your target to simulate a physical reader when one is not present in a sandbox environment.
Expand All @@ -29,11 +29,11 @@ Install with [CocoaPods](http://cocoapods.org/) by adding the following to your
```
use_frameworks!
pod "SquareMobilePaymentsSDK", "~> 2.0.0-beta1"
pod "SquareMobilePaymentsSDK", "~> 2.0.0-beta2"
# Optionally include MockReaderUI if you wish to simulate a physical reader when one is not present.
# This feature is only available when provided a sandbox application ID.
pod "MockReaderUI", "~> 2.0.0-beta1", configurations: ['Debug']
pod "MockReaderUI", "~> 2.0.0-beta2", configurations: ['Debug']
```
_Note that MockReaderUI framework **requires** the `SquareMobilePaymentsSDK` framework to also be present in your `Podfile`._

Expand Down
5 changes: 3 additions & 2 deletions Scripts/sdk_constants.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module SquareMobilePaymentsSDK
VERSION = '2.0.0-beta1'
COMMIT_SHA = '6432c60c8568'
VERSION = '2.0.0-beta2'
COMMIT_SHA = 'b854a2f0e98b'
CLOUDFRONT_DOMAIN = 'd3eygymyzkbhx3.cloudfront.net'
LICENSE_TYPE = 'Square Developer License'
LICENSE_TEXT = <<-LICENSE
Copyright (c) 2020-present, Square, Inc. All rights reserved.
Expand Down
57 changes: 56 additions & 1 deletion Scripts/sdk_utilities.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
require 'erb'
require 'fileutils'
require 'open3'
require 'net/http'
require 'uri'
require 'digest'

class TemplateBuilder
def initialize(version, commit_sha, license, homepage_url, authors, ios_deployment_target)
def initialize(version, commit_sha, license, homepage_url, authors, ios_deployment_target, cloudfront_domain)
@version = version
@commit_sha = commit_sha
@license = license
@homepage_url = homepage_url
@authors = authors
@ios_deployment_target = ios_deployment_target
@cloudfront_domain = cloudfront_domain
@sdk_checksum, @mock_reader_checksum = checksums(@cloudfront_domain, @version, @commit_sha)
end

def build_and_write(template_path, file_name, output_dir)
Expand All @@ -20,6 +25,10 @@ def build_and_write(template_path, file_name, output_dir)
file.write(result)
end
end

def checksums(cloudfront_domain, version, commit_sha)
SdkDownloader.download_and_return_checksum(cloudfront_domain, version, commit_sha)
end
end

class CommandExecutor
Expand All @@ -43,3 +52,49 @@ def self.compare(file1_path, file2_path)
return true
end
end

class SdkDownloader
class << self
def download_and_return_checksum(cloudfront_domain, version, commit_sha)
sdk_url = "https://#{cloudfront_domain}/mpsdk/#{version}/SquareMobilePaymentsSDK_#{commit_sha}.zip"
mock_reader_url = "https://#{cloudfront_domain}/mpsdk/#{version}/MockReaderUI_#{commit_sha}.zip"

self.http_download(sdk_url)
file_content = File.read("t.zip", mode: 'rb')
sdk_hash = Digest::SHA256.hexdigest(file_content)
puts "SHA-256 hash: #{sdk_hash}"

self.http_download(mock_reader_url)
file_content = File.read("t.zip", mode: 'rb')
mock_reader_hash = Digest::SHA256.hexdigest(file_content)
puts "SHA-256 hash: #{mock_reader_hash}"

FileUtils.rm("t.zip")

[sdk_hash, mock_reader_hash]
end

def http_download(uri, filename: "t.zip")
url = URI.parse(uri)
progress = 0
Net::HTTP.start(url.host, url.port, use_ssl: true) do |http|
response_for_size = http.request_head(url)
size = response_for_size['content-length'].to_f

puts "Starting download: #{uri}"
http.request_get(url.path) do |response|
# This here is only so we can show some progress, files are heavy
open(filename, 'w') do |f|
response.read_body do |chunk|
f.write chunk
progress += chunk.length
printf("\rDownloaded: %.2f%%", 100*(progress/size))
end
end

end
end
puts "\nDownload Complete"
end
end
end
8 changes: 4 additions & 4 deletions Scripts/sdk_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def self.validate_podspecs
# Runs pod spec lint validation
command = "pod spec lint"
stdout, stderr = CommandExecutor.execute(command)
stdout.scan(/^(\w+)/).flatten

# Validates output
unless stdout.include?("All the specs passed validation.")
Expand All @@ -28,10 +27,10 @@ def self.validate_spm_package
# Resolves all packages in Package.swift
command = "swift package resolve"
_stdout, stderr = CommandExecutor.execute(command)
stderr.scan(/^(\w+)/).flatten
any_errors = stderr.scan("error").flatten

# Validates output of resolve does not have errors.
unless stderr.nil? || stderr.empty?
unless any_errors.nil? || any_errors.empty?
puts "❌ SPM Package could not be validated"
puts stderr
return false
Expand Down Expand Up @@ -68,7 +67,8 @@ def self.validate_template_files
SquareMobilePaymentsSDK::LICENSE,
SquareMobilePaymentsSDK::HOMEPAGE_URL,
SquareMobilePaymentsSDK::AUTHORS,
SquareMobilePaymentsSDK::IOS_DEPLOYMENT_TARGET
SquareMobilePaymentsSDK::IOS_DEPLOYMENT_TARGET,
SquareMobilePaymentsSDK::CLOUDFRONT_DOMAIN
)

files_to_test = [
Expand Down
6 changes: 1 addition & 5 deletions Scripts/templates/MockReaderUI.podspec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ Pod::Spec.new do |s|

s.ios.deployment_target = '<%= @ios_deployment_target %>'

s.source ={ :git => "https://github.com/square/mobile-payments-sdk-ios.git" , :tag => "<%= @version %>" }

s.source ={ :http => "https://<%= @cloudfront_domain %>/mpsdk/<%= @version %>/MockReaderUI_<%= @commit_sha %>.zip" }
s.vendored_frameworks = 'MockReaderUI.xcframework'
s.prepare_command = <<-CMD
unzip XCFrameworks/MockReaderUI_<%= @commit_sha %>.zip
CMD

end
6 changes: 4 additions & 2 deletions Scripts/templates/Package.swift.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ let package = Package(
targets: [
.binaryTarget(
name: "SquareMobilePaymentsSDK",
path: "XCFrameworks/SquareMobilePaymentsSDK_<%= @commit_sha %>.zip"
url: "https://<%= @cloudfront_domain %>/mpsdk/<%= @version %>/SquareMobilePaymentsSDK_<%= @commit_sha %>.zip",
checksum: "<%= @sdk_checksum %>"
),
.binaryTarget(
name: "MockReaderUI",
path: "XCFrameworks/MockReaderUI_<%= @commit_sha %>.zip"
url: "https://<%= @cloudfront_domain %>/mpsdk/<%= @version %>/MockReaderUI_<%= @commit_sha %>.zip",
checksum: "<%= @mock_reader_checksum %>"
),
]
)
6 changes: 1 addition & 5 deletions Scripts/templates/SquareMobilePaymentsSDK.podspec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ Pod::Spec.new do |s|

s.ios.deployment_target = '<%= @ios_deployment_target %>'

s.source ={ :git => "https://github.com/square/mobile-payments-sdk-ios.git", :tag => "<%= @version %>" }

s.source ={ :http => "https://<%= @cloudfront_domain %>/mpsdk/<%= @version %>/SquareMobilePaymentsSDK_<%= @commit_sha %>.zip" }
s.vendored_frameworks = 'SquareMobilePaymentsSDK.xcframework'
s.prepare_command = <<-CMD
unzip XCFrameworks/SquareMobilePaymentsSDK_<%= @commit_sha %>.zip
CMD

end
5 changes: 3 additions & 2 deletions Scripts/update-sdk-version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
SquareMobilePaymentsSDK::LICENSE,
SquareMobilePaymentsSDK::HOMEPAGE_URL,
SquareMobilePaymentsSDK::AUTHORS,
SquareMobilePaymentsSDK::IOS_DEPLOYMENT_TARGET
SquareMobilePaymentsSDK::IOS_DEPLOYMENT_TARGET,
SquareMobilePaymentsSDK::CLOUDFRONT_DOMAIN
)

# Generate README
Expand All @@ -24,4 +25,4 @@

# Generate Package.swift
template_builder.build_and_write('./Scripts/templates/Package.swift.erb', 'Package.swift', './')
puts "✅ Updated Package.swift"
puts "✅ Updated Package.swift"
8 changes: 2 additions & 6 deletions SquareMobilePaymentsSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
Pod::Spec.new do |s|
s.name = 'SquareMobilePaymentsSDK'
s.version = '2.0.0-beta1'
s.version = '2.0.0-beta2'
s.license = {:type=>"Square Developer License", :text=>"Copyright (c) 2020-present, Square, Inc. All rights reserved.\n\nYour use of this software is subject to the Square Developer Terms of\nService (https://squareup.com/legal/developers). This copyright notice shall\nbe included in all copies or substantial portions of the software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"}
s.homepage = 'https://github.com/square/mobile-payments-sdk-ios'
s.authors = 'Square'
s.summary = 'Enables developers to build secure in-person payment solutions'

s.ios.deployment_target = '15.0'

s.source ={ :git => "https://github.com/square/mobile-payments-sdk-ios.git", :tag => "2.0.0-beta1" }

s.source ={ :http => "https://d3eygymyzkbhx3.cloudfront.net/mpsdk/2.0.0-beta2/SquareMobilePaymentsSDK_b854a2f0e98b.zip" }
s.vendored_frameworks = 'SquareMobilePaymentsSDK.xcframework'
s.prepare_command = <<-CMD
unzip XCFrameworks/SquareMobilePaymentsSDK_6432c60c8568.zip
CMD

end
Binary file removed XCFrameworks/MockReaderUI_6432c60c8568.zip
Binary file not shown.
Binary file not shown.

0 comments on commit 56356e1

Please sign in to comment.