-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Integrate WordPressKit via source code #24771
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
Without this, Objective-C APIs that contains Swift types in WordPressKit will not be available to Swift code in the share extension targets.
Generated by 🚫 Danger |
|
App Name | Jetpack | |
Configuration | Release-Alpha | |
Build Number | 28694 | |
Version | PR #24771 | |
Bundle ID | com.jetpack.alpha | |
Commit | 0d83ce8 | |
Installation URL | 5ikedsaa16l0g |
|
App Name | WordPress | |
Configuration | Release-Alpha | |
Build Number | 28694 | |
Version | PR #24771 | |
Bundle ID | org.wordpress.alpha | |
Commit | 0d83ce8 | |
Installation URL | 0agojf7cbrf8g |
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.
In addition to the OTHER_SWIFT_FLAGS solution suggested in the above discussion, we also need to make sure the WordPressKit module is imported into the Xcode target's bridging header.
Interesting. I didn't know about that limitation. It looks like we'll have to eliminate WordPressKitObjC
and rewrite it to Swift or at least the parts the depend on Swift models (probably a better option).
@@ -1,5 +1,6 @@ | |||
import Foundation | |||
import WordPressShared | |||
@preconcurrency import WordPressKitModels |
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.
(nit) WordPressKit should probably re-export WordPressKitModels for convenience
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.
They are already re-exported. I have removed this import, and a couple of others too, in a8146d6.
|
Description
Note
Review commit by commit. There are not many actual code changes.
wordpress-mobile/WordPressKit-iOS#845 sorted out the dependencies among the Objective-C and Swift code in WordPressKit. We ended up having four modules:
The
WordPressKitObjC
module contains "remote service" types that make API calls and return model instances. Some of those model types are defined in Swift code. For example,-[BlogServiceRemoteREST syncBlogSettingsWithSuccess:failure:]
returnsRemoteBlogSettings
, which is in Swift.One of the problems I encounter during this integration is that the Objective-C API like the
syncBlogSettings
is not available to the app's Swift code, because the compiler somehow does not see the concrete type ofRemoteBlogSettings
(which is forward-declared in theBlogServiceRemoteREST.h
header file). Here is a discussion about this issue on the Swift forum.In addition to the
OTHER_SWIFT_FLAGS
solution suggested in the above discussion, we also need to make sure the WordPressKit module is imported into the Xcode target's bridging header.However, we can't provide either of these settings to Swift Package Manager targets. And as a result of that, this
getLikesForPostID
call in the JetpackStats module fails to compile. I ended up having to translate thegetLikesForPostID
Objective-C code into Swift. Luckily, there is only one such case, so we don't need to do a whole lot of unnecessary translation.Next step
First, review the WordPressKit changes in wordpress-mobile/WordPressKit-iOS#846. If both PRs look good, I'll merge this PR and close the WordPressKit one.
Next, I'll create a new PR to copy the WordPressKit code into this repo, which we can merge without reviewing.
After that, I'll create a test target in this Xcode project to run the WordPressKit unit tests. It needs to be in Xcode, instead of Modules/Package.swift, because we will likely need to provide the
OTHER_SWIFT_FLAGS
build setting and the bridging header.