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

Error when using *.xcdatamodeld resources #45

Open
DJean opened this issue Nov 18, 2020 · 4 comments
Open

Error when using *.xcdatamodeld resources #45

DJean opened this issue Nov 18, 2020 · 4 comments

Comments

@DJean
Copy link

DJean commented Nov 18, 2020

When the Development Pods that have resources declared by spec.resources = [...], it throws an error saying that the *. xcdatamodeld file does not exist.

Our Development Pods podspec file.

s.resources = 'Code/**/*.{xcdatamodeld}'

The issue occurred in the integration step when we generate the project file.

Errno::ENOENT - No such file or directory @ realpath_rec - /Users/dj/MyTestProject/code/ios/_Prebuild/GeneratedFrameworks/Test/Test.framework/Test.xcdatamodeld
....

I found when installing, it will overwrite original *. xcdatamodeld file, and make a soft link to the GenerateFramework/Test/Test.xcdatamodeld, but the real xcdatamodeld file is Test.framework/Test.momd

@DJean
Copy link
Author

DJean commented Nov 18, 2020

I'm not sure this is OK or not, in source_installer.rb

def install_prebuilt_framework!
    ...
    metadata.resources.each do |path|
        ...
        case File.extname(path)
        when ".xib"
          real_file_path = real_file_path.sub_ext(".nib")
          target_file_path = target_file_path.sub(".xib", ".nib")
        when ".bundle"
          next if metadata.resource_bundles.include?(File.basename(path))
          real_file_path = real_file_folder + File.basename(path) unless real_file_path.exist?
        when ".xcdatamodeld"
          next
        end
        ...
    end
end

@trinhngocthuyen
Copy link
Contributor

Hi @DJean, Thanks for reaching out and pointing out what went wrong in the code.

We acknowledge the issue when the declaration of .resources has the following extensions: xib, storyboard, xcdatamodel, xcdatamodeld, xcmappingmodel...
Your suggestion above could work in one case and can be still broken in some corner cases (for ex. when the resources are embedded inside the framework itself). We'll look into this to have a more proper fix for such extensions.

In the meantime, I would suggest changing your podspec declaration from .resources to .resource_bundle as resource_bundle is more properly handled by the plugin:

s.resource_bundle = {'<PodName>' => Code/**/*.{xcdatamodeld}'}

(of course, we need to update the swift code to load the resources from App.app/PodName.bundle/Model.momd instead of App.app/Model.momd)

Thank you!

@VaslD
Copy link

VaslD commented Nov 26, 2020

This also seems to affect Asset Catalog somehow.

I have a Podspec that defines:

s.resources = "UIKitExtensions/**/*.{xib,storyboard,xcassets}"

and regular pod install succeeds but pod binary --prebuild fails with

Errno::ENOENT - No such file or directory @ realpath_rec - /Users/vasld/Developer/BinaryPlayground/_Prebuild/GeneratedFrameworks/UIExtensions/UIExtensions.framework/Assets.xcassets

When I inspect the _Prebuild folder in Finder, I can see Assets.car in UIExtensions.framework.

@trinhngocthuyen
Copy link
Contributor

Acknowledged!
Yup. The workaround for static frameworks with s.resources (not s.resource_bundle) seems buggy

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

3 participants