oblador / react-native-vector-icons

Customizable Icons for React Native with support for image source and full styling.
https://oblador.github.io/react-native-vector-icons/
MIT License
17.31k stars 2.12k forks source link

Isn't Auto-linking a thing in this project? #1405

Open Cmoen11 opened 2 years ago

Cmoen11 commented 2 years ago

I'm fairly new to React Native, but this installation guide has me draw questions.

For other projects I've seen, you only need to install the node module and run pod install, that's it. Why does this require you to add stuff to your podfile or use the deprecated react-link command?

I'm ok by doing any of this, but I'd like to know why this is :)

fqborges commented 2 years ago

Autolink does work (mostly).

There is something special with the assets, though. Not sure if it happens in other projects too.

To make the fonts assets available after autolinking you need to:

Android:

// somewhere in your android/app/android.gradle
// I usually put after the end, after the 'native_modules.gradle'
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

iOS

<!-- add to your Info.plist -->
<key>UIAppFonts</key>
<array>
  <string>AntDesign.ttf</string>
  <string>Entypo.ttf</string>
  <string>EvilIcons.ttf</string>
  <string>Feather.ttf</string>
  <string>FontAwesome.ttf</string>
  <string>FontAwesome5_Brands.ttf</string>
  <string>FontAwesome5_Regular.ttf</string>
  <string>FontAwesome5_Solid.ttf</string>
  <string>Foundation.ttf</string>
  <string>Ionicons.ttf</string>
  <string>MaterialIcons.ttf</string>
  <string>MaterialCommunityIcons.ttf</string>
  <string>SimpleLineIcons.ttf</string>
  <string>Octicons.ttf</string>
  <string>Zocial.ttf</string>
  <string>Fontisto.ttf</string>
</array>
leoparis89 commented 2 years ago

Autolink does work (mostly).

There is something special with the assets, though. Not sure if it happens in other projects too.

To make the fonts assets available after autolinking you need to:

Android:

// somewhere in your android/app/android.gradle
// I usually put after the end, after the 'native_modules.gradle'
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

iOS

<!-- add to your Info.plist -->
<key>UIAppFonts</key>
<array>
  <string>AntDesign.ttf</string>
  <string>Entypo.ttf</string>
  <string>EvilIcons.ttf</string>
  <string>Feather.ttf</string>
  <string>FontAwesome.ttf</string>
  <string>FontAwesome5_Brands.ttf</string>
  <string>FontAwesome5_Regular.ttf</string>
  <string>FontAwesome5_Solid.ttf</string>
  <string>Foundation.ttf</string>
  <string>Ionicons.ttf</string>
  <string>MaterialIcons.ttf</string>
  <string>MaterialCommunityIcons.ttf</string>
  <string>SimpleLineIcons.ttf</string>
  <string>Octicons.ttf</string>
  <string>Zocial.ttf</string>
  <string>Fontisto.ttf</string>
</array>

Snippet for info.plist has to be added to the Readme under "install with cocoapods section"

Nick-Lucas commented 2 years ago

Thanks @fqborges that saved me a lot of time with a freshly bootstrapped 0.68.2 app. Really was as simple as autolinking and adding that snippet.

The readme instructions are pretty confusing, why is manual installation listed first? Why is autolinking buried inside the old "link" command instructions and doesn't have the exact info.plist snippet included?

I suspect the answer is legacy related which is easy due to ecosystem churn, but perhaps the readme needs a pass to bring it up to more recent standards and simplify it somewhat?

1mike12 commented 1 year ago

So now I'm confused, I followed the instructions as written including the article linked https://medium.com/@vimniky/how-to-use-vector-icons-in-your-react-native-project-8212ac6a8f06

In the article, we're told to create a group folder and drag TTF files manually into the workspace. Is that part required or not?

Becuase reading this thread it seems like just the plist edit and pod install is needed and nothing else.