Skip to content

Convert WordPressData to SwiftPM target#25377

Draft
kean wants to merge 1 commit intotrunkfrom
task/move-wpdata
Draft

Convert WordPressData to SwiftPM target#25377
kean wants to merge 1 commit intotrunkfrom
task/move-wpdata

Conversation

@kean
Copy link
Contributor

@kean kean commented Mar 13, 2026

Remaining Issues

Class Mapping

Crash when using the non-objc classes that represent entities:

  let name = BlogSettings.classNameWithoutNamespaces()
  let entity = NSEntityDescription.insertNewObject(forEntityName: name, into: context)
  return entity as! BlogSettings
  Could not cast value of type 'NSManagedObject_BlogSettings_3' (0x600008d89530) to 'WordPressData.BlogSettings' (0x113c53088).
Could not cast value of type 'NSManagedObject_BlogSettings_3' (0x600008d89530) to 'WordPressData.BlogSettings' (0x113c53088).
CoreSimulator 1051.17.8 - Device: iPhone 17 Pro (B8A3EF1E-2688-49AA-9703-2C82D08F1E37) - Runtime: iOS 26.2 (23C54) - DeviceType: iPhone 17 Pro

Before moving these types to SwiftPM, the class names were:

entity	WordPressData.BlogSettings	0x0000600002124a00

After the move:

entity	NSManagedObject_BlogSettings_3	0x00006000023ae490

Explanation:

When a Core Data entity's managedObjectClassName is set to something like BlogSettings, Core Data looks it up in the ObjC runtime. In an Xcode framework
target, Swift classes are automatically registered as ModuleName.ClassName (e.g., WordPressData.BlogSettings). But SwiftPM targets don't auto-register
Swift classes with the ObjC runtime the same way — unless the class has an explicit @objc annotation.

When Core Data can't find the class, it dynamically generates a generic NSManagedObject subclass (hence NSManagedObject_BlogSettings_3), and the cast
fails.

The fix: Add @objc(ClassName) to each affected managed object subclass. This explicitly registers the class with the ObjC runtime under a stable name
that Core Data can find.

@dangermattic
Copy link
Collaborator

3 Warnings
⚠️ Modules/Package.swift was changed without updating its corresponding Package.resolved.

If the change includes adding, removing, or editing a dependency please resolve the Swift packages as appropriate to your project setup (e.g. in Xcode or by running swift package resolve).

If the change to the Package.swift did not modify dependencies, ignoring this warning should be safe, but we recommend double checking and running the package resolution just in case.
.

⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@sonarqubecloud
Copy link

@wpmobilebot
Copy link
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

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