Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment:
OS: macOS High Sierra 10.13.2
Node: 7.6.0
Yarn: 0.24.6
npm: 4.1.2
Watchman: 4.7.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: Not Found
Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: file:submodule/react-native => 0.52.0
Target Platform: iOS (11.1)
Steps to Reproduce
1.the react-native project complied with swift code
2.build project
Expected Behavior
Complied Success.
Actual Behavior
Complied failed.
Xcode shows 'string' file not found".
Reproducible Demo
Every react-native 0.52 or above project with swift has this problem.
The same issues:(facebook/yoga#697)
I think the reason is the OC file in React include yoga cpp has .m suffix,but it needs .mm.It builds success in only OC project,but failed in swift project.
any solution for this?
This is really bad, how can React Native release a new version that is totally unusable for an large subset of their users? Do they even test the releases on Swift?
Assuming you're using CocoaPods, a generated umbrella header file breaks the build because some of the imported files include C++ headers. I added a post_install script in my Podfile and it seems to work. Hope this helps.
# 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 "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
I tried the following:
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
inhibit_all_warnings!
target '...' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
...
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTText',
'RCTNetwork',
'RCTWebSocket', # needed for debugging
# Add any other subspecs you want to use in your project
]
# Explicitly include Yoga if you are using RN >= 0.42.0
pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
# Third party deps podspec link
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'GLog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
end
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 "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
But now I do get RCTTVRemoteHandler.h file not found (inside RCTModalHostView.m).
try including tvOS in React subspecs
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTText',
'RCTNetwork',
'RCTWebSocket', # needed for debugging
+ 'tvOS',
]
it goes on and on...
fishhook/fishhook.h file not found in RCTReconnectingWebSocket.m
Pretty sure this helps https://github.com/facebook/react-native/issues/13198#issuecomment-328758950
Integrating React Native with CocoaPods has never been a pleasant experience. I'd advise that it is much better to link React Native dependencies by adding the *.xcodeproj files directly to your project rather than using CocoaPods unless you absolutely have to 🙂
fishhook/fishhook.h file not found in RCTReconnectingWebSocket.m @haemi
fix #import
@ldshangfeng wow - it works now, thanks a lot!
@haemi should thanks @esam091 .The post_install script is more important!
If the post_install script doesn't work,you can check yoga-umbrella.h and delete the line 14 (#import "Yoga-internal.h" and #import "YGNodePrint.h") by yourself.I also tested it successfully.
@ldshangfeng is that the proper way to fix this issue?
fix #import
to #import "fishhook.h"
@yuoppp see all of comments.It work successfully with CocoaPods only.
Hello,
Making the approaches that you suggested it generate warnings.
Do you know if there is a way to make the compilation works & remove the warnings?
Thanks
@yuoppp @fjtrujy only wait for official solution. This is temp solution.
After adding all these "workarounds" it's still not working. Getting the error: Umbrella header for module 'yoga' does not include header 'Yoga-internal.h'
Makes sense because the post_install script removes it....
Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version?
I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer.
Bad bot. Don't close this. Still an issue even on 0.54.0-rc3.
https://github.com/facebook/yoga/issues/711
It seems that XCode treat "*.h" files as Clang so attempt to compile with gcc. I set a custom rule to build using g++ and the error disappeared (although another errors are occurring in my project)
Could this be a solution?

"react": "16.0.0-alpha.12",
"react-native": "^0.47.2",
"react-native-camera": "^1.0.1",

After changing from #import " got the issue "'RCTNetworking.h' file not found"?
Most helpful comment
This is really bad, how can React Native release a new version that is totally unusable for an large subset of their users? Do they even test the releases on Swift?