Skip to content

Reset Modules as an Xcode local package with tests in CI #24518

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 9 commits into from
May 12, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .buildkite/commands/complete-code-freeze.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ source use-bot-for-git

.buildkite/commands/checkout-release-branch.sh "$RELEASE_NUMBER"

echo '--- :ruby: Setup Ruby tools'
install_gems

echo "--- :swift: Set up Swift Packages"
install_swiftpm_dependencies
"$(dirname "${BASH_SOURCE[0]}")/shared-set-up.sh"

echo '--- :closed_lock_with_key: Access secrets'
bundle exec fastlane run configure_apply
Expand Down
4 changes: 4 additions & 0 deletions .buildkite/commands/shared-set-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
echo "--- :rubygems: Setting up Gems"
install_gems

# The push/pop is workaround for tooling not supporting a Package.swift path.
# Note that neither ours nor Apple's tooling does.
pushd "$(dirname "${BASH_SOURCE[0]}")/../../Modules"
echo "--- :swift: Setting up Swift Packages"
install_swiftpm_dependencies
popd

echo "--- :xcode: Fetch XCFrameworks"
rake dependencies
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@ WordPress/InfoPlist-internal.h
# and assume no local copy would have generated the Pods.
Pods/

# Modules — Where the Swift packages that make up the modular app live
#
# Ignore the Package.resolved file. The packages source of truth is the
# resolved file generated by the Xcode workspace.
Modules/Package.resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought you had to use ...ace/xcshareddata/swiftpm/Package.resolved managed by Xcode? Modules/Package.resolved isn't, or is it? How did you get it to work? When you open the Xcode project, does it use pins from Modules/Package.resolved?

...ace/xcshareddata/swiftpm/Package.resolved → Modules/Package.resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies @kean this change surprised me a bit and I should have preempted your question writing about it.

Before

Modules was part of the workspace. When Xcode detected changes in Modules/Package.swift, it triggered the packages resolution and updated the resolved file in the workspace xcshareddata folder.

After

Modules is part of the project, but is not a dependency of the project:

image

When Xcode detects a change in Modules/Package.swift, it triggers the packages resolution and updates Modules/Package.resolved.

I guess that if we were to add additional package dependencies to the project Xcode would then re-introduce the workspace resolved file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When Xcode detects a change in Modules/Package.swift, it triggers the packages resolution and updates Modules/Package.resolved.

I verified this by switching color-studio from pointing to a branch to a commit. The screenshot below shows Xcode highlighting the change in the gutter and the package resolution running.

image

35e360b tracks the changes and the .resolved update.


# While we depend on gutenberg-mobile, we download its XCFrameworks in
# WordPress/Frameworks
WordPress/Frameworks/*.xcframework
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ let package = Package(
.package(url: "https://github.com/wordpress-mobile/MediaEditor-iOS", branch: "task/spm-support"),
.package(url: "https://github.com/wordpress-mobile/NSObject-SafeExpectations", from: "0.0.6"),
.package(url: "https://github.com/wordpress-mobile/NSURL-IDN", revision: "b34794c9a3f32312e1593d4a3d120572afa0d010"),
.package(url: "https://github.com/wordpress-mobile/WordPressKit-iOS", branch: "wpios-edition"),
.package(
url: "https://github.com/wordpress-mobile/WordPressKit-iOS",
revision: "5bc08764d2025e21685816065f611e884c8672d1" // see wpios-edition branch
),
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
// We can't use wordpress-rs branches nor commits here. Only tags work.
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20250505"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.2.0"),
.package(url: "https://github.com/Automattic/color-studio", branch: "trunk"),
.package(
url: "https://github.com/Automattic/color-studio",
revision: "bf141adc75e2769eb469a3e095bdc93dc30be8de"
),
.package(url: "https://github.com/wordpress-mobile/AztecEditor-iOS", from: "1.20.0"),
],
targets: XcodeSupport.targets + [
Expand Down Expand Up @@ -168,7 +174,12 @@ let package = Package(
),
.testTarget(name: "JetpackStatsWidgetsCoreTests", dependencies: [.target(name: "JetpackStatsWidgetsCore")], swiftSettings: [.swiftLanguageMode(.v5)]),
.testTarget(name: "DesignSystemTests", dependencies: [.target(name: "DesignSystem")], swiftSettings: [.swiftLanguageMode(.v5)]),
.testTarget(name: "WordPressFluxTests", dependencies: ["WordPressFlux"], swiftSettings: [.swiftLanguageMode(.v5)]),
.testTarget(
name: "WordPressFluxTests",
dependencies: ["WordPressFlux"],
exclude: ["WordPressFluxTests.xctestplan"],
swiftSettings: [.swiftLanguageMode(.v5)]
),
Comment on lines -171 to +182
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this to see how WordPressFluxTests would run tests with standalone scheme.

Interestingly, I tried using a copy-paste friendly exclude: ["*.xctestplan"], pattern, but it failed to find the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My autogenerated scheme picks up the test plan:

image

However, I got an unlock prompt when I edited it (but no xcsheme change in the project, possibly because the scheme might be in Modules/.swiftpm) so I'd be curious to know if you see it too...

.testTarget(name: "AsyncImageKitTests", dependencies: [
.target(name: "AsyncImageKit"),
.target(name: "WordPressTesting"),
Expand Down
24 changes: 24 additions & 0 deletions Modules/Tests/WordPressFluxTests/WordPressFluxTests.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"configurations" : [
{
"id" : "92A65F35-8051-4F5F-B68A-1802B2E06105",
"name" : "Test Scheme Action",
"options" : {

}
}
],
"defaultOptions" : {
"codeCoverage" : false
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:",
"identifier" : "WordPressFluxTests",
"name" : "WordPressFluxTests"
}
}
],
"version" : 1
}
7 changes: 0 additions & 7 deletions Tests/KeystoneTests/WordPressUnitTests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@
},
"testTargets" : [
{
"enabled" : false,
"target" : {
"containerPath" : "container:..\/Modules",
"identifier" : "AsyncImageKitTests",
"name" : "AsyncImageKitTests"
}
},
{
"enabled" : false,
"target" : {
"containerPath" : "container:WordPress.xcodeproj",
"identifier" : "4AD953BA2C21451700D0EEFA",
Expand All @@ -62,39 +60,34 @@
}
},
{
"enabled" : false,
"target" : {
"containerPath" : "container:..\/Modules",
"identifier" : "WordPressUIUnitTests",
"name" : "WordPressUIUnitTests"
}
},
{
"enabled" : false,
"target" : {
"containerPath" : "container:..\/Modules",
"identifier" : "WordPressSharedTests",
"name" : "WordPressSharedTests"
}
},
{
"enabled" : false,
"target" : {
"containerPath" : "container:..\/Modules",
"identifier" : "JetpackStatsWidgetsCoreTests",
"name" : "JetpackStatsWidgetsCoreTests"
}
},
{
"enabled" : false,
"target" : {
"containerPath" : "container:..\/Modules",
"identifier" : "WordPressFluxTests",
"name" : "WordPressFluxTests"
}
},
{
"enabled" : false,
"target" : {
"containerPath" : "container:..\/Modules",
"identifier" : "WordPressSharedObjCTests",
Expand Down
10 changes: 2 additions & 8 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@
3F9DD3F62CC214BF00DF1760 /* Common.debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Common.debug.xcconfig; sourceTree = "<group>"; };
3F9DD3F72CC2188400DF1760 /* Common.alpha.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Common.alpha.xcconfig; sourceTree = "<group>"; };
3FA640652670CEFE0064401E /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
3FD4B20E2DCC468200781DFA /* Modules */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Modules; path = ../Modules; sourceTree = SOURCE_ROOT; };
406A0EEF224D39C50016AD6A /* Flags.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Flags.xcassets; sourceTree = "<group>"; };
433840C622C2BA5B00CB13F8 /* AppImages.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = AppImages.xcassets; path = Resources/AppImages.xcassets; sourceTree = "<group>"; };
4A690C142BA790BC00A8E0C5 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1606,6 +1607,7 @@
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup;
children = (
3FD4B20E2DCC468200781DFA /* Modules */,
0C5C46FB2D98395300F2CD55 /* Sources */,
0C5A19CB2D9B07E700C25301 /* Tests */,
F14B5F6F208E648200439554 /* config */,
Expand Down Expand Up @@ -2705,7 +2707,6 @@
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
packageReferences = (
0C8095952DC2A4B9008DFC2F /* XCLocalSwiftPackageReference "../Modules" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = 19C28FACFE9D520D11CA2CBB /* Products */;
Expand Down Expand Up @@ -7040,13 +7041,6 @@
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
0C8095952DC2A4B9008DFC2F /* XCLocalSwiftPackageReference "../Modules" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../Modules;
};
/* End XCLocalSwiftPackageReference section */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the difference between this and the previous setup (pre #24511) is that we no longer have any local swift package reference as a dependency for WordPress.

My guess is that, whichever way it ended up like that, the duplicated reference—as a local module in the workspace and as a package reference—is what resulted in the duplicated entries shown in the #24511 description.

/* Begin XCSwiftPackageProductDependency section */
0C2155A52C39A24D00EFE2C0 /* XcodeTarget_UITests */ = {
isa = XCSwiftPackageProductDependency;
Expand Down
Loading