Skip to content

Simplify Experiments into a Swift package #15622

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
merged 2 commits into from
Jun 5, 2025

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented May 13, 2025

Description

Similar too #15651 , this PR converts the Experiments framework into a Swift package in Modules/.

See also https://linear.app/a8c/issue/AINFRA-471

Unfortunately, this is the last individual framework migration we can perform. The rest will need to be moved in bulk because the tests all depend on Fakes, which in turn depends on the rest of the frameworks.

Steps to reproduce & Testing information

See green CI + run this branch on device.

Screenshots


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

@dangermattic
Copy link
Collaborator

dangermattic commented May 13, 2025

2 Warnings
⚠️ Modules/Package.swift was changed without updating its corresponding Package.resolved. Please resolve the Swift packages as appropriate to your project setup (e.g. in Xcode or by running swift package resolve).
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@mokagio mokagio force-pushed the ainfra-471-move-experiments-to-modules branch from 9423902 to acd51eb Compare May 16, 2025 04:53
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 16, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Number30244
VersionPR #15622
Bundle IDcom.automattic.alpha.woocommerce
Commit1d33e99
Installation URL0r9il8hntvgtg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@mokagio mokagio force-pushed the ainfra-471-move-experiments-to-modules branch from acd51eb to eae2e4c Compare May 19, 2025 03:05
@mokagio mokagio force-pushed the ainfra-471-move-experiments-to-modules branch from eae2e4c to 9cbaeb7 Compare June 2, 2025 02:57
@mokagio mokagio added this to the 22.6 milestone Jun 2, 2025
@mokagio mokagio added the category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. label Jun 2, 2025
@mokagio mokagio self-assigned this Jun 2, 2025
@mokagio mokagio requested review from a team June 2, 2025 03:02
@mokagio mokagio marked this pull request as ready for review June 2, 2025 03:02
mokagio added a commit that referenced this pull request Jun 2, 2025
When moving from frameworks to Swift packages, see for example
#15622 and
#15651, we lose the
framework headers which had statements like `#import
<Foundation/Foundation.h>`. This means that basic frameworks such as
Foundation and UIKit are no longer imported as part of consumers
frameworks such as Yosemite. To simplify the code review of the upcoming
PRs migrating those frameworks to Swift packages in `Modules/`, this PR
preemptively adds the required imports in the files that need them.

This was done by running `git reset trunk` on the workbench branch
`temp-branch-for-swiftpm-migration` and only committing the `import`
additions in this branch.
mokagio added a commit that referenced this pull request Jun 2, 2025
When moving from frameworks to Swift packages, see for example
#15622 and
#15651, we lose the
framework headers which had statements like `#import
<Foundation/Foundation.h>`. This means that basic frameworks such as
Foundation and UIKit are no longer imported as part of consumers
frameworks such as Yosemite. To simplify the code review of the upcoming
PRs migrating those frameworks to Swift packages in `Modules/`, this PR
preemptively adds the required imports in the files that need them.

This was done by running `git reset trunk` on the workbench branch
`temp-branch-for-swiftpm-migration` and only committing the `import`
additions in this branch.
@mokagio mokagio force-pushed the ainfra-471-move-experiments-to-modules branch from 9cbaeb7 to 1d33e99 Compare June 3, 2025 21:50
@@ -1,6 +1,7 @@
import Foundation
import KeychainAccess
import Networking
import UserNotifications
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explanation for why this and the Foundation import below are here can be found in #15698

twstokes
twstokes previously approved these changes Jun 4, 2025
Copy link
Contributor

@twstokes twstokes left a comment

Choose a reason for hiding this comment

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

👋 These changes LGTM @mokagio - I was able to build and test locally and see that CI passed. Approving to unblock but other reviews are welcome.

Copy link
Contributor

@twstokes twstokes left a comment

Choose a reason for hiding this comment

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

Actually on second thought @mokagio - when trying to run WCiOS in a Simulator I'm seeing:

dyld[36556]: Symbol not found: _$sSo7UIColorC13WooFoundationE15withColorStudio_5shadeAB0bC4Core0eF0V_AF0eF5ShadeOtFZ
  Referenced from: <A6BCB995-881E-31AF-92A5-6146F3FFD8EC> /Users/tanner/Library/Developer/CoreSimulator/Devices/7586F18C-8D66-495B-BFB8-6346FCF526B1/data/Containers/Bundle/Application/EF3681BC-7340-4715-B3A4-A2E30D1DF40C/WooCommerce.app/WooCommerce.debug.dylib
  Expected in:     <5F3EA820-850E-3F18-91A5-97361DE9CEDD> /Users/tanner/Library/Developer/Xcode/DerivedData/WooCommerce-dutzhurnuvsqusgjnyibtbncmmou/Build/Products/Debug-iphonesimulator/WooFoundation.framework/WooFoundation

I'll double-check that this isn't something in my local environment.

Edit: After cleaning my local environment and rebuilding I'm able to run the app without this crash.

@mokagio
Copy link
Contributor Author

mokagio commented Jun 5, 2025

Thanks @twstokes !

Regarding the issue that resolved itself after cleaning, I'm afraid we can expect a few of those as we transition. A positive side effect of having to bulk move all the remaining frameworks because of how Fakes is used in the tests and links to all of them, #15678, is that we don't have many PRs left till the migration is done.

@mokagio mokagio merged commit 71913fd into trunk Jun 5, 2025
13 checks passed
@mokagio mokagio deleted the ainfra-471-move-experiments-to-modules branch June 5, 2025 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants