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

[in_app_purchase_storekit] Add Swift Package Manager compatibility #8469

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

alejandro-all-win-software
Copy link

@alejandro-all-win-software alejandro-all-win-software commented Jan 21, 2025

Makes in_app_purchase_storekit available as a Swift Package to Flutter

Closes #146905

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@LouiseHsu LouiseHsu requested a review from loic-sharma January 21, 2025 18:22
@stuartmorgan
Copy link
Contributor

  • All existing and new tests are passing.

A number of the automated tests are not buildable in this PR. If you click into the failing CI tasks, click View more details on flutter-dashboard, and the go into the stdout for failing steps you can see the errors.

@alejandro-all-win-software alejandro-all-win-software marked this pull request as draft January 21, 2025 21:55
@alejandro-all-win-software
Copy link
Author

I will fix tree issue tmr

@alejandro-all-win-software alejandro-all-win-software force-pushed the feat/in-app-purchase-add-swift-package-manager-support branch from b71a757 to 99a1132 Compare January 22, 2025 13:56
@alejandro-all-win-software
Copy link
Author

alejandro-all-win-software commented Jan 22, 2025

Hmm, I am not sure why the tree status is failing. I though it was because of the main merge in my branch.

@stuartmorgan
Copy link
Contributor

Hmm, I am not sure why the tree status is failing.

tree-status is a live-updating check reflecting the current post-submit state of the tree, in order to block all PRs from landing while the tree is broken. It is not related to the individual PR.

@alejandro-all-win-software
Copy link
Author

I see, thank you.

…packages into feat/in-app-purchase-add-swift-package-manager-support
@alejandro-all-win-software alejandro-all-win-software force-pushed the feat/in-app-purchase-add-swift-package-manager-support branch from 99a1132 to f415bf0 Compare January 22, 2025 15:20
@alejandro-all-win-software alejandro-all-win-software marked this pull request as ready for review January 22, 2025 15:21
Comment on lines 14 to 18
#if __has_include(<in_app_purchase_storekit/in_app_purchase_storekit.h>)
@import in_app_purchase_storekit;
#else
@import storekit_objc;
#endif

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to avoid changing this file but I couldn't find a way.

@alejandro-all-win-software
Copy link
Author

Hey @loic-sharma, whenever you have a chance, could you review these changes, please? Thanks!

@stuartmorgan stuartmorgan added the triage-ios Should be looked at in iOS triage label Jan 23, 2025
@stuartmorgan
Copy link
Contributor

@alejandro-all-win-software Per our contributor docs, you should expect a review within two weeks, not 24 hours; please don't ping people just because they haven't immediately reviewed a PR.

@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <TargetConditionals.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? If I remove this line, I can still build fine locally using both SwiftPM and CocoaPods.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -2,11 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <TargetConditionals.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? If I remove this line, I can still build fine locally using both SwiftPM and CocoaPods.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? If I remove this line, I can still build fine locally using both SwiftPM and CocoaPods.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am encountering errors when running the project on macOS using the SPM.
Screenshot 2025-01-24 at 3 44 57 PM
Screenshot 2025-01-24 at 3 55 01 PM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really weird but I'm able to reproduce this on my machine as well... This seems harmless I guess 🙃

Copy link
Contributor

@stuartmorgan stuartmorgan Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add the missing Foundation import (this header uses NSArray for instance), this probably won't be necessary. Usually this header doesn't have to be explicitly imported because the core frameworks all use it in their headers. (Arguably it should be included anyway for IWYU, but it's kind of a grey area since it's so core.)

Comment on lines 5 to 11
#include <TargetConditionals.h>

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the Flutter or FlutterMacOS necessary here? The only type from the Flutter framework in this file, FlutterError, is forward declared. With this change, I can still build fine locally using both SwiftPM and CocoaPods on both the macOS and iOS apps.

Suggested change
#include <TargetConditionals.h>
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included it as I believed it was necessary, but if it’s not required, I’m happy to remove it 👍.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's odd that we have a forward declaration in this header in the first place; generally we follow https://google.github.io/styleguide/cppguide.html#Forward_Declarations for Obj-C code as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[in_app_purchase_storekit] Add Swift Package Manager compatibility to in_app_purchase_storekit
4 participants