Repository navigation
[CocoaPods] Podspec doesn't set up header search paths for <CSSLayout> imports #9014
Description
Activity
It seems that I have similar issue related to importing CSSLayout.
I can't buildReactpod. Compiling ofCSSNodeList.cfails withfatal error: 'CSSLayout/CSSLayout.h' file not found.
Probably my setup will be useful:
package.json:{ "name": "Chat", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start" }, "dependencies": { "react": "~15.2.1", "react-native": "~0.31.0", "react-native-gifted-chat": "0.0.3" } }podfile:
target 'Chat' do use_frameworks! pod 'React', :path => './node_modules/react-native', :subspecs => [ 'Core', 'RCTText', 'RCTWebSocket', 'RCTImage', ] endI have latest stable version of XCode (7.3.1), cocoapods v1.0.1 and new swift project.
I've tried to deletePods/,node_modules/,Podfile.lockand install everything again.I reproduced the issue on my office mac.
BTW, downgrading to0.30.0solves it.Reacted by Nathan Smith, Guy Segal, Raphael Randschau, rahilbhansali, Spike Brehm, Azen Xu, Vincent Chow, Matthew Sisley, Ilya Isupov and Tawab GhorbandiSame problem here, occurs only when
use_frameworks!is set in the Podfile (which is required when using pods implemented in Swift).Downgrading to 0.30 worked for me, too.
Reacted by Nathan Smith, Guy Segal, Raphael Randschau, Spike Brehm, Azen Xu and Tawab GhorbandiSame here .We have react native project with Swift and the error started to occur on 0.31.
We also downgraded to 0.30 and it solved it..+1 I did the same as @guysegal and it's fine
This looks to be down to a Cocoapods/Xcode bug, but I haven't found a clean solution yet - CocoaPods/CocoaPods#4605
It's not clean but we've worked around this using an npm postinstall script that rewrites imports:
replace(/#(include|import) <CSSLayout\/([A-Za-z]+)\.h>/, '#$1 "$2.h"');(#import <CSSLayout/CSSlayout.h>becomes#import "CSSLayout.h")Definitely not clean or ideal and may or may not work depending on how you're using React in your codebase. Thought I'd post here just in case it helps anyone else.
Seems like its a blocker for a lot of projects to upgrade to 0.31..
Reacted by Spike Brehm and Eric Schulte- addedHelp Wanted
Issues ideal for external contributors.Issues ideal for external contributors.on Aug 18, 2016 After doing some digging I think @sdcooke's solution is the right one, so I've submitted a PR to get it changed at source.
In the mean time, I'm using
"postinstall": "find ./node_modules/react-native \\( -name *.h -o -name *.m \\) -print0 | xargs -0 sed -i '' -e 's:<CSSLayout/\\(.*\\)>:\"\\1\":g'"- ghost added a commit that references this issue
on Aug 24, 2016 - ghost added a commit that references this issue
on Aug 24, 2016 I tried to solve this problem。
I was such a modification:
package.json{ "name": "xxxxxxx", "version": "1.0.0", "description": "", "main": "", "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "bundle": "react-native bundle --platform ios --entry-file index.ios.js --bundle-output bundle/main.ios.jsbundle --assets-dest bundle/ --dev false", "postinstall": "find ./node_modules/react-native \\( -name *.h -o -name *.m \\) -print0 | xargs -0 sed -i '' -e 's:<CSSLayout/\\(.*\\)>:\"\\1\":g'" }, "author": "senpng@qq.com", "license": "ISC", "dependencies": { "react": "^15.3.0", "react-native": "^0.32.0", "react-native-fs": "^2.0.1-rc.2" } }the most important is
"postinstall": "find ./node_modules/react-native \\( -name *.h -o -name *.m \\) -print0 | xargs -0 sed -i '' -e 's:<CSSLayout/\\(.*\\)>:\"\\1\":g'"(thinks @rh389 )Edit
node_modules/react-native/React.podspecFile:
line 46s.subspec 'CSSLayout' do |ss| ss.source_files = "React/CSSLayout/**/*.{c,h}" ss.header_mappings_dir = "React" end
changed to
s.subspec 'CSSLayout' do |ss| ss.source_files = "React/CSSLayout/**/*.{c,h}" end
Before
pod installReacted by Azen Xu, SenPng, Abhinav Chauhan, sun_, Matthew Sisley, xuech, Julien Fouilhé and johnliu33Reacted by Azen XuReacted by Azen Xu and Kristofer EngReacted by Azen Xu and laowenluGood find - that seems to be because CocoaPods will usually copy all headers to the same directory, but specifying
Reactas aheader_mappings_diroverrides that behaviour to preserve all paths underReact, so has quite a wide impact (@alloy may have more insight). #9544 works too by removing the subspec completely, and I guess adding a recursive user header search path would also work (you could do that from your own Podfile or as a workspace setting).#9544 is definitely the good long-term solution, in the interim there are many stopgap solutions. Yours would work, as would @rh389’s:
I guess adding a recursive user header search path would also work (you could do that from your own Podfile
Which can be done with a
post_installhook https://guides.cocoapods.org/syntax/podfile.html#post_install.Reacted by Spike Brehm and Eric Schulte- added a commit that references this issue
on Sep 19, 2016 - added 2 commits that reference this issue
on Nov 23, 2016 Can anyone tell me how should I add a recursive user header search path for workaround before pr merged?
- added a commit that references this issue
on Dec 10, 2016 - addedHelp Wantedand removed
Issues ideal for external contributors.Issues ideal for external contributors.Help Wanted
Issues ideal for external contributors.Issues ideal for external contributors.on Mar 8, 2018 - locked as resolved and limited conversation to collaborators
on May 24, 2018 - addedResolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
on Jul 19, 2018


RN includes CSSLayout files using angle brackets like
#import <CSSLayout/CSSLayout.h>, which don't work with CocoaPods right now since CP flattens the headers by default. We either need to figure out how to preserve the directory hierarchy just forReact/CSSLayoutor preserve the entire directory hierarchy and set up the header search path to be recursive I think.