-
Notifications
You must be signed in to change notification settings - Fork 149
Extract HTMLParser in dedicated library
#1412
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
Conversation
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.
4465a5c to
ade72c7
Compare
ade72c7 to
1b98c11
Compare
No idea how the resizing might be failing...
ab93da2 to
1854660
Compare
|
CI is failing with 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 |
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
bfe41ed to
38c3770
Compare
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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)], |
There was a problem hiding this comment.
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.
|
@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
left a comment
There was a problem hiding this 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.
| #if SWIFT_PACKAGE | ||
| @testable import HTMLParser | ||
| #endif |
There was a problem hiding this comment.
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)? 🤔
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #if SWIFT_PACKAGE | ||
| @testable import HTMLParser | ||
| #else | ||
| @testable import Aztec | ||
| #endif |
There was a problem hiding this comment.
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? 🤔
There was a problem hiding this comment.
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.
Follow up to the conversation on #1412 (comment)
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/andTests/root folders that SwiftPM expects. To keep thePackage.swiftandpodspecs 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.
CHANGELOG.mdif necessary. – N.A. many files were moved, but the source change was minimal.