Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native use in Swift ,follow up yoga.h not found . #12294

Closed
huangcheng1 opened this issue Feb 9, 2017 · 6 comments
Closed

react-native use in Swift ,follow up yoga.h not found . #12294

huangcheng1 opened this issue Feb 9, 2017 · 6 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@huangcheng1
Copy link

huangcheng1 commented Feb 9, 2017

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

@kmuralidharan91
Copy link

facing the same issue in swift 3.0 project.
can u guys help us?

@nikolal
Copy link

nikolal commented Feb 11, 2017

I also have this issue.

@pilwon
Copy link
Contributor

pilwon commented Feb 13, 2017

Same problem here. Does someone have any suggestions?

@kmuralidharan91
Copy link

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
Copy link

See #11781

@askielboe
Copy link

Same issue with react-native 0.42.0-rc.3. Using @julienfouilhe's Podspec fixes it for me.

@facebook facebook locked as resolved and limited conversation to collaborators Aug 31, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants