Incorrect file path for font assets on iOS
TheHeumanModean opened this issue · comments
TheHeumanModean commented
Context
used ignite boilerplate this potentially changes iOS folder structure
Steps to reproduce
- added custom font to
./assets/fonts
|
|_ assets
|_|_ fonts
|_|_|_ font-name
|_|_|_|_ ttf-file-name.ttf
- changed
react-native.config.js
module.exports = {
assets: ['./assets/fonts/'],
}
- ran
npx react-native-asset
- android builds fine and fonts are correct
- iOS fails build with
No such file or directory found
on each of my ttf files
Steps that I did to fix
- in the file
ios/projectName.xcodeproj/project.pgxproj
under the/* Begin PBXFileReference section */
replaced every../assets/fonts/font-name/ttf-file-name.ttf
with an extra ../ to make../../assets/fonts/font-name/ttf-file-name.ttf
before
197A7A355453429EBCF9A29A /* ttf-file-name.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ttf-file-name.ttf"; path = "../assets/fonts/font-name/ttf-file-name.ttf"; sourceTree = "<group>"; };
after
197A7A355453429EBCF9A29A /* ttf-file-name.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ttf-file-name.ttf"; path = "../../assets/fonts/font-name/ttf-file-name.ttf"; sourceTree = "<group>"; };
Shankar morwal commented
I have same problem. App builds but fonts do not work in ios. When i apply this fix, build start to fail.
Yuval Saraf commented
Not sure what the problem is, happily merge whatever PR you do to fix this
Cayley Humphries commented
The problem here is that the cordova-node-xcode
library's project.addResourceFile()
is to add the resource as "Relative to Group" in Xcode, which is "/Resources".
I'm investigating if there is an option on addResourceFile()
that can set it relative to the project. I'll have a PR with a potential solution for discussion shortly.