Skip to content
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

Incorrect module name in the compiled managed object model file (.mom) #2606

Open
vakhidbetrakhmadov opened this issue Nov 27, 2024 · 1 comment

Comments

@vakhidbetrakhmadov
Copy link
Contributor

vakhidbetrakhmadov commented Nov 27, 2024

Hi,

I have the following setup

ios_unit_test (FooTests) -> swift_library (FooTestsLib) -> swift_library (FooLib) -> apple_resource_bundle (FooBundle)

FooBundle wraps a Core Data model Foo.xcdatamodel.

A) Given module name is not explicitly set in Foo.xcdatamodel

Screenshot 2024-11-27 at 21 59 10

(Xcode view of Foo.xcdatamodel)

... representedClassName=".DBFoo" ...

(raw view of Foo.xcdatamodel/contents)

when i build unit tests, the module name in the generated .xctest/Foo.bundle/Foo.momd/Foo.mom file is incorrect FooTests__internal____test_bundle (plutil -p Foo.mom), therefore the Core Data model fails to load from unit tests.

Screenshot 2024-11-27 at 22 15 17

(Xcode view of .xcdatamodel reversed from .mom using https://github.com/atomicbird/momdec)

B) If i explicitly set module name in Foo.xcdatamodel

Screenshot 2024-11-27 at 22 01 57
... representedClassName="Foo.DBFoo" ...

when i build unit tests, the module name in the generated .xctest/Foo.bundle/Foo.momd/Foo.mom file is correct Foo, and the Core Data model successfully loads from unit tests.

Screenshot 2024-11-27 at 22 15 23

I have created a minimal repro example: https://github.com/vakhidbetrakhmadov/rules_apple/tree/vakhid/core-data-repro/examples/repro

A) Run bazelisk build //examples/repro:FooTests and examine .mom file in the generated .xctest bundle.

B) Run git apply examples/repro/module_name.patch && bazelisk build //examples/repro:FooTests and examine .mom file in the generated .xctest bundle.

@vakhidbetrakhmadov
Copy link
Contributor Author

vakhidbetrakhmadov commented Nov 27, 2024

I assume this is a bug, because Xcode is able to correctly handle either case, and also previously i used precompiled_apple_resource_bundle from rules_ios and it also worked in both cases.

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

No branches or pull requests

1 participant