I have been working in React Native iOS project and use cocoapods. When I do "import React" in my project, it throws error "Could not build Objective-C module 'React'". And there is error in "ArtNode.h" saying "Include of non-modular header inside framework module 'React.ARTNode'". 20 other similar Include of non-modular header errors occurring in other header file.
I do not know what is the problem and here is my pod file:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target ‘TestApp’ do
pod 'Alamofire'
pod 'RealmSwift'
pod 'SwiftyJSON', '~> 4.0'
pod 'SSZipArchive'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'Fabric'
pod 'Crashlytics'
# ReactNative
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'ART',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTActionSheet',
'RCTAnimation',
'RCTText',
'RCTImage',
'RCTNetwork',
'RCTPushNotification',
'RCTWebSocket', # needed for debugging
'RCTGeolocation',
'RCTSettings',
'RCTVibration',
'RCTLinkingIOS',
# 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'
# Other link
# pod 'RNI18n', :path => '../node_modules/react-native-i18n'
pod 'react-native-fetch-blob', :path => '../node_modules/react-native-fetch-blob'
pod 'react-native-pdf', :path => '../node_modules/react-native-pdf'
pod 'react-native-config', :path => '../node_modules/react-native-config'
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_unused_yoga_headers
end
post_install do |installer|
react_native_fix
# Fix react-native-config Bug: 'GeneratedDotEnv.m' file not found
installer.pods_project.targets.each do |target|
if target.name == 'react-native-config'
phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
phase.shell_script = "cd ../../"\
"&& RNC_ROOT=./node_modules/react-native-config/"\
"&& export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
"&& export BUILD_DIR=$RNC_ROOT/ios/ReactNativeConfig"\
"&& ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby"
target.build_phases << phase
target.build_phases.move(phase,0)
end
end
installer.pods_project.build_configuration_list.build_configurations.each do |configuration|
configuration.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
end
end