RCTConvert+AirMap. h文件未找到IOS上的React本地错误

zqdjd7g9  于 2022-12-30  发布在  React
关注(0)|答案(3)|浏览(130)

我遇到此错误。未找到RCTConvert + AirMap. h文件IOS上的React Native错误

q35jwt9p

q35jwt9p1#

我可以使用以下方法解决此问题:
1.在项目目标表头增加**$(SRCROOT)/../node_modules/react-native-maps/lib/ios/AirMaps**
1.将**pod 'react-native-google-maps', path: rn_maps_path移动到Podfile中use_native_modules**上方(之前位于其下方
1.增加:

post_install do |installer|
      //...
      installer.pods_project.targets.each do |target|
      if target.name == 'react-native-google-maps'
        target.build_configurations.each do |config|
          config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
        end
      end
      
    end
  end

1.在步骤3之后,如果仍然无法工作,请删除所有缓存(pod deintegratepod installremove derived dataclean build

k97glaaz

k97glaaz2#

最新更新

对于类似或最新的配置

"react": "17.0.1",
    "react-native": "0.64.2",
    "react-native-cli": "^2.0.1",
    "react-native-maps": "^0.28.0",

使用GoogleMap和其他Map提供程序配置React原生Map要容易得多。
自动链接不能解决这个问题,所以你必须手动告诉xcode本地代码在哪里。
1.手动将文件/文件夹添加到Xcode using these instructions here
1.最简单的。不需要转到Xcode来调整header search path

2.最简单

# Podfile

pod 'react-native-google-maps', :path => '../../../node_modules/react-native-maps/'
pod 'react-native-maps', :path => '../../../node_modules/react-native-maps/'

# These might not be necessary
# Please build without these. If could not build, add these as well
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'

AppDelegate.m文件中

#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h> // this line is alreaady there.  Add the line below
#import <GoogleMaps/GoogleMaps.h>

...

...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions // this line is alreaady there.  Add the line below
{
+  [GMSServices provideAPIKey:@"AIzaEEBBLn-PhCDDD1AnC_h66yH8LEEUkd14WW0"]; // add this line using the api key obtained from Google Console

注:
1.从谷歌控制台用你自己的API密钥替换AIzaEEBBLn-PhCDDD1AnC_h66yH8LEEUkd14WW0
1.在我的情况下,我使用的是monorepo技术,所以'../../../node_modules/react-native-maps/'。在您的情况下,它的'../node_modules/react-native-maps/'
1.* * 应使用+-符号。它们是语言定义的实体。没有类型错误**

cbjzeqam

cbjzeqam3#

这是由于这静态框架使用.你需要一些改变在你的pod文件.这里是这pod文件为react-native 0.70.6

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '13.0'
install! 'cocoapods', :deterministic_uuids => false
production = ENV["PRODUCTION"] == "1"
pod 'Google-Mobile-Ads-SDK' ,"9.12.0"
pod 'GoogleMobileAdsMediationFacebook','6.11.0.0'
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'

target 'myApp' do
  config = use_native_modules!
  $static_framework = []
  $RNFirebaseAsStaticFramework = true
  $RNGoogleMobileAdsAsStaticFramework = true
  $RNAdMobAsStaticFramework = true
  $FirebaseSDKVersion = '10.2.0'
  use_frameworks! :linkage => :static
  pre_install do |installer|
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

  installer.pod_targets.each do |pod|
    if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
      def pod.build_type;
        # Uncomment the line corresponding to your CocoaPods version
        Pod::BuildType.static_library # >= 1.9
        # Pod::Target::BuildType.static_library # < 1.9
      end
    end
  end
end

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :hermes_enabled => true,
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    # :flipper_configuration => FlipperConfiguration.enabled,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  $static_framework += [
    'react-native-maps',
    'react-native-google-maps',
    'Google-Maps-iOS-Utils',
    'GoogleMaps',
    'RNFirebaseAsStaticFramework',
    'RNGoogleMobileAdsAsStaticFramework',
    'RNAdMobAsStaticFramework'

  ]
  permissions_path = '../node_modules/react-native-permissions/ios'
  
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
  pod 'Permission-PhotoLibraryAddOnly', :path => "#{permissions_path}/PhotoLibraryAddOnly"  
  pod 'react-native-google-maps', :path => '../node_modules/react-native-maps'
  target 'myAppTest' do
    inherit! :complete
    # Pods for testing
  end

  # ****** THIS IS THE MAGIC ******
  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
        installer.pod_targets.each do |pod|
            if $static_framework.include?(pod.name)
                def pod.build_type;
                Pod::BuildType.static_library # >= 1.9
            end
        end
    end
  end
  # ****** THIS IS THE MAGIC ENDED  ******
  post_install do |installer|
    react_native_post_install(installer)
    
    #############
      installer.pods_project.targets.each do |target|
        ### Added for Maps
        if target.name == 'RCT-Folly'
          target.build_configurations.each do |config|
            config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
          end
        end

        #### Added For Maps Ended 
        if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
          target.build_configurations.each do |config|
              config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
             # config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "i386 arm64"
          end
        end
      end
    ############
   # __apply_Xcode_12_5_M1_post_install_workaround(installer)  # comment for maps
   ## there two linesare added for maps
    installer.pods_project.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
  end
end

相关问题