Skip to content

Conversation

@mokagio
Copy link
Contributor

@mokagio mokagio commented May 28, 2025

Fixes https://linear.app/a8c/issue/AINFRA-639

The code is already in use in the WooCommerce iOS watchOS app, see woocommerce/woocommerce-ios@ec7a641

I decide to extract the files under the standard Sources/ and Tests/ root folders that SwiftPM expects. To keep the Package.swift and podspecs consistent, I moved all the other sources and tests there, too.

I updated the plumbing in the example app and ran it locally to ensure it still works, for what is worth.

Screenshot 2025-06-04 at 8 12 01 AM
  • I have considered if this change warrants release notes and have added them to the appropriate section in the CHANGELOG.md if necessary. – N.A. many files were moved, but the source change was minimal.

mokagio added 3 commits May 29, 2025 06:08
There are likely more files that could go into this target, but in the
context of getting `HTMLParser` accessing by WooCommerce on watchOS
(without UIKit) it's best to move forward without clearly separating the
tests.

The tests in Aztec already exercise the logic in the package anyway, so
we remain covered.
@mokagio mokagio force-pushed the mokagio/extract-html-parser branch 3 times, most recently from 4465a5c to ade72c7 Compare June 3, 2025 08:29
@mokagio mokagio force-pushed the mokagio/extract-html-parser branch from ade72c7 to 1b98c11 Compare June 3, 2025 08:37
@mokagio mokagio force-pushed the mokagio/extract-html-parser branch from ab93da2 to 1854660 Compare June 4, 2025 01:50
@mokagio
Copy link
Contributor Author

mokagio commented Jun 4, 2025

CI is failing with

Compiling for iOS 12.0, but module 'Aztec' has a minimum deployment target of iOS 13.0: /Users/builder/Library/Developer/Xcode/DerivedData/App-etmfcijrdcehzwescvrvmhwzlcrt/Build/Products/Debug-iphonesimulator/WordPress-Aztec-iOS/Aztec.framework/Modules/Aztec.swiftmodule/arm64-apple-ios-simulator.swiftmodule

but I don't get this locally 🤔


Update: Gave up on trying to fix this. Simply bumped everything to iOS 13 to satisfy it. bd3eacc

mokagio added 5 commits June 5, 2025 11:53
This aligns it with the pod and package configuration.

This changed is done in the context of CI failing with

- ERROR | xcodebuild:  /opt/ci/builds/builder/automattic/aztec-editor-ios/Tests/AztecTests/Extensions/ArrayHelperTests.swift:2:18: error: compiling for iOS 12.0, but module 'Aztec' has a minimum deployment target of iOS 13.0: /Users/builder/Library/Developer/Xcode/DerivedData/App-etmfcijrdcehzwescvrvmhwzlcrt/Build/Products/Debug-iphonesimulator/WordPress-Aztec-iOS/Aztec.framework/Modules/Aztec.swiftmodule/arm64-apple-ios-simulator.swiftmodule

However, it's a wild guess, as I don't see how CocoaPods would pick iOS
13 as the deployment target from the Example app, when none of its paths
are given to CocoaPods.

https://buildkite.com/automattic/aztec-editor-ios/builds/211/steps/canvas?jid=019738a1-cb58-4c2d-84de-d8aa8f76a57b
@mokagio mokagio force-pushed the mokagio/extract-html-parser branch from bfe41ed to 38c3770 Compare June 5, 2025 02:25
After all, all clients of this app already support above iOS 13.

Hopefully this will address the 12 vs 13 issue we're seeing in CI.

https://buildkite.com/automattic/aztec-editor-ios/builds/211/steps/canvas?jid=019738a1-cb58-4c2d-84de-d8aa8f76a57b
# The ~> modifier is not currently used, but we check for it just in case
XCODE_VERSION=$(sed -E 's/^~> ?//' .xcode-version)
CI_TOOLKIT_PLUGIN_VERSION="3.8.0"
CI_TOOLKIT_PLUGIN_VERSION="5.3.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Routine update.

CI_TOOLKIT_PLUGIN_VERSION="5.3.1"

export IMAGE_ID="xcode-$XCODE_VERSION-macos-14.7.1-v1"
export IMAGE_ID="xcode-$XCODE_VERSION"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suffix removed because I also updated the tooling to 16.4 which does not need it.

let package = Package(
name: "WordPress-AztecEditor-iOS",
platforms: [.iOS(.v11)],
platforms: [.iOS(.v13)],
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 reason for the version bump is layered.

This PR extracts HTMLParser as a standalone library so that the WooCommerce watchOS app can use it via SwiftPM, since watchOS does not support UIKit.

I knew the restructuring works when the library is fetched via SwiftPM because both the example app and Woo build and run.

But the only way I had to verify the CocoaPods setup, which required a few conditional imports (see the rest of the diff) was to run the unit tests as part of the spec verification.

But in CI, the tests failed with:

    - ERROR | xcodebuild:  /opt/ci/builds/builder/automattic/aztec-editor-ios/Tests/AztecTests/Extensions/ArrayHelperTests.swift:2:18: error: compiling for iOS 12.0, but module 'Aztec' has a minimum deployment target of iOS 13.0: /Users/builder/Library/Developer/Xcode/DerivedData/App-fnvsuwzsjydtrdcwmvzmpjrcydqz/Build/Products/Debug-iphonesimulator/WordPress-Aztec-iOS/Aztec.framework/Modules/Aztec.swiftmodule/arm64-apple-ios-simulator.swiftmodule

However on my local machine the same bundle exec pod lib lint command passes.

After a number of unsuccessful attempts to address the CI issue I simply decided to bump the minimum deployment target and move on. After all, all clients of this app already expect version way above iOS 13.

@mokagio mokagio marked this pull request as ready for review June 5, 2025 05:10
@mokagio mokagio requested a review from a team June 5, 2025 05:15
@mokagio mokagio enabled auto-merge June 5, 2025 22:51
@mokagio
Copy link
Contributor Author

mokagio commented Jun 11, 2025

@AliSoftware @iangmaia @twstokes could I ask you for a review?

The code is already in use in WooCommerce, referenced by a commit, but it would be good to merge this. Publishing a new tag would also be neat.

@AliSoftware AliSoftware disabled auto-merge June 11, 2025 09:24
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Ran bundle exec fastlane test and passed as expected (well after I updated TEST_RUNTIME = 'iOS 18.3' because I didn't have the 18.2 runtime installed on my Mac with the Xcode versions I have and didn't want to lose time downloading the whole runtime just for that while I won't use it afterwards and it'd take lots of disk space)

Left a couple of questions regarding the #if SWIFT_PACKAGE imports though, so I disabled auto-merge so you can review them first if needed, but approving to unblock.

Comment on lines +3 to +5
#if SWIFT_PACKAGE
@testable import HTMLParser
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm unsure why this @testable import has to be gated by #if SWIFT_PACKAGE (while other imports don't)? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has to do with the difference between how CocoaPods and SwiftPM build the library, or rather libraries.

In SwiftPM, we now have the standalone HTMLParser library and Aztec depends on it.

But in CocoaPods, I didn't expose HTMLParser. That's a bit of an inconsistency, I'll admit. But it seemed fine to only work in the context of SwiftPM, between the state of CocoaPods and the fact that this change was just to unblock SwiftPM in Woo.

But this situation resulted in a few build differences. The HTMLParser sources are part of Aztec when building with CocoaPods, but when building for SwiftPM (the default in Xcode and xcodebuild/CLI) they aren't.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I think I see (even though this is a bit much for my mushy Friday evening brain to take on fully 😅)

This seems like an important explanation, and something someone other that you (who worked on this migration directly and are thus familiar with the kind of hybrid/unbalanced setup you had to end up with) would require some digging to understand this subtlety and the reason behind it.

As such, I'll suggest to document it somewhere in the code. Like maybe a code comment explaining all that in the key/main/root place in the codebase where this #if case happens for the first time, then code comments next to all other #if you had to similarly add just pointing to that longer comment/explanation (to avoid copy/pasting same long explanatory comment at every single place)? wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +3 to +7
#if SWIFT_PACKAGE
@testable import HTMLParser
#else
@testable import Aztec
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is even more confusing to me… why do we import one package in one context (#if SWIFT_PACKAGE) and a different one in another? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After the explanation above, this should be clearer.

This test only exercises code that is part of the HTMLParser library. In SwiftPM that is a standalone module. But when building for CocoaPods, that's part of Aztec.

@mokagio mokagio merged commit 41327b9 into develop Jun 16, 2025
4 checks passed
@mokagio mokagio deleted the mokagio/extract-html-parser branch June 16, 2025 04:17
mokagio added a commit that referenced this pull request Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants