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
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 0 additions & 4 deletions Fakes/Fakes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
26106B3D25FA4F6C0000DF30 /* ProductFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26106B3C25FA4F6C0000DF30 /* ProductFactory.swift */; };
26CA6D2625F6C87800B01F48 /* Fakes.h in Headers */ = {isa = PBXBuildFile; fileRef = 26CA6D2425F6C87800B01F48 /* Fakes.h */; settings = {ATTRIBUTES = (Public, ); }; };
26CA6D2F25F6C8FC00B01F48 /* Fake.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26CA6D2D25F6C8FB00B01F48 /* Fake.swift */; };
26EEDC8D26FE1C1C00D5BA0E /* Yosemite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26EEDC8C26FE1C1C00D5BA0E /* Yosemite.framework */; };
26EEDC9026FE1C7B00D5BA0E /* Networking.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EEDC8E26FE1C7B00D5BA0E /* Networking.generated.swift */; };
26EEDC9126FE1C7B00D5BA0E /* Yosemite.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26EEDC8F26FE1C7B00D5BA0E /* Yosemite.generated.swift */; };
3F2B4AC22DDC30B200E5E49C /* XcodeTarget_Fakes in Frameworks */ = {isa = PBXBuildFile; productRef = 3F2B4AC12DDC30B200E5E49C /* XcodeTarget_Fakes */; };
Expand Down Expand Up @@ -41,7 +40,6 @@
26CA6D2425F6C87800B01F48 /* Fakes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Fakes.h; sourceTree = "<group>"; };
26CA6D2525F6C87800B01F48 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
26CA6D2D25F6C8FB00B01F48 /* Fake.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Fake.swift; sourceTree = "<group>"; };
26EEDC8C26FE1C1C00D5BA0E /* Yosemite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Yosemite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
26EEDC8E26FE1C7B00D5BA0E /* Networking.generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Networking.generated.swift; sourceTree = "<group>"; };
26EEDC8F26FE1C7B00D5BA0E /* Yosemite.generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Yosemite.generated.swift; sourceTree = "<group>"; };
3F37E1222DEEAC7200D8BF2B /* WooFoundationCore.generated.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooFoundationCore.generated.swift; sourceTree = "<group>"; };
Expand All @@ -55,7 +53,6 @@
buildActionMask = 2147483647;
files = (
3F2B4AC22DDC30B200E5E49C /* XcodeTarget_Fakes in Frameworks */,
26EEDC8D26FE1C1C00D5BA0E /* Yosemite.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -108,7 +105,6 @@
26CA6D3225F6C92100B01F48 /* Frameworks */ = {
isa = PBXGroup;
children = (
26EEDC8C26FE1C1C00D5BA0E /* Yosemite.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1620"
version = "1.3">
LastUpgradeVersion = "1640"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand All @@ -14,10 +15,10 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B5C9DDF42087FEC0006B910A"
BuildableName = "Yosemite.framework"
BlueprintIdentifier = "Yosemite"
BuildableName = "Yosemite"
BlueprintName = "Yosemite"
ReferencedContainer = "container:Yosemite.xcodeproj">
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -26,28 +27,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B5C9DDF42087FEC0006B910A"
BuildableName = "Yosemite.framework"
BlueprintName = "Yosemite"
ReferencedContainer = "container:Yosemite.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B5C9DDFD2087FEC0006B910A"
BuildableName = "YosemiteTests.xctest"
BlueprintName = "YosemiteTests"
ReferencedContainer = "container:Yosemite.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -59,15 +40,6 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B5C9DDF42087FEC0006B910A"
BuildableName = "Yosemite.framework"
BlueprintName = "Yosemite"
ReferencedContainer = "container:Yosemite.xcodeproj">
</BuildableReference>
</MacroExpansion>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand All @@ -78,10 +50,10 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B5C9DDF42087FEC0006B910A"
BuildableName = "Yosemite.framework"
BlueprintIdentifier = "Yosemite"
BuildableName = "Yosemite"
BlueprintName = "Yosemite"
ReferencedContainer = "container:Yosemite.xcodeproj">
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
Expand Down
45 changes: 25 additions & 20 deletions Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ let package = Package(
name: "WPMediaPicker",
targets: ["WPMediaPicker"]
),
.library(
name: "Yosemite",
targets: ["Yosemite"]
),
],
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire", from: "5.2.0"),
Expand Down Expand Up @@ -181,6 +185,23 @@ let package = Package(
name: "WPMediaPicker",
resources: [.process("Resources")]
),
.target(
name: "Yosemite",
dependencies: [
"Codegen",
"Hardware",
"Networking",
"Storage",
"WooFoundation",
"WordPressShared",
.product(name: "Alamofire", package: "Alamofire"),
.product(name: "Aztec", package: "AztecEditor-iOS"),
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
.product(name: "KeychainAccess", package: "KeychainAccess"),
.product(name: "StripeTerminal", package: "stripe-terminal-ios"),
.product(name: "WordPressEditor", package: "AztecEditor-iOS"),
]
),
.testTarget(
name: "ExperimentsTests",
dependencies: [
Expand Down Expand Up @@ -239,7 +260,6 @@ enum XcodeTargetNames {
static let wooCommerceWatchApp = "Woo Watch App"
static let wordPressAuthenticator = "WordPressAuthenticator"
static let wordPressAuthenticatorTests = "WordPressAuthenticatorTests"
static let yosemite = "Yosemite"
static let yosemiteTests = "YosemiteTests"
}

Expand All @@ -260,7 +280,6 @@ enum XcodeSupport {
XcodeTargetNames.wooCommerceWatchApp,
XcodeTargetNames.wordPressAuthenticator,
XcodeTargetNames.wordPressAuthenticatorTests,
XcodeTargetNames.yosemite,
XcodeTargetNames.yosemiteTests
].map { .supportingProduct(forXcodeTarget: $0) }
}
Expand All @@ -273,6 +292,7 @@ enum XcodeSupport {
"Codegen",
"Hardware",
"Networking",
"Yosemite"
]
),
.xcodeTarget(
Expand All @@ -297,6 +317,7 @@ enum XcodeSupport {
dependencies: [
"Networking",
"WooFoundation",
"Yosemite",
.product(name: "KeychainAccess", package: "KeychainAccess"),
]
),
Expand Down Expand Up @@ -335,6 +356,7 @@ enum XcodeSupport {
"WordPressShared",
"WordPressUI",
"WPMediaPicker",
"Yosemite",
.product(name: "Alamofire", package: "Alamofire"),
.product(name: "Algorithms", package: "swift-algorithms"),
.product(name: "AutomatticAbout", package: "AutomatticAbout-swift"),
Expand Down Expand Up @@ -416,31 +438,14 @@ enum XcodeSupport {
XcodeTargetNames.wordPressAuthenticator.asDependency,
]
),
.xcodeTarget(
XcodeTargetNames.yosemite,
dependencies: [
"Codegen",
"Hardware",
"Networking",
"Storage",
"WooFoundation",
"WordPressShared",
.product(name: "Alamofire", package: "Alamofire"),
.product(name: "Aztec", package: "AztecEditor-iOS"),
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
.product(name: "KeychainAccess", package: "KeychainAccess"),
.product(name: "StripeTerminal", package: "stripe-terminal-ios"),
.product(name: "WordPressEditor", package: "AztecEditor-iOS"),
]
),
.xcodeTarget(
XcodeTargetNames.yosemiteTests,
dependencies: [
"Codegen",
"TestKit",
"WooFoundation",
"WordPressShared",
XcodeTargetNames.yosemite.asDependency
"Yosemite"
]
)
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
project:
file: ../../../../../Yosemite/Yosemite.xcodeproj
target:
name: Yosemite
sources:
include:
- ../../../../../Modules/Sources/Yosemite/
templates:
- Models+Copiable.swifttemplate
output: ../../../../../Yosemite/Yosemite/Model/Copiable/
output: ../../../../../Modules/Sources/Yosemite/Model/Copiable/
args:
moduleName: Yosemite
10 changes: 5 additions & 5 deletions Modules/Sources/Codegen/Sourcery/Fakes/Yosemite-Fakes.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
project:
file: ../../../../../Yosemite/Yosemite.xcodeproj
target:
name: Yosemite
sources:
include:
- ../../../../../Modules/Sources/Yosemite/
templates:
- Fakes.swifttemplate
output: ../../../../../Fakes/Fakes/Yosemite.generated.swift

args:
moduleName: Yosemite
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//

import Combine
import Foundation

public enum CardPresentPaymentAction: Action {
/// Sets the store to use a given payment gateway
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import Networking
import Storage

// MARK: - NotificationCountAction: Defines all of the Actions supported by the NotificationCountStore.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Networking

public enum ShippingLabelAction: Action {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Networking

public enum WooShippingAction: Action {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ extension Yosemite.POSSimpleProduct {

extension Yosemite.ProductReviewFromNoteParcel {
public func copy(
note: CopiableProp<Yosemite.Note> = .copy,
review: CopiableProp<Yosemite.ProductReview> = .copy,
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

) -> Yosemite.ProductReviewFromNoteParcel {
let note = note ?? self.note
let review = review ?? self.review
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import WooFoundation

/// Represents the possible states for onboarding to In-Person payments
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Hardware
import WooFoundation

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Networking

extension Note.Kind: Codable {}

/// The type of notification count for the site
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Foundation

public struct POSCoupon: Equatable, Hashable {
public let id: UUID
public let code: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import WooFoundation
import Codegen
import Networking
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import struct Networking.PagedItems

public enum POSItem: Equatable, Identifiable, Hashable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Foundation
import Storage
import CoreData
import Combine
import UIKit

/// The mutable (`Storage` model) type that is used by `FetchResultSnapshotsProvider`.
public typealias FetchResultSnapshotsProviderMutableType = NSManagedObject & ReadOnlyConvertible
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Networking
import Storage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Storage
import Networking

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Storage
import Hardware
import Networking
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Networking
import Storage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import Storage
import Networking
import UIKit
import WooFoundation

// MARK: - JustInTimeMessageStore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Storage
import Networking
import WooFoundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Foundation

/// Configuration of a bundled order item from the configuration UI. It contains necessary information to save the configuration remotely.
public struct BundledProductConfiguration: Equatable {
public enum ProductOrVariation: Equatable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Networking

public protocol OrderSyncProductTypeProtocol: Hashable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import Storage
import Networking

Expand Down
Loading