提问者:小点点

升级Xcode 12.5后,无法在iOS上运行react native


尝试在MacBook Air M1iOS模拟器上启动react native project失败,出现此错误

: 0:错误:模块映射文件'/用户/用户名/库/开发人员/Xcode/DerivedData/project ectName-czhmfookabhyqzdsutttonzlxnsi/Build/Products/Debug-iphone模拟器/FBSDKCoreKit/FBSDKCoreKit.模块地图'未找到
:0:错误:模块映射文件'/用户/erName/库/开发人员/Xcode/DerivedData/project NamectName-czhmfookabhyqzdsutttonzlxnsi/Build/Products/Debug-iphone模拟器/FBSDKCoreKit/FBSDKCoreKit.模块地图'未找到
:0:错误:缺少所需的模块'SwiftShims'

**建筑失败**

以下构建命令失败:

CompileSwift正常x86_64[路径到项目文件夹]/ios/File. swift
CompileSwiftSsource正常x86_64com.apple.xcode.tools.swift.compiler

我已经试过了

  • 使用Xcode打开. xcworkspace
  • 删除node_modules、package-lock. json和podfile.lock;
  • npm安装;
  • pod安装在iOS文件夹中
  • 清理DerivedData文件夹
  • 重建项目
System:
    OS: macOS 11.3 
    CPU: (8) arm64 Apple M1 
    Memory: 177.69 MB / 8.00 GB 
    Shell: 5.8 - /bin/zsh 
  Binaries: 
    Node: 15.14.0 - /opt/homebrew/bin/node 
    npm: 7.7.6 - /opt/homebrew/bin/npm 
    Watchman: 4.9.0 - /opt/homebrew/bin/watchman 
  SDKs: 
    iOS SDK: 
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 
    Android SDK: 
      API Levels: 27, 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.3 
      System Images: android-29 | Automotive with Play Store Intel x86 Atom, android-29 | Android TV Intel x86 Atom, android-29 | Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom 
  IDEs: 
    Android Studio: 4.1 AI-201.8743.12.41.7199119 
    Xcode: 12.5/12E262 - /usr/bin/xcodebuild 
  npmPackages: 
    react: 16.9.0 => 16.9.0  
    react-native: ^0.61.5 => 0.61.5  
  npmGlobalPackages: 
    react-native-cli: 2.0.1 
platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target '[tName]' do

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
  
  pod 'GoogleSignIn', '~> 5.0.2'
  
  # react-native-geolocation-service
  pod 'react-native-geolocation', path: '../node_modules/@react-native-community/geolocation'

  # use_frameworks!
  pod 'TwitterKit5'

#  google idfa support
  pod 'GoogleIDFASupport', '~> 3.14'

  target '[tNameTests]' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
  
#  GOOGLE MAPS REQUIRE
  rn_maps_path = '../node_modules/react-native-maps'
   pod 'react-native-google-maps', :path => rn_maps_path
   pod 'GoogleMaps'
   pod 'Google-Maps-iOS-Utils'
   
end

  target '[tName]-tvOS' do
   # Pods for [tName]-tvOS

   target '[tName]-tvOSTests' do
     inherit! :search_paths
     # Pods for testing
   end

end
    
 post_install do |installer|
     ## Fix for XCode 12.5 beta
     find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm", "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
     find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
         "RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
 end

 def find_and_replace(dir, findstr, replacestr)
   Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
       if text != replace
           puts "Fix: " + name
           File.open(name, "w") { |file| file.puts replace }
           STDOUT.flush
       end
   end
   Dir[dir + '*/'].each(&method(:find_and_replace))
 end

共1个答案

匿名用户

不仅仅是您,这是一个悬而未决的问题。以下是问题线程的链接和故障排除指南:

  • react-native run-ios在XCode 12.5beta#1365上构建失败
  • Xcode 12.5故障排除指南(RN0.62/0.63/0.64)#31480