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

React-native-vector-icons not working in ios

Open shubhanshubb opened this issue 11 months ago • 12 comments

"I'm currently working on a React Native project (version 0.73.2) and encountering an issue with react-native-vector-icons integration. Despite following the installation steps (npm install --save react-native-vector-icons followed by pod install), the RNVectorIcons library does not seem to be added to my Podfile.lock or properly linked in my Xcode project. Auto-linking should work with my React Native version, but it appears to be missing. Is there a known issue or step I'm overlooking for React Native 0.73.2?"

shubhanshubb avatar Mar 20 '24 13:03 shubhanshubb

have you found any solution for this yet?

tarangshah19 avatar Apr 01 '24 04:04 tarangshah19

Similar issues reported on this older issue https://github.com/oblador/react-native-vector-icons/issues/1317 (though I think it is better that you created a new issue).

I am working on a fresh new react-native app and icons were working just fine. I just stumbled upon this problem after i ran pod install and the output contained:

Removing RNVectorIcons

My package.json

  "dependencies": {
    "react": "18.2.0",
    "react-native": "0.73.6",
    "react-native-vector-icons": "^10.0.3"
  },

The project was created by my Android-colleague. Then I cloned our project on my mac and went though the installation steps for react-native-vector-icons (adding the Fonts to the iOS project file) and the icons were working fine. Until now when I ran pod install and it removed RNVectorIcons.

I added RNVectorIcons to my ios/Podfile and re-ran pod install and it is working again.

target 'MyApp' do
  config = use_native_modules!

  use_react_native!(
    # ....
  )

  target 'MyAppTests' do
    # ....
  end

  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

  post_install do |installer|
    # ....
  end
end

I cannot see that it would have been there in my git history.

I wonder:

  • Is npm install react-native-vector-icons supposed to add RNVectorIcons to the Podfile?
  • Or is the pod added another way?
  • How is cocoapods supposed to know it should add RNVectorIcons?
  • May XCode or something else have added RNVectorIcons to the Podfile on the first build (which would explain why it worked to begin with) but somehow did not save the file?
  • I could also have inadvertently removed the changes to the Podfile after install (though I don't think I did)

durandt avatar Apr 25 '24 14:04 durandt

@durandt You should not need to add anything to the Podfile. cocapods should detect the podspec in the node_modules package.

Are using able to share your entire Podfile?

johnf avatar Apr 27 '24 00:04 johnf

@johnf sure:

# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

platform :ios, min_ios_version_supported
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

target 'MyApp' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    :flipper_configuration => flipper_config,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'MyAppTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
  end
end

Git history says file hasn't changed since it was created with npx react-native@latest init MyApp around April 11th. (react native version would have been 0.73.6)

durandt avatar Apr 27 '24 08:04 durandt

same issue counter any solution?

anastobe avatar May 06 '24 11:05 anastobe

Similar issues reported on this older issue #1317 (though I think it is better that you created a new issue).

I am working on a fresh new react-native app and icons were working just fine. I just stumbled upon this problem after i ran pod install and the output contained:

Removing RNVectorIcons

My package.json

  "dependencies": {
    "react": "18.2.0",
    "react-native": "0.73.6",
    "react-native-vector-icons": "^10.0.3"
  },

The project was created by my Android-colleague. Then I cloned our project on my mac and went though the installation steps for react-native-vector-icons (adding the Fonts to the iOS project file) and the icons were working fine. Until now when I ran pod install and it removed RNVectorIcons.

I added RNVectorIcons to my ios/Podfile and re-ran pod install and it is working again.

target 'MyApp' do
  config = use_native_modules!

  use_react_native!(
    # ....
  )

  target 'MyAppTests' do
    # ....
  end

  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

  post_install do |installer|
    # ....
  end
end

I cannot see that it would have been there in my git history.

I wonder:

  • Is npm install react-native-vector-icons supposed to add RNVectorIcons to the Podfile?
  • Or is the pod added another way?
  • How is cocoapods supposed to know it should add RNVectorIcons?
  • May XCode or something else have added RNVectorIcons to the Podfile on the first build (which would explain why it worked to begin with) but somehow did not save the file?
  • I could also have inadvertently removed the changes to the Podfile after install (though I don't think I did)

tanks it's work

eko9x9 avatar May 22 '24 18:05 eko9x9

I have the same Issue.

Tried installing React-Native-Vector-Icons 10.0.3 in my RN 0.72 project. worked fine, but when I run the same version in RN version 0.73.6, it tells me the same as @durandt: Downloading dependencies Removing RNVectorIcons

I also tried newest version: 10.1.0 - Also no luck with RN version 0.73.6

Unfortuntely I'm unable to replicate this. If someone can share a git repo or send me something privately I'll be happy to debug

johnf avatar Jun 10 '24 14:06 johnf

Same issue with latest react-native-vector-icon and RN 0.74.2

Confirm @durandt 's manual update to Podfile fixes it: https://github.com/oblador/react-native-vector-icons/issues/1604#issuecomment-2077364376

l3utterfly avatar Jun 12 '24 03:06 l3utterfly

Same issue with latest react-native-vector-icon and RN 0.74.2

Confirm @durandt 's manual update to Podfile fixes it: #1604 (comment)

By adding that line to the Podfile, it's installed, but then when building the App, I get the error: 'error: Multiple commands produce '/path/of/the/project/ios/build/NameOfTheProject/Build/Products/Debug-iphonesimulator/NameOfTheProject.app/Zocial.ttf':'.

What's the correct way to configure it?

I'm using these versions:

"react": "18.2.0",
"react-native": "0.74.5",
"react-native-vector-icons": "^10.1.0"

crico avatar Aug 14 '24 17:08 crico

getting the same issue

      "react": "18.3.1",
      "react-native": "^0.75.1",
      "react-native-vector-icons": "^10.1.0"

singhJasvinder101 avatar Aug 16 '24 16:08 singhJasvinder101

I don't know if this will help any of you.

I upgraded to expo 51 and installed @react-native/assets-registry and all my assets and icons stopped working.

I removed the dependency on @react-native/assets-registry and all of my stuff starting working again.

"@expo/vector-icons": "^14.0.0",
"expo": "^51.0.31",
"react-native": "0.74.5",

Here is where I got a clue: https://x.com/hirbod_dev/status/1798178985463181598?s=46&t=BJ6679qzsf66cZNyHJdrlA

dpitre avatar Aug 28 '24 14:08 dpitre

Same issue, anyone found a fix ? Sometimes it works on simulator but not on device for FontAwesome6

"expo": "^51.0.0", "react-native": "0.74.5", "react-native-vector-icons": "^10.1.0",

MelMayssonOwen avatar Aug 30 '24 16:08 MelMayssonOwen

this was happening to me because i had a "leftover" (?) react-native.config.js which disabled react-native-vector-icons for ios remove this file if it looks like this and you're gettint rnvi removed during pod install

module.exports = {
  dependencies: {
    'react-native-vector-icons': {
      platforms: {
        ios: null,
      },
    },
  },
};

jbrodriguez avatar Sep 01 '24 23:09 jbrodriguez

Any fix ? I'm having some issues with certain icons after updating react native

MelMayssonOwen avatar Sep 02 '24 14:09 MelMayssonOwen

ALready fixed

shubhanshubb avatar Sep 02 '24 14:09 shubhanshubb

ALready fixed

what is the fix?

crico avatar Sep 03 '24 07:09 crico

the only icons that work reliably for me are fontAwesome6

I’m on the latest version and tried every fix

MelMayssonOwen avatar Sep 03 '24 08:09 MelMayssonOwen

Definately not fixed. Using 10.1.0 on ReactNaive 0.75.2

haswalt avatar Sep 05 '24 17:09 haswalt