Skip to content

Simplify Yosemite into a Swift package - Sources only #15755

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 1 commit into from
Jun 20, 2025

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Jun 16, 2025

Description

See https://linear.app/a8c/issue/AINFRA-468.

Based on top of #15744 and based off the original work from #15678 .

This first PR moves the Yosemite sources from being a framework to being a Swift package.

Steps to reproduce & Testing information

See green CI. Also check out the prototype build.

Screenshots


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

@mokagio mokagio changed the base branch from ainfra-470-networking-source to ainfra-510-hardware-sources June 16, 2025 09:19
@dangermattic
Copy link
Collaborator

dangermattic commented Jun 16, 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

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jun 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 Number30604
VersionPR #15755
Bundle IDcom.automattic.alpha.woocommerce
Commit045d091
Installation URL6kgncn9924veg
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-468-yosemite-sources branch 4 times, most recently from db60645 to 2e4a5f7 Compare June 17, 2025 04:22
@mokagio mokagio force-pushed the ainfra-510-hardware-sources branch from 0aec18c to 9660145 Compare June 18, 2025 03:30
@mokagio mokagio force-pushed the ainfra-468-yosemite-sources branch from 2e4a5f7 to 75bd727 Compare June 18, 2025 03:36
product: CopiableProp<Yosemite.Product> = .copy
note: CopiableProp<Note> = .copy,
review: CopiableProp<ProductReview> = .copy,
product: CopiableProp<Networking.Product> = .copy
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change from Yosemite.Product to Networking.Product can be explained by noticing that the former is but a typealias for the latter:

public typealias Product = Networking.Product

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 probably fine, but pedantry could creep in here.

The WooCommerce target isn't supposed to import from Networking or Storage, but to use Yosemite instead... that's the reason for all the typealiases.

So my only concern is that something using this copy function from the WooCommerce target might not be able to without first importing Networking, which it shouldn't do...

It's often better to make a specific model in Yosemite for use by WooCommerce, instead of proxying the Networking model, and you see that more with newer code... presumably if we did that for these examples, rake generate would sort that out.

Do you know why the output changed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you know why the output changed here?

I can't say for certain, but my guess is that it has to do with referencing a list of files as opposed to accessing them through the Xcode project. We obviously cannot use the project now because it's no longer there, and for some reason accessing via the package does not work either, I left some more details in #15702

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So my only concern is that something using this copy function from the WooCommerce target might not be able to without first importing Networking, which it shouldn't do...

I tried this quickly locally and it worked without Networking.

diff --git a/WooCommerce/Classes/ViewRelated/Hub Menu/HubMenuCoordinator.swift b/WooCommerce/Classes/ViewRelated/Hub Menu/HubMenuCoordinator.swift
index d5df7f6d9f..3846b3416b 100644
--- a/WooCommerce/Classes/ViewRelated/Hub Menu/HubMenuCoordinator.swift	
+++ b/WooCommerce/Classes/ViewRelated/Hub Menu/HubMenuCoordinator.swift	
@@ -2,10 +2,7 @@ import Combine
 import Foundation
 import UIKit
 
-import enum Yosemite.ProductReviewAction
-import enum Yosemite.NotificationAction
-import struct Yosemite.ProductReviewFromNoteParcel
-import protocol Yosemite.StoresManager
+import Yosemite
 
 /// Coordinator for the HubMenu tab.
 ///
@@ -120,6 +117,7 @@ final class HubMenuCoordinator {
     }
 
     private func pushReviewDetailsViewController(using parcel: ProductReviewFromNoteParcel) {
+        _ = parcel.copy()
         hubMenuController?.pushReviewDetailsViewController(using: parcel)
     }
 }

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The WooCommerce target isn't supposed to import from Networking or Storage, but to use Yosemite instead...

By the way, this rule has been breached a few times:

image image

@mokagio mokagio changed the title AINFRA-469 - Simplify Storage into a Swift package - Sources only Simplify Yosemite into a Swift package - Sources only Jun 18, 2025
@mokagio mokagio force-pushed the ainfra-468-yosemite-sources branch from 75bd727 to 2c04a26 Compare June 18, 2025 03:42
@mokagio mokagio force-pushed the ainfra-510-hardware-sources branch from 9660145 to 7bdc4dd Compare June 18, 2025 10:40
@mokagio mokagio force-pushed the ainfra-468-yosemite-sources branch from 2c04a26 to 5a1e7e9 Compare June 18, 2025 11:00
@mokagio mokagio force-pushed the ainfra-510-hardware-sources branch from 7bdc4dd to 8c82f5e Compare June 19, 2025 05:32
@mokagio mokagio force-pushed the ainfra-468-yosemite-sources branch from 5a1e7e9 to 284c9fc Compare June 19, 2025 07:12
Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

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

This one looks good as well. Tested on simulators, but I'll check on a device when I get a chance too.

product: CopiableProp<Yosemite.Product> = .copy
note: CopiableProp<Note> = .copy,
review: CopiableProp<ProductReview> = .copy,
product: CopiableProp<Networking.Product> = .copy
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 probably fine, but pedantry could creep in here.

The WooCommerce target isn't supposed to import from Networking or Storage, but to use Yosemite instead... that's the reason for all the typealiases.

So my only concern is that something using this copy function from the WooCommerce target might not be able to without first importing Networking, which it shouldn't do...

It's often better to make a specific model in Yosemite for use by WooCommerce, instead of proxying the Networking model, and you see that more with newer code... presumably if we did that for these examples, rake generate would sort that out.

Do you know why the output changed here?

@@ -1,4 +1,5 @@
import Photos
import UIKit
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 surprising to see this one imported in Yosemite... but I see it's needed for UIImage. I guess we got this import for free before...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It came from the umbrella header:

#import <UIKit/UIKit.h>

Base automatically changed from ainfra-510-hardware-sources to trunk June 19, 2025 23:48
@mokagio mokagio marked this pull request as ready for review June 20, 2025 01:30
@mokagio mokagio force-pushed the ainfra-468-yosemite-sources branch from 284c9fc to 045d091 Compare June 20, 2025 01:31
@mokagio mokagio enabled auto-merge June 20, 2025 01:31
@mokagio mokagio added this to the 22.7 milestone Jun 20, 2025
@mokagio mokagio self-assigned this Jun 20, 2025
@mokagio mokagio added the category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. label Jun 20, 2025
@mokagio mokagio merged commit f74676d into trunk Jun 20, 2025
18 checks passed
@mokagio mokagio deleted the ainfra-468-yosemite-sources branch June 20, 2025 01:52
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