美文网首页
React Native融合到原生项目,报Could not b

React Native融合到原生项目,报Could not b

作者: 々莫等闲々 | 来源:发表于2018-05-02 17:14 被阅读0次

    1.在ReactNative的/node_modules/react-native/ReactCommon/yoga 文件夹中找到“yoga.podspec”文件并打开,将

    spec.public_header_files ='yoga/Yoga.h','yoga/YGEnums.h','yoga/YGMacros.h'

    添加到最后(end前面一行)。

    2.删掉podfile.lock文件中关于yoga的数据,在命令行中执行pod install;

    3.此时可能会报 'RCTAnimation/RCTValueAnimatedNode.h' file not found 错误,将

    #import <RCTAnimation/RCTValueAnimatedNode.h>                   

    换成 

    #import “RCTValueAnimatedNode.h”

    4.报#import fishhook/fishhook.h file not found错误,换成

     #import fishhook.h

    5.报Could not build module 'react'错误,解决办法如下:

    # 在Podfile中加入

    def fix_cplusplus_header_compiler_error

    filepath = '../node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceSizeMeasureMode.h'

    contents = []

    file = File.open(filepath, 'r')

    file.each_line do | line |

    contents << line

    end

    file.close if contents[32].include? "&"

    contents.insert(26, "#ifdef __cplusplus")

    contents[36] = "#endif"

    file = File.open(filepath, 'w')

    do |f| f.puts(contents)

                    end

            end

    end

    def fix_unused_yoga_headers

                filepath = './Pods/Target Support Files/yoga/yoga-umbrella.h'

                contents = []

                    file = File.open(filepath, 'r')

                    file.each_line  do | line |

                                contents << line

                                end

                    file.close

                        if contents[12].include? "Utils.h"

                                contents.delete_at(15) # #import "YGNode.h"

                                contents.delete_at(15) ##import "YGNodePrint.h"    

                                 contents.delete_at(15) # #import "Yoga-internal.h"

                                 contents.delete_at(12) # #import "Utils.h"

                                  file = File.open(filepath, 'w')  do |f| f.puts(contents)

                        end

        end

    end

    def react_native_fix

            fix_cplusplus_header_compiler_error

            fix_unused_yoga_headers

    end

    post_install do |installer|

    react_native_fix

    end

    相关文章

      网友评论

          本文标题:React Native融合到原生项目,报Could not b

          本文链接:https://www.haomeiwen.com/subject/rdycrftx.html