react-native-asset icon indicating copy to clipboard operation
react-native-asset copied to clipboard

fix: Adjust asset paths on iOS to resolve relative to the Resources group

Open cayleyh opened this issue 1 year ago • 1 comments

https://github.com/unimonkiez/react-native-asset/issues/43

cayleyh avatar Jun 15 '23 18:06 cayleyh

While this improves the default handling of issues like https://github.com/unimonkiez/react-native-asset/issues/43 and using react-native-assets with other RN boilerplates, it does not address the underlying issue:

Xcode project groups can be arbitrarily moved around in Xcode, and they are not necessarily related to the layout of the underlying source code. Most teams over a certain size or app complexity will have adjusted their Resource groups to more cleanly organize their projects.

When react-native-assets links assets with Xcode, it just shoves everything in the the Resource group (either the first one it can find, or by creating one in the project top-level). The assets are added as Relative to Group --> ie. the path of the asset is relative to the nesting of the group in the Xcode project.

This can cause different errors, such as in cases where a deeply nested Resources group already exists, or if the team later moves their Resources group.

A better change would be to link the assets as being Relative to Project. However, based on my cursory reading of the cordova-node-xcode project tools, this is not possible. We would need to be able to set the sourceTree of an individual file from <group> to SOURCE_ROOT.

It's also worth noting that unlinking is broken in projects that require manual adjustments, and if you unlink some assets then re-add them, you could have duplicates added to your Xcode project.

cayleyh avatar Jun 15 '23 18:06 cayleyh