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.46k stars 2.13k forks source link

Monorepo iOS build failure #1666

Closed ghost closed 1 month ago

ghost commented 1 month ago

Environment

Lib Versions

    "@react-native-vector-icons/ant-design": "^4.4.2-alpha.28",
    "@react-native-vector-icons/common": "^0.0.1-alpha.23",
    "@react-native-vector-icons/entypo": "^1.0.1-alpha.28",
    "@react-native-vector-icons/feather": "^4.29.2-alpha.28",
    "@react-native-vector-icons/fontawesome": "^4.7.0-alpha.28",
    "@react-native-vector-icons/fontawesome5": "^5.15.4-alpha.31",
    "@react-native-vector-icons/fontawesome6": "^6.6.0-alpha.31",
    "@react-native-vector-icons/fontisto": "^3.0.4-alpha.28",
    "@react-native-vector-icons/foundation": "^2.0.0-alpha.27",
    "@react-native-vector-icons/ionicons": "^7.4.0-alpha.30",
    "@react-native-vector-icons/material-design-icons": "^7.4.47-alpha.28",
    "@react-native-vector-icons/material-icons": "^0.0.1-alpha.28",
    "@react-native-vector-icons/octicons": "^19.11.0-alpha.28",
    "@react-native-vector-icons/simple-line-icons": "^2.5.5-alpha.28",
    "node":"v18.20"
    "npm":"10.7.0"

Podfile

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

# 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

$RNFirebaseAsStaticFramework = true

platform :ios, 13.4
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

require 'json'
podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {}

target 'GulfTalentTest' do
  use_expo_modules!
  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
  config = use_native_modules!

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'GoogleDataTransport', :modular_headers => true
  pod 'nanopb', :modular_headers => true

  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}/.."
  )

  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
    )

    # Needed to install proper dependencies on Apple Silicon systems
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
      end
    end

    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|
      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
        resource_bundle_target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end

    # Workaround `Cycle inside FBReactNativeSpec` error for react-native 0.64
    # Reference: https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933
    installer.pods_project.targets.each do |target|

      if (target.name&.eql?('FBReactNativeSpec'))
        target.build_phases.each do |build_phase|
          if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
            target.build_phases.move(build_phase, 0)
          end
        end
      end

      if target.name == 'Flipper'
        file_path = 'Pods/Flipper/xplat/Flipper/FlipperTransportTypes.h'
        contents = File.read(file_path)
        unless contents.include?('#include <functional>')
          File.open(file_path, 'w') do |file|
            file.puts('#include <functional>')
            file.puts(contents)
          end
        end
      end

    end
  end
end

Description

We recently performed a react native upgrade to 0.73.6. Upon completing this upgrade we noticed that our icons were not displayed from react-native-vector-icons when building the android build via EAS. iOS worked perfectly on this point and we could build the app properly. To overcome the Android issues after trial and error we decided to use the new monorepo and it worked well. The icons were displayed after building with EAS. But now our iOS builds fail to build with the following errors `/node_modules/@react-native-vector-icons/common/ios/generated/RNVectorIconsSpec/EventEmitters.h:12:10: fatal error: 'react/renderer/components/view/ViewEventEmitter.h' file not found

include <react/renderer/components/view/ViewEventEmitter.h>and/node_modules/@react-native-vector-icons/common/ios/generated/RNVectorIconsSpecJSI.h:12:10: fatal error: 'ReactCommon/TurboModule.h' file not found

include <ReactCommon/TurboModule.h>`

We have removed node_modules/Pods/Podfile.lock and installed everything again. Also tried the bundle installer bundle install and bundle exec pod install as instructed here but we weren't successful. Any help is gratefully appreciated

johnf commented 1 month ago

@gttesting007 I've just released a new version that treats how we deal with codegen files differently. Can you give it a try?

ghost commented 1 month ago

hey @johnf thank you for your response. I shall update the packages and try again. I will update this thread in the next 24Hrs

ghost commented 1 month ago

@gttesting007 I've just released a new version that treats how we deal with codegen files differently. Can you give it a try?

Hi @johnf Sorry for getting back so late. I have updated the app and its building now without any issues.

Thank you for your help