简体   繁体   English

将react native集成到现有的Swift项目中:找不到'string'文件

[英]Integrate react native into existing Swift project: 'string' file not found

I try to integrate React Native into my existing iOS app (mixed code ObjC and Swift) according to this tutorial: https://facebook.github.io/react-native/docs/integration-with-existing-apps.html 我根据此教程尝试将React Native集成到我现有的iOS应用程序(混合代码ObjC和Swift)中: https ://facebook.github.io/react-native/docs/integration-with-existing-apps.html

But whenever I try to compile my project, I get 'string' file not found (there's also an issue: https://github.com/facebook/react-native/issues/17556 but no solution yet). 但是,每当我尝试编译我的项目时,我都'string' file not found (还有一个问题: https : //github.com/facebook/react-native/issues/17556但还没有解决方案)。

Did anyone solve this problem? 有人解决了这个问题吗?

We also recently encountered this while integrating RN through CocoaPods. 我们最近在通过CocoaPods集成RN时也遇到了这一问题。

Not sure if you're still looking for a solution to this, but as stated by esam091 in that issue you linked, a workaround is to add this postinstall hook in the Podfile. 不知道您是否仍在寻找解决方案,但是正如esam091在所链接的问题中所述,一种解决方法是在Podfile中添加此后安装挂钩。

# 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

This removes the culprit headers. 这将删除罪魁祸首。 Still a problem as of RN 0.53 从RN 0.53开始仍然是一个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM