1

尝试在 MacBook Air M1 的 iOS 模拟器上启动 react native 项目失败并出现此错误

:0:错误:模块映射文件'/Users/userName/Library/Developer/Xcode/DerivedData/projectName-czhmfookabhyqzdsutttonzlxnsi/Build/Products/Debug-iphonesimulator/FBSDKCoreKit/FBSDKCoreKit.modulemap'未找到
:0:错误:模块映射文件'/Users/erName/Library/Developer/Xcode/DerivedData/projectName-czhmfookabhyqzdsutttonzlxnsi/Build/Products/Debug-iphonesimulator/FBSDKCoreKit/FBSDKCoreKit.modulemap'未找到
:0:错误:缺少必需的模块'SwiftShims'

** 构建失败 **

以下构建命令失败:

CompileSwift 正常 x86_64 [path-to-project-folder]/ios/File.swift
CompileSwiftSources 正常 x86_64 com.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
4

1 回答 1

3

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

于 2021-05-11T21:19:44.877 回答