首页 文章

集成反应原生到现有的Swift项目:找不到'string'文件

提问于
浏览
0

我尝试根据本教程将React Native集成到我现有的iOS应用程序(混合代码ObjC和Swift)中:https://facebook.github.io/react-native/docs/integration-with-existing-apps.html

但每当我尝试编译我的项目时,我都会得到 'string' file not found (还有一个问题:https://github.com/facebook/react-native/issues/17556但还没有解决方案) .

有人解决了这个问题吗?

1 回答

  • 0

    我们最近也在通过CocoaPods整合RN时遇到了这个问题 .

    不确定您是否仍在寻找解决方案,但正如您在链接的问题中esam091所述,解决方法是在Podfile中添加此postinstall挂钩 .

    # Podfile
    
    def remove_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
    
    contents.delete_at(14) # #import "YGNode.h"
    contents.delete_at(14) # #import "YGNodePrint.h"
    contents.delete_at(14) # #import "Yoga-internal.h"
    
    file = File.open(filepath, 'w') do |f| 
        f.puts(contents)
    end
    end
    
    post_install do | installer |
     remove_unused_yoga_headers
    end
    

    这删除了罪魁祸首 Headers . RN 0.53仍是一个问题

相关问题