【问题标题】:'folly/Portability.h' file not found React library'folly/Portability.h' 文件未找到 React 库
【发布时间】:2019-07-23 13:26:30
【问题描述】:

使用我的 react native 项目在 Xcode 上运行构建失败。 错误是'folly/Portability.h' file not found

过去几天我一直在尝试自行解决此问题,但无法解决。

注册护士信息:

  React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: (4) x64 Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
      Memory: 641.79 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.6.0 - /usr/local/bin/node
      Yarn: 1.17.3 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    IDEs:
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.8 => 0.59.8 
    npmGlobalPackages:
      react-native-cli: 2.0.1

播客文件

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
# Required by RNFirebase
pod 'Firebase/Core', '~> 5.20.1'

target 'WhosThat_app' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!
  pod 'Firebase/Firestore'
  pod 'Firebase/Storage'
  pod 'Firebase/Auth'
  pod 'GoogleMaps', '~> 2.7.0'
  pod 'Fabric', '~> 1.10.1'
  pod 'Crashlytics', '~> 3.13.1'
  # Pods for WhosThat_app
  pod 'RNImageCropPicker', :path => '../node_modules/react-native-image-crop-picker'
  pod 'RNBackgroundGeolocation', :path => '../node_modules/react-native-background-geolocation'
  pod 'RNBackgroundFetch', :path => '../node_modules/react-native-background-fetch'
  pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'Folly', podspec: '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  target 'WhosThat_app-tvOSTests' do
    inherit! :search_paths
    # Pods for testing


  end

  target 'WhosThat_appTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

尝试删除 pods 文件夹并重新安装它们并删除 node-modules 文件夹

【问题讨论】:

    标签: ios xcode react-native cocoapods


    【解决方案1】:

    将以下内容添加到Podfile 内的target 'WhosThat_app' do

    target 'WhosThat_app' do
    
      # ...everything else
    
      post_install do |installer|
        installer.pods_project.targets.each do |target|
          if target.name == 'React'
            target.remove_from_project
          end
        end
      end
    

    我不需要以下行,相信您可以删除它:

    pod 'Folly', podspec: '../node_modules/react-native/third-party-podspecs/Folly.podspec'
    

    注意事项

    【讨论】:

    • 嗨@Andru 我尝试了你的建议,当我运行“pod install”时,我收到以下错误:'[!] Invalid Podfile file: syntax error, unexpected tIDENTIFIER, expecting then or ' ;'或 '\n' en...get.remove_from_project' ---- 有什么想法吗?
    • @Yossi 不知道。看起来你应该检查语法。您是否可能忘记了一些逗号或其他内容?
    • 再次输入整个 podfile,错误消失了,尽管文本看起来相同。不知道是什么问题...谢谢!
    【解决方案2】:

    要解决这个问题,你应该做两件事:

    1) 添加CxxBridge子规范

    2) 点 DoubleConversionglog 依赖规范直接用于 Folly

    Podfile 示例:

    # React Native
    rn_path = '../node_modules/react-native'
    pod 'React', path: rn_path, subspecs: [
        'CxxBridge',
        'RCTText',
        'RCTNetwork',
        'RCTWebSocket',
        'RCTAnimation',
        'RCTActionSheet',
        'RCTGeolocation',
        'RCTImage',
        'RCTSettings',
        'RCTVibration',
        'RCTLinkingIOS'
    ]
    pod 'yoga', :path => "#{rn_path}/ReactCommon/yoga"
    pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
    pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
    pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"
    

    【讨论】:

      【解决方案3】:
      pod 'React', path: rn_path, subspecs: [
        'ART',
        'Core',
        'CxxBridge',
        'RCTText',
        'RCTNetwork',
        'RCTLinkingIOS',
        'RCTImage',
        'RCTAnimation',
        'RCTWebSocket', # needed for debugging
        'RCTActionSheet',
        'RCTGeolocation',
        'RCTSettings',
        'RCTVibration',
        'DevSupport',
        'RCTPushNotification'
      ]
      

      通过添加这些,我的问题已成功解决。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-10-17
        • 2022-01-03
        • 1970-01-01
        • 2018-03-26
        • 2017-05-30
        • 2023-03-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多