Skip to content

[in_app_purchase_storekit] Add Swift Package Manager compatibility #8469

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

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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.21

* Adds Swift Package Manager compatibility.

## 0.3.20+4

* Exposes `jsonRepresentation` field for transactions.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ Downloaded by pub (not CocoaPods).
# Updating it before the package is published will cause a lint error and block the tree.
s.documentation_url = 'https://pub.dev/packages/in_app_purchase'
s.swift_version = '5.0'
s.source_files = 'Classes/**/*.{h,m,swift}'
s.public_header_files = 'Classes/**/*.h'
s.source_files = 'in_app_purchase_storekit/Sources/**/*.{h,m,swift}'
s.public_header_files = 'in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/include/**/*.h'

s.ios.dependency 'Flutter'
s.osx.dependency 'FlutterMacOS'
s.ios.deployment_target = '12.0'
s.osx.deployment_target = '10.15'

s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.resource_bundles = {'in_app_purchase_storekit_privacy' => ['Resources/PrivacyInfo.xcprivacy']}
s.resource_bundles = {'in_app_purchase_storekit_privacy' => ['in_app_purchase_storekit/Sources/in_app_purchase_storekit/Resources/PrivacyInfo.xcprivacy']}
s.xcconfig = {
'LIBRARY_SEARCH_PATHS' => '$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)/ $(SDKROOT)/usr/lib/swift',
'LD_RUNPATH_SEARCH_PATHS' => '/usr/lib/swift',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import PackageDescription

let package = Package(
name: "in_app_purchase_storekit",
platforms: [
.iOS(.v12),
.macOS(.v10_15),
],
products: [
.library(name: "in-app-purchase-storekit", targets: ["in_app_purchase_storekit"])
],
dependencies: [],
targets: [
.target(
name: "in_app_purchase_storekit",
dependencies: [
"in_app_purchase_storekit_objc"
],
resources: [
.process("Resources/PrivacyInfo.xcprivacy")
]
),
.target(
name: "in_app_purchase_storekit_objc",
dependencies: [],
publicHeadersPath: "include/in_app_purchase_storekit_objc",
cSettings: [
.headerSearchPath("include/in_app_purchase_storekit_objc")
]
),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import Foundation
import StoreKit

#if canImport(in_app_purchase_storekit_objc)
import in_app_purchase_storekit_objc
#endif

#if os(iOS)
import Flutter
#elseif os(macOS)
Expand Down Expand Up @@ -241,7 +245,7 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI {

// TODO(louisehsu): This is a workaround for objc pigeon's NSNull support. Once we move to swift pigeon, this can be removed.
let castedFinishMap: [String: String] = finishMap.compactMapValues { value in
if let _ = value as? NSNull {
if value as? NSNull != nil {
return nil
} else if let stringValue = value as? String {
return stringValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import StoreKit

@available(iOS 15.0, macOS 12.0, *)
extension InAppPurchasePlugin: InAppPurchase2API {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v22.6.0), do not edit directly.
// Autogenerated from Pigeon (v22.7.3), do not edit directly.
// See also: https://pub.dev/packages/pigeon

import Foundation
Expand Down Expand Up @@ -392,7 +392,7 @@ struct SK2ErrorMessage {
}
}

private class sk2_pigeonPigeonCodecReader: FlutterStandardReader {
private class Sk2PigeonPigeonCodecReader: FlutterStandardReader {
override func readValue(ofType type: UInt8) -> Any? {
switch type {
case 129:
Expand Down Expand Up @@ -447,7 +447,7 @@ private class sk2_pigeonPigeonCodecReader: FlutterStandardReader {
}
}

private class sk2_pigeonPigeonCodecWriter: FlutterStandardWriter {
private class Sk2PigeonPigeonCodecWriter: FlutterStandardWriter {
override func writeValue(_ value: Any) {
if let value = value as? SK2ProductTypeMessage {
super.writeByte(129)
Expand Down Expand Up @@ -494,18 +494,18 @@ private class sk2_pigeonPigeonCodecWriter: FlutterStandardWriter {
}
}

private class sk2_pigeonPigeonCodecReaderWriter: FlutterStandardReaderWriter {
private class Sk2PigeonPigeonCodecReaderWriter: FlutterStandardReaderWriter {
override func reader(with data: Data) -> FlutterStandardReader {
return sk2_pigeonPigeonCodecReader(data: data)
return Sk2PigeonPigeonCodecReader(data: data)
}

override func writer(with data: NSMutableData) -> FlutterStandardWriter {
return sk2_pigeonPigeonCodecWriter(data: data)
return Sk2PigeonPigeonCodecWriter(data: data)
}
}

class sk2_pigeonPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
static let shared = sk2_pigeonPigeonCodec(readerWriter: sk2_pigeonPigeonCodecReaderWriter())
class Sk2PigeonPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
static let shared = Sk2PigeonPigeonCodec(readerWriter: Sk2PigeonPigeonCodecReaderWriter())
}

/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
Expand All @@ -525,11 +525,11 @@ protocol InAppPurchase2API {

/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
class InAppPurchase2APISetup {
static var codec: FlutterStandardMessageCodec { sk2_pigeonPigeonCodec.shared }
static var codec: FlutterStandardMessageCodec { Sk2PigeonPigeonCodec.shared }
/// Sets up an instance of `InAppPurchase2API` to handle messages through the `binaryMessenger`.
static func setUp(
binaryMessenger: FlutterBinaryMessenger,
api: InAppPurchase2API?, messageChannelSuffix: String = ""
binaryMessenger: FlutterBinaryMessenger, api: InAppPurchase2API?,
messageChannelSuffix: String = ""
) {
let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
let canMakePaymentsChannel = FlutterBasicMessageChannel(
Expand Down Expand Up @@ -691,8 +691,8 @@ class InAppPurchase2CallbackAPI: InAppPurchase2CallbackAPIProtocol {
self.binaryMessenger = binaryMessenger
self.messageChannelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
}
var codec: sk2_pigeonPigeonCodec {
return sk2_pigeonPigeonCodec.shared
var codec: Sk2PigeonPigeonCodec {
return Sk2PigeonPigeonCodec.shared
}
func onTransactionsUpdated(
newTransactions newTransactionsArg: [SK2TransactionMessage],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FIAObjectTranslator.h"
#import "./include/in_app_purchase_storekit_objc/FIAObjectTranslator.h"

#pragma mark - SKProduct Coders

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FIAPPaymentQueueDelegate.h"
#import "FIAObjectTranslator.h"
#import "./include/in_app_purchase_storekit_objc/FIAPPaymentQueueDelegate.h"
#import "./include/in_app_purchase_storekit_objc/FIAObjectTranslator.h"

@interface FIAPPaymentQueueDelegate ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FIAPReceiptManager.h"
#import "./include/in_app_purchase_storekit_objc/FIAPReceiptManager.h"

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif
#import "FIAObjectTranslator.h"
#import "./include/in_app_purchase_storekit_objc/FIAObjectTranslator.h"

@interface FIAPReceiptManager ()
// Gets the receipt file data from the location of the url. Can be nil if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FIAPRequestHandler.h"
#import "./include/in_app_purchase_storekit_objc/FIAPRequestHandler.h"
#import <StoreKit/StoreKit.h>

#pragma mark - Main Handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FIAPaymentQueueHandler.h"
#import "FIAPPaymentQueueDelegate.h"
#import "FIATransactionCache.h"
#import "./include/in_app_purchase_storekit_objc/FIAPaymentQueueHandler.h"
#import "./include/in_app_purchase_storekit_objc/FIAPPaymentQueueDelegate.h"
#import "./include/in_app_purchase_storekit_objc/FIATransactionCache.h"

@interface FIAPaymentQueueHandler ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FIATransactionCache.h"
#import "./include/in_app_purchase_storekit_objc/FIATransactionCache.h"

@interface FIATransactionCache ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FLTMethodChannelProtocol.h"
#import "../include/in_app_purchase_storekit_objc/FLTMethodChannelProtocol.h"

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

@interface DefaultMethodChannel ()
/// The wrapped FlutterMethodChannel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FLTPaymentQueueProtocol.h"
#import "../include/in_app_purchase_storekit_objc/FLTPaymentQueueProtocol.h"

@interface DefaultPaymentQueue ()
/// The wrapped SKPaymentQueue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FLTRequestHandlerProtocol.h"
#import "../include/in_app_purchase_storekit_objc/FLTRequestHandlerProtocol.h"
#import <Foundation/Foundation.h>
#import "FIAPRequestHandler.h"
#import "../include/in_app_purchase_storekit_objc/FIAPRequestHandler.h"

@interface DefaultRequestHandler ()
/// The wrapped FIAPRequestHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "FLTTransactionCacheProtocol.h"
#import "../include/in_app_purchase_storekit_objc/FLTTransactionCacheProtocol.h"

@interface DefaultTransactionCache ()
/// The wrapped FIATransactionCache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Foundation/Foundation.h>

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
#import "FLTMethodChannelProtocol.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <FLTRequestHandlerProtocol.h>
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
#import "FLTRequestHandlerProtocol.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, TransactionCacheKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Foundation/Foundation.h>

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <TargetConditionals.h>
#import "FIATransactionCache.h"

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v22.6.0), do not edit directly.
// Autogenerated from Pigeon (v22.7.3), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>
Expand Down Expand Up @@ -67,8 +67,7 @@ typedef NS_ENUM(NSUInteger, FIASKProductDiscountTypeMessage) {
typedef NS_ENUM(NSUInteger, FIASKProductDiscountPaymentModeMessage) {
/// Allows user to pay the discounted price at each payment period.
FIASKProductDiscountPaymentModeMessagePayAsYouGo = 0,
/// Allows user to pay the discounted price upfront and receive the product
/// for the rest of time
/// Allows user to pay the discounted price upfront and receive the product for the rest of time
/// that was paid for.
FIASKProductDiscountPaymentModeMessagePayUpFront = 1,
/// User pays nothing during the discounted period.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v22.6.0), do not edit directly.
// Autogenerated from Pigeon (v22.7.3), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import "messages.g.h"
#import "./include/in_app_purchase_storekit_objc/messages.g.h"

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
Expand Down
Loading
Loading