-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
"react-native link" silently fails to link non-font assets #16446
Comments
Hi @andriichernenko! This is an expected behavior (so far). I don't see how |
@Kureev I have a large text file (~500 KB, it's a document with license information for the open-source libraries we are using) which I would like to update automatically and include in the app as an asset. Later in code I want to be able to access this file, read and display its contents without worrying about the platform-specific things. There are many other file types which developers might need to include as assets (videos, sounds; some people, for example, might want to include an SQLite database), so I was surprised when I found out that The logic which does all the heavy lifting (like adding the files to a group in iOS project and to the Copy Bundle Resources phase) is already in place, I don't think it will be too much work to handle additional file types. On the RN side of things it would be nice to have something like AssetManager on Android, but for now we could use |
Oh, don't get me wrong: I have no issues adding new functionality to handle this. For some reason I had a feeling that for iOS it requires additional logic to register a font (not sure if its true, fyi @grabbou). Based on your explanation, I feel like you want to use What do you think, Mike? |
I have this problem as well. I'm still confused with the same question as @andriichernenko said: why does In my situation, I have a custom RN library with some license files and other static files (which need to be added into Copy Bundle Resources phase if you want to use it). If I want to use this library in my RN project, I must copy these files and add them to Copy Bundle Resources manually. So... Why not |
@andriichernenko we added assets linking functionality to With non-font files, like Would you mind telling why the above would not work for you? |
@grabbou Even if Okay, even if |
@andriichernenko in regards to this:
Just start your packager this way:
Returns a number that is a reference to an asset in AssetRegistry - place where assets are stored along with additional information about their scales, location - an implementation detail.
Will debug this in the morning to see how to read that file. I've done it once, but it's been a while. |
Is there a chance it will be added?
Oh, I see. UPD: never mind, |
I think yeah, shouldn't be an issue. Just submit PR adding it if you think it's a reasonable default. I think it would be cool to be able to import
I don't have time to dig into it, but look how Let me know if you need any further assistance, happy to help. As I said, I don't have enough time to dig into it myself. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
I wrote react-native-asset which solves just that.
|
It helps me . https://stackoverflow.com/a/49457267/2666902 |
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 7.10.0
Yarn: 0.27.5
npm: 4.2.0
Watchman: 4.7.0
Xcode: Xcode 9.0.1 Build version 9A1004
Android Studio: 2.3 AI-162.4069837
Packages: (wanted => installed)
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
react-native: 0.48.4 => 0.48.4
Steps to Reproduce
./assets/fonts/file.ttf
./assets/text/file.txt
).package.json
:react-native link
.Expected Behavior
All asset files are copied to iOS and Android projects. If that's not possible, an error or warning is reported in console. If for some reason that's not possible either, this behavior is documented.
Actual Behavior
file.ttf
is copied as expected.file.txt
is not copied, console reports that linking was successful, there are no errors or warnings.Reproducible Demo
https://github.com/andriichernenko/rnpm-non-font-assets-repro
Here's the code in
/node_modules/react-native/local-cli/link/ios/copyAssets.js
that copies the assets:As the comment says, "the only types of files that are handled are fonts". One would think that other types are handled somewhere else, but that's not the case.
Seems like this has been reported before (see #14468). There's also a related PR: #12047, but it wasn't merged.
Are there any plans to implement handling of resources of all types?
The text was updated successfully, but these errors were encountered: