Closed
Description
When i use react in swift with cocoapods , found if use_frameworks in podfile, make error : yoga/yoga.h not found .
so i change podfile with :
use_frameworks!
platform :ios, '8.0'
target 'RNSwiftDemo' do
pod 'React'
end
pre_install do |installer|
# Yoga exists in two places in the RN source tree. Delete the obsolete one to avoid redefinitions
`rm -rf ./xxx/React/CSSLayout`
end
post_install do |installer|
patch_subspecs(installer)
end
def patch_subspecs(installer)
# patch source and header files
`find ./xxx/React/React ./xxx/React/ReactCommon ./xxx/React/Libraries \\( -name *.h -o -name *.m -o -name *.mm \\) -print0 | xargs -0 sed -i '' -E 's:<(yoga|jschelpers|cxxreact)/(.*)>:"\\2":g'`
# exclude duplicate symbols
# https://github.com/facebook/react-native/issues/11502
installer.pods_project.targets.each do |target|
next unless target.name == 'React'
source_files = target.source_build_phase.files
uniqs = source_files.uniq { |f| f.file_ref.path }
(source_files - uniqs).each { |dup| source_files.delete(dup) }
end
end
can work on ObjC, but ObjC file must use .mm,
so i guess , cpp cause this problem .
don't work on Swift, even make ObjeC file to middle file.
Description
swift can't use react , cstdint not found
cocopods 1.2.0 use_frameworks
swift 3.0
react-native 0.40.0
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
kmuralidharan91 commentedon Feb 10, 2017
facing the same issue in swift 3.0 project.
can u guys help us?
nikolal commentedon Feb 11, 2017
I also have this issue.
pilwon commentedon Feb 13, 2017
Same problem here. Does someone have any suggestions?
kmuralidharan91 commentedon Feb 14, 2017
Solution from @julienfouilhe
You don't need all the above fixes anymore, remove your patch function in your Podfile, remove the postinstall script in your package.json, just put the master branch of react-native in your dependencies and add yoga as a pod dependency and it should work
package.json:
"react-native": "facebook/react-native#master"
Podfile:
react_path = '../node_modules/react-native'
yoga_path = File.join(react_path, 'ReactCommon/yoga')
pod 'React', :path => react_path, :subspecs => [
'Core',
'RCTText',
'RCTImage',
'RCTWebSocket', # needed for debugging
'RCTNetwork'
]
pod 'Yoga', :path => yoga_path
Don't forget to change all your #include "RCT..." to #include <React/RCT...> too
julienfouilhe commentedon Feb 14, 2017
See #11781
askielboe commentedon Feb 15, 2017
Same issue with
react-native 0.42.0-rc.3
. Using @julienfouilhe'sPodspec
fixes it for me.