-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Move xcdatamodeld
into WordPressData
#24166
base: trunk
Are you sure you want to change the base?
Conversation
See how https://buildkite.com/automattic/wordpress-ios/builds/25994 failed: ``` error: Build input file cannot be found: '/opt/ci/builds/builder/automattic/wordpress-ios/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/WordPress Alpha/BuildProductsPath/Release-Alpha-iphoneos/WordPressDataObjC.o'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it? (in target 'WordPress' from project 'WordPress') ```
Not sure how it was working before — and in CI too, see https://buildkite.com/automattic/wordpress-ios/builds/25995 My only guess is that the file became available in the DerivedData somehow because the Swift package importing it was built before the app targets? Odd...
It was needed just because there was no file in the package yet, but we've addressed it whenw e moved `CoreDataService` in there.
So we can use it next in WordPressData.
Generated by 🚫 Danger |
<entity name="BloggingPrompt" representedClassName=".BloggingPrompt" syncable="YES"> | ||
<entity name="BloggingPrompt" representedClassName="WordPressData.BloggingPrompt" syncable="YES"> |
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.
public let modelURL: URL = { | ||
guard let url = Bundle.module.url(forResource: "WordPress", withExtension: "momd") else { | ||
fatalError("Cannot find model file.") | ||
} | ||
return url | ||
}() | ||
|
||
public func urlForModel(name: String, in directory: String?) -> URL? { | ||
let bundle = Bundle(for: TemporaryDummyClassToPickUpModule.self) | ||
var url = bundle.url(forResource: name, withExtension: "mom", subdirectory: directory) | ||
|
||
if url != nil { | ||
return url | ||
} | ||
|
||
let momdPaths = bundle.paths(forResourcesOfType: "momd", inDirectory: directory) | ||
momdPaths.forEach { (path) in | ||
if url != nil { | ||
return | ||
} | ||
url = bundle.url(forResource: name, withExtension: "mom", subdirectory: URL(fileURLWithPath: path).lastPathComponent) | ||
} | ||
|
||
return url | ||
} |
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.
These free functions should go into an object at some point.
It was just simpler to chuck them in here at this stage while I figure things out.
Also, I'd like to think there will be no need to have them public
once all the types involved in setting up the Core Data stack have been moved.
|
App Name | ![]() |
|
Configuration | Release-Alpha | |
Build Number | pr24166-b94d69d | |
Version | 25.8 | |
Bundle ID | com.jetpack.alpha | |
Commit | b94d69d | |
App Center Build | jetpack-installable-builds #10637 |
|
App Name | ![]() |
|
Configuration | Release-Alpha | |
Build Number | pr24166-b94d69d | |
Version | 25.8 | |
Bundle ID | org.wordpress.alpha | |
Commit | b94d69d | |
App Center Build | WPiOS - One-Offs #11606 |
Have you tried overriding an Objective-C class name for the managed objects written in Swift?
|
81890b9
to
57a9e60
Compare
Part of #24165
Note
Work in Progress. So far:
xcdatamodeld
folder into the module and updated the code that referenced its URL to read it from the moduleBloggingPrompt
(apparently the first model to load at runtime). The error was withFatal error: NSArray element failed to match the Swift Array Element type . Expected BloggingPrompt got NSManagedObject
.BloggingPrompt
to WordPressDataFatal error: NSArray element failed to match the Swift Array Element type . Expected BloggingPrompt got NSManagedObject
I don't like this solution because it would require editing the schema for each model. Besides, the compiler (or whichever piece is involved in going from the schema to the binary) should be able to inject the correct module name without hardcoding.
Leaving this up as a draft so that others can look at it.
The next thing I'll try will be to move more of the components involved in making the Core Data fetch request, the
NSManagedObjectContext
in particular, and see if it gets the namespace resolution to work without hardcoding.Fixes #
To test:
Regression Notes
Potential unintended areas of impact
What I did to test those areas of impact (or what existing automated tests I relied on)
What automated tests I added (or what prevented me from doing so)
PR submission checklist:
RELEASE-NOTES.txt
if necessary.Testing checklist: