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

[IOS] Add Customer resource folder for assets image

Open Creemli opened this issue 10 years ago • 1 comments

when I try to add another assets image folder, I found the path is not correct: First, we run the command : react-native bundle --assets-dest ./ReactRes --entry-file ./index.ios.js --bundle-output ios.jsbundle --platform ios --dev true --minify false it will create a folder ReactRes and put directory assets into this folder. And the images will not displayed.

When I try to debug this, I found the path in oc code is just like this: /Users/.../assets/some.png And the correct path should be /Users/...ReactRes//assets/some.png

So one of the solution maybe modify the method for building path in Image.ios.js & resolveAssetSource.js:

function getPathInArchive(asset) {
var offlinePath = getOfflinePath();
if (Platform.OS === 'android') {
if (offlinePath) {
// E.g. 'file:///sdcard/AwesomeModule/drawable-mdpi/icon.png'
return 'file://' + offlinePath + getAssetPathInDrawableFolder(asset);
}
// E.g. 'assets_awesomemodule_icon'
// The Android resource system picks the correct scale.
return assetPathUtils.getAndroidResourceIdentifier(asset);
} else {

return offlinePath + 'ReactRes/' + getScaledAssetPath(asset);

// E.g. '/assets/AwesomeModule/[email protected]'
return offlinePath + getScaledAssetPath(asset);

} }

The ReactRes folder has been defined when we run the bundle script.

What do you think of this? This could fix the issue that the assets folder has been existing in our app.

Creemli avatar Mar 11 '16 03:03 Creemli

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/ios-add-customer-resource-folder-for-assets-image

ProductPains helps the community prioritize the most important issues thanks to its voting feature. It is easy to use - just login with GitHub. GitHub issues have voting too, nevertheless Product Pains has been very useful in highlighting the top bugs and feature requests: https://productpains.com/product/react-native?tab=top

Also, if this issue is a bug, please consider sending a pull request with a fix. We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.

mkonicek avatar Jul 29 '16 23:07 mkonicek