Add support for Swift Package Manager

This commit is contained in:
David Estes 2020-09-11 16:29:53 -07:00
parent b9c33a6829
commit da3e2568c3
493 changed files with 2447 additions and 3012 deletions

3
.gitignore vendored
View File

@ -32,3 +32,6 @@ xcuserdata/
jazzy jazzy
jazzy/* jazzy/*
docs/docs/undocumented.json docs/docs/undocumented.json
.build
.swiftpm

View File

@ -3,7 +3,7 @@
output: docs/docs output: docs/docs
clean: true clean: true
objc: true objc: true
umbrella_header: Stripe/PublicHeaders/Stripe.h umbrella_header: Stripe/PublicHeaders/Stripe/Stripe.h
framework_root: . framework_root: .
sdk: iphonesimulator sdk: iphonesimulator
author: Stripe author: Stripe
@ -15,5 +15,5 @@ skip_undocumented: true
hide_documentation_coverage: true hide_documentation_coverage: true
theme: fullwidth theme: fullwidth
exclude: exclude:
- Stripe/PublicHeaders/STD* - Stripe/PublicHeaders/Stripe/STD*
- Stripe/PublicHeaders/Stripe3DS2.h - Stripe/PublicHeaders/Stripe/Stripe3DS2.h

View File

@ -34,6 +34,10 @@ matrix:
- name: legacy-tests-11 - name: legacy-tests-11
env: TEST_TYPE=legacy-tests-11 env: TEST_TYPE=legacy-tests-11
osx_image: xcode11.6 osx_image: xcode11.6
osx_image: xcode11.6
- name: installation_spm
env: TEST_TYPE=installation_spm
osx_image: xcode12
before_install: before_install:
- SIMULATOR_ID=$(xcrun instruments -s | grep -o "iPhone 6 (11.4) \[.*\]" | grep -o - SIMULATOR_ID=$(xcrun instruments -s | grep -o "iPhone 6 (11.4) \[.*\]" | grep -o
@ -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_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_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_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' - '[ "$TEST_TYPE" != documentation ] || ./ci_scripts/check_documentation.sh'

View File

@ -1,7 +1,7 @@
// Generated from the Faux Pas GUI // Generated from the Faux Pas GUI
{ {
// Xcode target to check (String) // Xcode target to check (String)
"target": "StripeiOSStatic", "target": "StripeiOS",
// Xcode build configuration to check (String) // Xcode build configuration to check (String)
"buildConfig": "Release", "buildConfig": "Release",
// Rules to apply (Array of strings) // Rules to apply (Array of strings)
@ -481,7 +481,7 @@
"UnusedResource": { "UnusedResource": {
// Regexes for ignored file paths (Array of regular expression // Regexes for ignored file paths (Array of regular expression
// strings) // strings)
"ignoredFileRegexes": ["integrate-dynamic-framework.sh"] "ignoredFileRegexes": []
}, },
// Options for rule: Potential assertion side effects // Options for rule: Potential assertion side effects
"AssertionSideEffects": { "AssertionSideEffects": {

View File

@ -1,5 +1,9 @@
## Migration Guides ## 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 ### 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. * `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.
@ -237,7 +241,7 @@ STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:publishableK
### Handling errors ### 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 ### Validating STPCards

40
Package.swift Normal file
View File

@ -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"),
]
)

View File

@ -55,20 +55,19 @@ From left to right: [STPAddCardViewController](https://stripe.dev/stripe-ios/doc
## Releases ## 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 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). [this link](https://github.com/stripe/stripe-ios/tree/v19.4.0).
## Requirements ## 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 ## Getting Started
### Integration ### 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. 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 ### Examples
@ -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. 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. 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). This feature is currently in beta. Please file bugs on our [GitHub issues page](https://github.com/stripe/stripe-ios/issues).

View File

@ -115,7 +115,7 @@ static NSString * const STPSDKVersion = @"11.0.0";
- `stripe-ios/Example/Basic Integration/` - `stripe-ios/Example/Basic Integration/`
- `stripe-ios/Example/Non-Card Payment Examples/` - `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 ## Design Patterns

View File

@ -10,11 +10,11 @@ Pod::Spec.new do |s|
s.requires_arc = true s.requires_arc = true
s.platform = :ios s.platform = :ios
s.ios.deployment_target = '11.0' s.ios.deployment_target = '11.0'
s.public_header_files = 'Stripe/PublicHeaders/*.h' s.public_header_files = 'Stripe/PublicHeaders/Stripe/*.h'
s.source_files = 'Stripe/PublicHeaders/*.h', 'Stripe/*.{h,m}', 'Stripe/Payments/*.{h,m}' s.source_files = 'Stripe/PublicHeaders/Stripe/*.h', 'Stripe/*.{h,m}'
s.vendored_libraries = 'InternalFrameworks/libStripe3DS2.a' s.vendored_libraries = 'InternalFrameworks/libStripe3DS2.a'
s.ios.resource_bundle = { 'Stripe' => 'Stripe/Resources/**/*.{lproj,json,png,xcassets}' } 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 = { s.xcconfig = {
"OTHER_LDFLAGS" => "$(inherited) -ObjC" "OTHER_LDFLAGS" => "$(inherited) -ObjC"
} }

File diff suppressed because it is too large Load Diff

View File

@ -6,5 +6,3 @@
// //
#include "StripeiOS-Shared.xcconfig" #include "StripeiOS-Shared.xcconfig"
ENABLE_NS_ASSERTIONS = YES

View File

@ -1,116 +0,0 @@
//
// StripeiOSStatic-Shared.xcconfig
//
// Generated by BuildSettingExtractor on 4/27/15
// https://github.com/dempseyatgithub/BuildSettingExtractor
//
// Strip Debug Symbols During Copy
//
// Activating this setting causes binary files which are copied during the build (e.g.,
// in a Copy Bundle Resources or Copy Files build phase) to be stripped of debugging
// symbols. It does not cause the linked product of a target to be stripped (use Strip
// Linked Product for that).
COPY_PHASE_STRIP = NO
CLANG_CXX_LANGUAGE_STANDARD = gnu++0x
CLANG_CXX_LIBRARY = libc++
CLANG_ENABLE_MODULES = YES
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR
// Dead Code Stripping
//
// Activating this setting causes the -dead_strip flag to be passed to ld(1) via cc(1) to
// turn on dead code stripping. If this option is selected, -gfull (not -gused) must be
// used to generate debugging symbols in order to have them correctly stripped.
// [-dead_strip]
DEAD_CODE_STRIPPING = NO
GCC_TREAT_WARNINGS_AS_ERRORS = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR
GCC_WARN_SHADOW = YES
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE
CLANG_WARN_ASSIGN_ENUM = YES
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES
CLANG_WARN_INFINITE_RECURSION = YES
CLANG_WARN_SUSPICIOUS_MOVE = YES
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
GCC_WARN_UNKNOWN_PRAGMAS = YES
GCC_WARN_UNUSED_LABEL = YES
GCC_WARN_UNUSED_PARAMETER = YES
STP_EXTRA_PREPROCESSOR_MACROS = STP_STATIC_LIBRARY_BUILD
// Other Linker Flags
//
// Options defined in this setting are passed to invocations of the linker.
OTHER_LDFLAGS = $(inherited) -ObjC
// enable bitcode
ENABLE_BITCODE_iphonesimulator = NO
ENABLE_BITCODE_iphoneos = YES
ENABLE_BITCODE = $(ENABLE_BITCODE_$(PLATFORM_NAME))
OTHER_CFLAGS[sdk=iphoneos*] = $(inherited) -fembed-bitcode -Wno-error=unused-command-line-argument
// Product Name
//
// This is the basename of the product generated.
PRODUCT_NAME = Stripe
// Skip Install
//
// Activating this setting when deployment locations are used causes the product to be
// built into an alternative location instead of the install location.
SKIP_INSTALL = YES
// Strip Style
//
// Defines the level of symbol stripping to be performed on the linked product of the
// build. The default value is defined by the target's product type.
//
// All Symbols - Completely strips the binary, removing the symbol table and relocation
// information. [all, -s]
// Non-Global Symbols - Strips non-global symbols, but saves external symbols.
// [non-global, -x]
// Debugging Symbols - Strips debugging symbols, but saves local and global symbols.
// [debugging, -S]
STRIP_STYLE = non-global
FRAMEWORK_SEARCH_PATHS = $(inherited) $(PROJECT_DIR)/InternalFrameworks
HEADER_SEARCH_PATHS = $(inherited) $(PROJECT_DIR)/InternalFrameworks
LIBRARY_SEARCH_PATHS = $(inherited) $(PROJECT_DIR)/InternalFrameworks

View File

@ -1,19 +0,0 @@
//
// StripeiOSStaticFramework-Shared.xcconfig
//
// Generated by BuildSettingExtractor on 4/27/15
// https://github.com/dempseyatgithub/BuildSettingExtractor
//
GCC_TREAT_WARNINGS_AS_ERRORS = YES
GCC_WARN_SHADOW = YES
// Product Name
//
// This is the basename of the product generated.
PRODUCT_NAME = $(TARGET_NAME)

Some files were not shown because too many files have changed in this diff Show More