-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Move model files from apps targets to WordPressData #24378
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
base: trunk
Are you sure you want to change the base?
Move model files from apps targets to WordPressData #24378
Conversation
Generated by 🚫 Danger |
5e4258a
to
8b47455
Compare
@@ -0,0 +1 @@ | |||
// Here only to have the matching .m where to define the DDLogLevel value. |
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.
Might not even be necessary. Gotta try that...
#ifndef WordPress_Swift_h | ||
#define WordPress_Swift_h | ||
// FIXME: Defined here to avoid compilation errors while files are migrated over... | ||
#endif /* WordPress_Swift_h */ |
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.
Should be able to remove this now...
@@ -11,7 +11,8 @@ public extension Blog { | |||
/// - Warning: this method doesn't know if a Jetpack blog has the JSON API disabled. | |||
@objc | |||
var wordPressComRestApi: WordPressComRestApi? { | |||
account?.wordPressComRestApi | |||
// FIXME: We are banking on the fact that by the time a consumer reads this, WPAccount will already have initialized its API client instance. | |||
account?._private_wordPressComRestApi |
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.
Maybe we could decouple WPAccount
wordPressComRestApi
from WordPressAuthenticator using... a Notification
?
WordPress-iOS/WordPress/Classes/Models/WPAccount+RestApi.swift
Lines 12 to 20 in b14619b
@objc var wordPressComRestApi: WordPressComRestApi? { | |
if let api = _private_wordPressComRestApi { | |
return api | |
} | |
guard !authToken.isEmpty else { | |
DispatchQueue.main.async { | |
WordPressAuthenticationManager.showSigninForWPComFixingAuthToken() | |
} | |
return nil |
WordPress-iOS/WordPress/Classes/Models/WPAccount+RestApi.swift
Lines 27 to 38 in b14619b
private func makeWordPressComRestApi() -> WordPressComRestApi { | |
let api = WordPressComRestApi.defaultApi( | |
oAuthToken: authToken, | |
userAgent: WPUserAgent.defaultUserAgent(), | |
localeKey: WordPressComRestApi.LocaleKeyDefault | |
) | |
api.setInvalidTokenHandler { [weak self] in | |
guard let self else { return } | |
self.authToken = nil | |
WordPressAuthenticationManager.showSigninForWPComFixingAuthToken() |
I suggest a Notification
because I don't think injecting callbacks or using a delegate would be feasible with a model like this.
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.
See #24392
710846d
to
8e8a6d7
Compare
WordPress/Classes/Models/Blog/Blog.m
Outdated
return [self supportsRestApi] && [JetpackFeaturesRemovalCoordinator jetpackFeaturesEnabled]; | ||
// FIXME: See https://github.com/wordpress-mobile/WordPress-iOS/pull/24332 | ||
// return [self supportsRestApi] && [JetpackFeaturesRemovalCoordinator jetpackFeaturesEnabled]; | ||
return [self supportsRestApi]; | ||
case BlogFeatureTenor: | ||
return [JetpackFeaturesRemovalCoordinator jetpackFeaturesEnabled]; | ||
// FIXME: See https://github.com/wordpress-mobile/WordPress-iOS/pull/24332 | ||
// return [JetpackFeaturesRemovalCoordinator jetpackFeaturesEnabled]; | ||
return NO; |
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.
#24393 should address this.
@@ -234,13 +235,14 @@ private extension ContextManager { | |||
fatalError("Can't create object model named \(modelName) at \(modelFileURL)") | |||
} | |||
|
|||
let startupEvent = SentryStartupEvent() | |||
// FIXME: Import the Sentry stuff, too — But it accesses the app delegate! | |||
// let startupEvent = SentryStartupEvent() |
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.
@crazytonyli is this ContextManager
Sentry logging something that we need, or is it by any chance something that we added at the time of adoption just to monitor 🤞 ?
Being able to just chop it off would simplify things.
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.
See also p1743115991824589/1743090023.463689-slack-C08HQR4C2TS
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 sorry I missed this message. I don't think I added the events. It's very likely that they were there before my time. I doubt these events ever occur on production. I did a quick search on Sentry and don't see any related events. However, I think it's best to keep them in case we introduce some issues to the Core Data layer. At the bare minimum, we can send the events to the app via a notification.
8e8a6d7
to
caa0730
Compare
caa0730
to
f15a95b
Compare
f0b8baf
to
9747c86
Compare
1b81897
to
c5f7a76
Compare
|
App Name | Jetpack | |
Configuration | Release-Alpha | |
Build Number | 27506 | |
Version | PR #24378 | |
Bundle ID | com.jetpack.alpha | |
Commit | 200048d | |
Installation URL | 6c16vdi27pi00 |
|
App Name | WordPress | |
Configuration | Release-Alpha | |
Build Number | 27506 | |
Version | PR #24378 | |
Bundle ID | org.wordpress.alpha | |
Commit | 200048d | |
Installation URL | 04hhmfjhmi7i0 |
c5f7a76
to
35a3999
Compare
35a3999
to
85779b2
Compare
Undefined symbol: _OBJC_CLASS_$_DDLog
Via ``` find WordPress/WordPressTest \ -name "*.swift" \ -type f \ -exec perl -i -0pe 's/(@testable import WordPress\n)(\nclass (\w+): CoreDataTestCase \{)/\1\@testable import WordPressData\n\nclass \3: CoreDataTestCase {/g' \ {} \; ``` and ``` find WordPress/WordPressTest \ -name "*.swift" \ -type f \ -exec perl -i -0pe 's/(@testable import WordPress\n)(\nfinal class (\w+): CoreDataTestCase \{)/\1\@testable import WordPressData\n\nfinal class \3: CoreDataTestCase {/g' \ {} \; ```
…tAPI Same rationale as 09990b8
930dc78
to
161a708
Compare
Triggered by a few errors like ``` In file included from /Users/gio/Developer/a8c/wpios/WordPress/Classes/ViewRelated/Suggestions/SuggestionsTableViewCell.m:3: /Users/gio/Developer/a8c/wpios/DerivedData/WordPress/Build/Intermediates.noindex/WordPress.build/Debug-iphonesimulator/Keystone.build/DerivedSources/Keystone-Swift.h:295:9: fatal error: module 'WebKit' not found 295 | @import WebKit; | ~~~~~~~^~~~~~ ``` which I got after linking WordPressData against Keystone and moving all the sources there.
Apparently unnecessary, see #24420 (comment)
Via ``` sed -i '' -E 's/representedClassName="(WordPress)?(\.)?([^"]+)"/representedClassName=".\3"/g' \ Sources/WordPressData/Resources/WordPress.xcdatamodeld/WordPress\ 155.xcdatamodel/contents ``` which switched to "Current Product Module" but resulted in unit tests failure in WordPressData, followed by ``` ➜ sed -i '' -E 's/representedClassName="\.([^"]+)"/representedClassName="\1"/g' \ Sources/WordPressData/Resources/WordPress.xcdatamodeld/WordPress\ 155.xcdatamodel/contents ```
161a708
to
f851bc5
Compare
The current status here is that we are up to date with I tried switching all to global namespace module, but it did not work 172031e The situation is made a bit more complex by having a variety of ways with which we instantiate entities ![]() Given there are only three possible core data module settings, one would expect it to be straightforward to try them and find the best one. Alas, it's proven a fiddly task for me. I'll spend a bit more time on this today in the hope of getting to the bottom of it before hading over to @kean who offered to take over the last bits of integration. |
Done via ``` find . \ \( -path './DerivedData' -o -path './.git' -o -path './vendor' \) \ -prune -o -type f -name "*.swift" \ -exec sed -i '' -E 's/forEntityName: "([A-Za-z_][A-Za-z0-9_]*)"/forEntityName: \1.entityName()/g' {} + ```
Done via ``` find . \ \( -path './DerivedData' -o -path './.git' -o -path './vendor' \) \ -prune -o -type f -name "*.swift" \ -exec sed -i '' -E 's/forEntityName: NSStringFromClass\(([A-Za-z_][A-Za-z0-9_]*)\.self\)/forEntityName: \1.entityName()/g' {} + ``` The goal is to have a single way to get the entity name so we can adapt it to the new WordPressData setup in one go.
The goal is to have a single way to get the entity name so we can adapt it to the new WordPressData setup in one go.
Done via ``` find . \( -path './DerivedData' -o -path './.git' -o -path './vendor' \) \ -prune -o -type f -name "*.swift" \ -exec sed -i '' -E 's/forEntityName: ([A-Za-z_][A-Za-z0-9_]*)\.classNameWithoutNamespaces\(\)/forEntityName: \1.entityName()/g' {} + ``` The goal is to have a single way to get the entity name so we can adapt it to the new WordPressData setup in one go.
f851bc5
to
1deadc6
Compare
* Move remaining types to WordPressData * Use Current Module for Swift-only types * Fix ReaderTeamTopic compilation * Add missing class names * Remove unused SiteInfo * Add Bundle.wordPressData and update DataMigratorTests * Update CoreDataMigrationTests * Fix unit tests (AppEnvironment required)
|
Builds on top of #24374, with standalone commits from #24375 and #24376, part of #24165.