Swift 项目集成 RN(0.55.4) 错误处理 'algorithm' file not found

Integration with Existing Apps 官方文档

1) algorithm yoga

'algorithm' file not found
'yoga' file not found
解决方法:

在 Podfile 中复制脚本,修改需要手动修改的内容

# 在 Podfile 中加入
def change_lines_in_file(file_path, &change)
  print "Fixing #{file_path}...\n"

  contents = []

  file = File.open(file_path, 'r')
  file.each_line do | line |
    contents << line
  end
  file.close

  File.open(file_path, 'w') do |f|
    f.puts(change.call(contents))
  end
end

post_install do |installer|
  # https://github.com/facebook/yoga/issues/711#issuecomment-381098373
  change_lines_in_file('./Pods/Target Support Files/yoga/yoga-umbrella.h') do |lines|
    lines.reject do | line |
      [
        '#import "Utils.h"',
        '#import "YGLayout.h"',
        '#import "YGNode.h"',
        '#import "YGNodePrint.h"',
        '#import "YGStyle.h"',
        '#import "Yoga-internal.h"',
      ].include?(line.strip)
    end
  end

  # https://github.com/facebook/yoga/issues/711#issuecomment-374605785
  change_lines_in_file('./node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceSizeMeasureMode.h') do |lines|
    unless lines[27].include?("#ifdef __cplusplus")
      lines.insert(27, "#ifdef __cplusplus")
      lines.insert(34, "#endif")
    end
    lines
  end

  # https://github.com/facebook/react-native/issues/13198
  change_lines_in_file('./node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h') do |lines|
    lines.map { |line| line.include?("#import ") ? '#import "RCTValueAnimatedNode.h"' : line }
  end

  # https://github.com/facebook/react-native/issues/16039
  change_lines_in_file('./node_modules/react-native/Libraries/WebSocket/RCTReconnectingWebSocket.m') do |lines|
    lines.map { |line| line.include?("#import ") ? '#import "fishhook.h"' : line }
  end
end

解决的 issues:
https://github.com/facebook/yoga/issues/711#issuecomment-381098373
https://github.com/facebook/yoga/issues/711#issuecomment-374605785
https://github.com/facebook/react-native/issues/13198
https://github.com/facebook/react-native/issues/16039

2) fishhook

'fishhook/fishhook.h' file not found

解决方法:

/// 将#import ""修改为
#import "fishhook.h"

Building成功

可以开心import React

参考
facebook/yoga/issues/711
facebook/react-native/issues/16039

Jpunt/Profile Report gist

你可能感兴趣的:(Swift 项目集成 RN(0.55.4) 错误处理 'algorithm' file not found)