Skip to content

Commit dbb784d

Browse files
authored
[in_app_purchase_storekit] Suppress StoreKit 1 deprecation warnings (#13301)
StoreKit 1 is intentionally used as the fallback on iOS < 15 and macOS < 12. With `SWIFT_TREAT_WARNINGS_AS_ERRORS` enabled, the in_app_purchase_storekit_objc module is built with -Werror, so the iOS 18 deprecations of StoreKit1 in the public headers fail the build. Wrap the StoreKit 1 ObjC sources in -Wdeprecated-declarations suppression. Also wrap deprecated `Locale.currencyCode` in availability. This wasn't showing up in CI due to flutter/flutter#194517. Fixes flutter/flutter#170442 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 6fcf4b7 commit dbb784d

15 files changed

Lines changed: 98 additions & 2 deletions

File tree

‎packages/in_app_purchase/in_app_purchase_storekit/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.4.14+1
2+
3+
* Suppresses deprecation warnings for StoreKit 1 APIs, which are used as
4+
the fallback on iOS < 15 and macOS < 12.
5+
* Replaces the deprecated `Locale.currencyCode` with `Locale.currency`.
6+
17
## 0.4.14
28

39
* Adds `showManageSubscriptions` to `InAppPurchaseStoreKitPlatformAddition`, which presents the

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/StoreKit2Translators.swift‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,14 @@ extension Product.SubscriptionOffer.PaymentMode {
169169

170170
extension Locale {
171171
var convertToPigeon: SK2PriceLocaleMessage {
172+
let code: String
173+
if #available(iOS 16.0, macOS 13.0, *) {
174+
code = currency?.identifier ?? ""
175+
} else {
176+
code = currencyCode ?? ""
177+
}
172178
return SK2PriceLocaleMessage(
173-
currencyCode: currencyCode ?? "",
179+
currencyCode: code,
174180
currencySymbol: currencySymbol ?? ""
175181
)
176182
}

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/FIAObjectTranslator.m‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

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

7+
// StoreKit 1 is intentionally used as the fallback on iOS < 15 and macOS < 12,
8+
// where StoreKit 2 is unavailable. Suppress its deprecation warnings.
9+
#pragma clang diagnostic push
10+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
11+
712
#pragma mark - SKProduct Coders
813

914
@implementation FIAObjectTranslator
@@ -467,3 +472,5 @@ + (nullable FIASKProductsResponseMessage *)convertProductsResponseToPigeon:
467472
}
468473

469474
@end
475+
476+
#pragma clang diagnostic pop

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/FIAPPaymentQueueDelegate.m‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
#import "./include/in_app_purchase_storekit_objc/FIAPPaymentQueueDelegate.h"
66
#import "./include/in_app_purchase_storekit_objc/FIAObjectTranslator.h"
77

8+
// StoreKit 1 is intentionally used as the fallback on iOS < 15 and macOS < 12,
9+
// where StoreKit 2 is unavailable. Suppress its deprecation warnings.
10+
#pragma clang diagnostic push
11+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
12+
813
@interface FIAPPaymentQueueDelegate ()
914

1015
// The designated Flutter method channel that handles if a transaction should be continued
@@ -79,3 +84,5 @@ - (BOOL)paymentQueueShouldShowPriceConsent:(SKPaymentQueue *)paymentQueue {
7984
#endif
8085

8186
@end
87+
88+
#pragma clang diagnostic pop

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/FIAPRequestHandler.m‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
#import "./include/in_app_purchase_storekit_objc/FIAPRequestHandler.h"
66
#import <StoreKit/StoreKit.h>
77

8+
// StoreKit 1 is intentionally used as the fallback on iOS < 15 and macOS < 12,
9+
// where StoreKit 2 is unavailable. Suppress its deprecation warnings.
10+
#pragma clang diagnostic push
11+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
12+
813
#pragma mark - Main Handler
914

1015
@interface FIAPRequestHandler () <SKProductsRequestDelegate>
@@ -53,3 +58,5 @@ - (void)request:(SKRequest *)request didFailWithError:(NSError *)error {
5358
}
5459

5560
@end
61+
62+
#pragma clang diagnostic pop

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/FIAPaymentQueueHandler.m‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#import "./include/in_app_purchase_storekit_objc/FIAPPaymentQueueDelegate.h"
77
#import "./include/in_app_purchase_storekit_objc/FIATransactionCache.h"
88

9+
// StoreKit 1 is intentionally used as the fallback on iOS < 15 and macOS < 12,
10+
// where StoreKit 2 is unavailable. Suppress its deprecation warnings.
11+
#pragma clang diagnostic push
12+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
13+
914
@interface FIAPaymentQueueHandler ()
1015

1116
/// The SKPaymentQueue instance connected to the App Store and responsible for processing
@@ -217,3 +222,5 @@ - (SKStorefront *)storefront {
217222
}
218223

219224
@end
225+
226+
#pragma clang diagnostic pop

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/Protocols/FLTPaymentQueueProtocol.m‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

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

7+
// StoreKit 1 is intentionally used as the fallback on iOS < 15 and macOS < 12,
8+
// where StoreKit 2 is unavailable. Suppress its deprecation warnings.
9+
#pragma clang diagnostic push
10+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
11+
712
@interface DefaultPaymentQueue ()
813
/// The wrapped SKPaymentQueue
914
@property(nonatomic, strong) SKPaymentQueue *queue;
@@ -68,3 +73,5 @@ - (void)showPriceConsentIfNeeded API_AVAILABLE(ios(13.4))API_UNAVAILABLE(tvos, m
6873
#endif
6974

7075
@end
76+
77+
#pragma clang diagnostic pop

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/include/in_app_purchase_storekit_objc/FIAObjectTranslator.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#import <StoreKit/StoreKit.h>
77
#import "messages.g.h"
88

9+
// StoreKit 1 is intentionally used as the fallback on iOS < 15 and macOS < 12,
10+
// where StoreKit 2 is unavailable. Suppress its deprecation warnings.
11+
#pragma clang diagnostic push
12+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
13+
914
NS_ASSUME_NONNULL_BEGIN
1015

1116
@interface FIAObjectTranslator : NSObject
@@ -79,3 +84,5 @@ NS_ASSUME_NONNULL_BEGIN
7984
@end
8085

8186
NS_ASSUME_NONNULL_END
87+
88+
#pragma clang diagnostic pop

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/include/in_app_purchase_storekit_objc/FIAPPaymentQueueDelegate.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#import <StoreKit/StoreKit.h>
1313
#import "FLTMethodChannelProtocol.h"
1414

15+
// StoreKit 1 is intentionally used as the fallback on iOS < 15 and macOS < 12,
16+
// where StoreKit 2 is unavailable. Suppress its deprecation warnings.
17+
#pragma clang diagnostic push
18+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
19+
1520
NS_ASSUME_NONNULL_BEGIN
1621

1722
API_UNAVAILABLE(tvos, watchos)
@@ -20,3 +25,5 @@ API_UNAVAILABLE(tvos, watchos)
2025
@end
2126

2227
NS_ASSUME_NONNULL_END
28+
29+
#pragma clang diagnostic pop

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/include/in_app_purchase_storekit_objc/FIAPRequestHandler.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#import <StoreKit/StoreKit.h>
77
#import "FLTRequestHandlerProtocol.h"
88

9+
// StoreKit 1 is intentionally used as the fallback on iOS < 15 and macOS < 12,
10+
// where StoreKit 2 is unavailable. Suppress its deprecation warnings.
11+
#pragma clang diagnostic push
12+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
13+
914
NS_ASSUME_NONNULL_BEGIN
1015

1116
@interface FIAPRequestHandler : NSObject <FLTRequestHandlerProtocol>
@@ -22,3 +27,5 @@ NS_ASSUME_NONNULL_BEGIN
2227
- (instancetype)initWithRequestHandler:(FIAPRequestHandler *)handler;
2328
@end
2429
NS_ASSUME_NONNULL_END
30+
31+
#pragma clang diagnostic pop

0 commit comments

Comments
 (0)