Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Swift Package Manager #1644

Merged
merged 3 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ xcuserdata/
jazzy
jazzy/*
docs/docs/undocumented.json

.build
.swiftpm
6 changes: 3 additions & 3 deletions .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
output: docs/docs
clean: true
objc: true
umbrella_header: Stripe/PublicHeaders/Stripe.h
umbrella_header: Stripe/PublicHeaders/Stripe/Stripe.h
framework_root: .
sdk: iphonesimulator
author: Stripe
Expand All @@ -15,5 +15,5 @@ skip_undocumented: true
hide_documentation_coverage: true
theme: fullwidth
exclude:
- Stripe/PublicHeaders/STD*
- Stripe/PublicHeaders/Stripe3DS2.h
- Stripe/PublicHeaders/Stripe/STD*
- Stripe/PublicHeaders/Stripe/Stripe3DS2.h
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ matrix:
- name: legacy-tests-11
env: TEST_TYPE=legacy-tests-11
osx_image: xcode11.6
osx_image: xcode11.6
- name: installation_spm
env: TEST_TYPE=installation_spm
osx_image: xcode12

before_install:
- SIMULATOR_ID=$(xcrun instruments -s | grep -o "iPhone 6 (11.4) \[.*\]" | grep -o
Expand All @@ -55,4 +59,5 @@ script:
- '[ "$TEST_TYPE" != installation_cocoapods_frameworks_objc ] || ./Tests/installation_tests/cocoapods/with_frameworks_objc/test.sh'
- '[ "$TEST_TYPE" != installation_cocoapods_frameworks_swift ] || ./Tests/installation_tests/cocoapods/with_frameworks_swift/test.sh'
- '[ "$TEST_TYPE" != installation_carthage ] || ./Tests/installation_tests/carthage/test.sh'
- '[ "$TEST_TYPE" != installation_spm ] || ./Tests/installation_tests/swift_package_manager/test.sh'
- '[ "$TEST_TYPE" != documentation ] || ./ci_scripts/check_documentation.sh'
4 changes: 2 additions & 2 deletions FauxPasConfig/main.fauxpas.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Generated from the Faux Pas GUI
{
// Xcode target to check (String)
"target": "StripeiOSStatic",
"target": "StripeiOS",
// Xcode build configuration to check (String)
"buildConfig": "Release",
// Rules to apply (Array of strings)
Expand Down Expand Up @@ -481,7 +481,7 @@
"UnusedResource": {
// Regexes for ignored file paths (Array of regular expression
// strings)
"ignoredFileRegexes": ["integrate-dynamic-framework.sh"]
"ignoredFileRegexes": []
},
// Options for rule: Potential assertion side effects
"AssertionSideEffects": {
Expand Down
6 changes: 5 additions & 1 deletion MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Migration Guides

### Migrating from versions < 20.0.0
* The minimum iOS version is now 11.0. If you'd like to deploy for iOS 10.0, please use Stripe SDK 19.4.0.
* The recommended package manager is now Swift Package Manager, though we continue to support Cocoapods and Carthage.

### Migrating from versions < 19.4.0
* `metadata` fields are no longer populated on retrieved Stripe API objects and must be fetched on your server using your secret key. If this is causing issues with your deployed app versions please reach out to [Stripe Support](https://support.stripe.com/?contact=true). These fields have been marked as deprecated and will be removed in a future SDK version.

Expand Down Expand Up @@ -237,7 +241,7 @@ STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:publishableK

### Handling errors

See [StripeError.h](https://github.com/stripe/stripe-ios/blob/master/Stripe/PublicHeaders/StripeError.h) for a list of error codes that may be returned from the Stripe API.
See [StripeError.h](https://github.com/stripe/stripe-ios/blob/master/Stripe/PublicHeaders/Stripe/StripeError.h) for a list of error codes that may be returned from the Stripe API.

### Validating STPCards

Expand Down
40 changes: 40 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// swift-tools-version:5.3
import PackageDescription

let package = Package(
name: "Stripe",
defaultLocalization: "en",
platforms: [
.iOS(.v11)
],
products: [
.library(
name: "Stripe",
type: .dynamic,
targets: ["Stripe"]
),
],
targets: [
.target(
name: "Stripe",
dependencies: ["Stripe3DS2"],
path: "Stripe",
exclude: ["BuildConfigurations", "Info.plist", "PublicHeaders/Stripe/Stripe3DS2-Prefix.pch"],
resources: [
.process("Info.plist"),
.process("Resources/Images"),
.process("Resources/au_becs_bsb.json"),
.process("ExternalResources/Stripe3DS2.bundle"),
],
publicHeadersPath: "PublicHeaders",
cSettings: [
.headerSearchPath("."),
.headerSearchPath("PublicHeaders/Stripe"),
]
),
.binaryTarget(
name: "Stripe3DS2",
url: "https://github.com/stripe-ios/stripe-3ds2-ios-releases/releases/download/v19.9.9/Stripe3DS2.xcframework.zip",
checksum: "2efb524df2480cb9d23dafe4b5e9cb0f91440e7d5d8b94fc1ea4c0a6c969f579"),
]
)
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,19 @@ From left to right: [STPAddCardViewController](https://stripe.dev/stripe-ios/doc

## Releases

We recommend installing the Stripe iOS SDK using a package manager such as Cocoapods or Carthage. If you link the library manually, use a version from our [releases](https://github.com/stripe/stripe-ios/releases) page.
We recommend installing the Stripe iOS SDK using Swift Package Manager. (File -> Swift Packages -> Add Package Dependency… in Xcode.) We also support Cocoapods and Carthage. If you link the library manually, use a version from our [releases](https://github.com/stripe/stripe-ios/releases) page.

If you're reading this on GitHub.com, please make sure you are looking at the [tagged version](https://github.com/stripe/stripe-ios/tags) that corresponds to the release you have installed. Otherwise, the instructions and example code may be mismatched with your copy. You can read the latest tagged version of this README and browse the associated code on GitHub using
[this link](https://github.com/stripe/stripe-ios/tree/v19.4.0).

## Requirements

The Stripe iOS SDK requires Xcode 10.1 or later and is compatible with apps targeting iOS 10 or above. Please use [v17.0.2](https://github.com/stripe/stripe-ios/tree/v17.0.2) if you need to support iOS 9.
The Stripe iOS SDK requires Xcode 11.6 or later and is compatible with apps targeting iOS 11 or above. Please use [v19.4.0](https://github.com/stripe/stripe-ios/tree/v19.4.0) if you need to support iOS 10 or [v17.0.2](https://github.com/stripe/stripe-ios/tree/v17.0.2) if you need to support iOS 9.

## Getting Started

### Integration


Get started with our [📚 integration guides](https://stripe.com/docs/payments) and [example projects](#examples), or [📘 browse the SDK reference](https://stripe.dev/stripe-ios/docs/index.html) for fine-grained documentation of all the classes and methods in the SDK.

### Examples
Expand All @@ -93,6 +92,10 @@ Check out [stripe-samples](https://github.com/stripe-samples/) for more, includi

To add card scanning capabilities to our prebuilt UI components, set the `cardScanningEnabled` option on your `STPPaymentConfiguration`. You'll also need to set `NSCameraUsageDescription` in your application's plist, and provide a reason for accessing the camera (e.g. "To scan cards"). Card scanning is supported on devices with iOS 13 or higher.

<p align="center">
<img src="https://user-images.githubusercontent.com/52758633/92628867-4d040200-f282-11ea-95d2-023d9a461d25.gif" width="222" height="458" alt="Card Scanning Demo" align="center">
</p>

Demo this in our [Basic Integration example app](https://github.com/stripe/stripe-ios/tree/v19.4.0/Example/Basic%20Integration). When you run the example app on a device, you'll see a "Scan Card" button when adding a new card.

This feature is currently in beta. Please file bugs on our [GitHub issues page](https://github.com/stripe/stripe-ios/issues).
Expand Down
2 changes: 1 addition & 1 deletion STYLEGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static NSString * const STPSDKVersion = @"11.0.0";
- `stripe-ios/Example/Basic Integration/`
- `stripe-ios/Example/Non-Card Payment Examples/`

- Save public header files in `stripe-ios/Stripe/PublicHeaders/` for Cocoapods compatibility
- Save public header files in `stripe-ios/Stripe/PublicHeaders/` for Cocoapods and Swift Package Manager compatibility

## Design Patterns

Expand Down
6 changes: 3 additions & 3 deletions Stripe.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.platform = :ios
s.ios.deployment_target = '11.0'
s.public_header_files = 'Stripe/PublicHeaders/*.h'
s.source_files = 'Stripe/PublicHeaders/*.h', 'Stripe/*.{h,m}', 'Stripe/Payments/*.{h,m}'
s.public_header_files = 'Stripe/PublicHeaders/Stripe/*.h'
s.source_files = 'Stripe/PublicHeaders/Stripe/*.h', 'Stripe/*.{h,m}'
s.vendored_libraries = 'InternalFrameworks/libStripe3DS2.a'
s.ios.resource_bundle = { 'Stripe' => 'Stripe/Resources/**/*.{lproj,json,png,xcassets}' }
s.ios.resources = "InternalFrameworks/Stripe3DS2.bundle"
s.ios.resources = "Stripe/ExternalResources/Stripe3DS2.bundle"
s.xcconfig = {
"OTHER_LDFLAGS" => "$(inherited) -ObjC"
}
Expand Down
Loading