-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[CocoaPods] Podspec doesn't set up header search paths for <CSSLayout> imports #9014
Comments
It seems that I have similar issue related to importing CSSLayout.
podfile:
I have latest stable version of XCode (7.3.1), cocoapods v1.0.1 and new swift project. I reproduced the issue on my office mac. |
Same problem here, occurs only when Downgrading to 0.30 worked for me, too. |
Same here .We have react native project with Swift and the error started to occur on 0.31. |
+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: 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.. |
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 |
Summary: This PR changes `#include <CSSLayout/*.h>` to `#include "*.h"` within the `CSSLayout` directory. Rationale: Quote includes are preferred for user (aka local/project) includes, whereas angle includes are preferred for standard libraries and external frameworks. In particular, XCode 7.1+ will not search user paths (even the current directory) when angle brackets are used unless "Always search user paths" is enabled - it is off by default and [Apple recommend](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW110) that it is only enabled for backwards compatibility. I think this is the best fix for #9014, and seems like good practice in any case. Closes facebook/yoga#217 Reviewed By: majak Differential Revision: D3764132 Pulled By: emilsjolander fbshipit-source-id: c8a6e8d19db71455922e3ba8f6c72bd66018fa84
Summary: This PR changes `#include <CSSLayout/*.h>` to `#include "*.h"` within the `CSSLayout` directory. Rationale: Quote includes are preferred for user (aka local/project) includes, whereas angle includes are preferred for standard libraries and external frameworks. In particular, XCode 7.1+ will not search user paths (even the current directory) when angle brackets are used unless "Always search user paths" is enabled - it is off by default and [Apple recommend](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW110) that it is only enabled for backwards compatibility. I think this is the best fix for facebook/react-native#9014, and seems like good practice in any case. Closes #217 Reviewed By: majak Differential Revision: D3764132 Pulled By: emilsjolander fbshipit-source-id: c8a6e8d19db71455922e3ba8f6c72bd66018fa84
I tried to solve this problem。 {
"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 Edit s.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 |
Good find - that seems to be because CocoaPods will usually copy all headers to the same directory, but specifying |
#9544 is definitely the good long-term solution, in the interim there are many stopgap solutions. Yours would work, as would @rh389’s:
Which can be done with a |
Summary: Include CSSLayout headers in the same way as other project headers, ie `#import <CSSLayout/CSSLayout.h>` becomes `#import "CSSLayout.h"`. CSSLayout is not a framework or system dependency, so shouldn't (AFAIK) be included with angle brackets. Doing so breaks framework builds, such as when RN is used as a pod in a swift project. In combination with facebook/yoga#217 this fixes facebook#9014 (specifically swift cocoapods projects). There is then no need for a separate CSSLayout pod subspec. Tests run on the RN project in isolation (with changes inside `CSSLayout` itself also applied) and against a dummy swift project with RN included as a pod. NB: This effectively reverts facebook#9015 and may break non-swift cocoapods projects unless facebook/yoga#217 is merged and synced first. Update: As discussed with alloy and emilsjolander, wrap these imports in a preprocess Closes facebook#9544 Differential Revision: D3821791 Pulled By: javache fbshipit-source-id: d27ac8be9ce560d03479b43d3db740cd196c24da
Summary: Include CSSLayout headers in the same way as other project headers, ie `#import <CSSLayout/CSSLayout.h>` becomes `#import "CSSLayout.h"`. CSSLayout is not a framework or system dependency, so shouldn't (AFAIK) be included with angle brackets. Doing so breaks framework builds, such as when RN is used as a pod in a swift project. In combination with facebook/yoga#217 this fixes facebook#9014 (specifically swift cocoapods projects). There is then no need for a separate CSSLayout pod subspec. Tests run on the RN project in isolation (with changes inside `CSSLayout` itself also applied) and against a dummy swift project with RN included as a pod. NB: This effectively reverts facebook#9015 and may break non-swift cocoapods projects unless facebook/yoga#217 is merged and synced first. Update: As discussed with alloy and emilsjolander, wrap these imports in a preprocess Closes facebook#9544 Differential Revision: D3821791 Pulled By: javache fbshipit-source-id: d27ac8be9ce560d03479b43d3db740cd196c24da
Summary: This PR changes `#include <CSSLayout/*.h>` to `#include "*.h"` within the `CSSLayout` directory. Rationale: Quote includes are preferred for user (aka local/project) includes, whereas angle includes are preferred for standard libraries and external frameworks. In particular, XCode 7.1+ will not search user paths (even the current directory) when angle brackets are used unless "Always search user paths" is enabled - it is off by default and [Apple recommend](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW110) that it is only enabled for backwards compatibility. I think this is the best fix for facebook#9014, and seems like good practice in any case. Closes facebook/yoga#217 Reviewed By: majak Differential Revision: D3764132 Pulled By: emilsjolander fbshipit-source-id: c8a6e8d19db71455922e3ba8f6c72bd66018fa84
Summary: Include CSSLayout headers in the same way as other project headers, ie `#import <CSSLayout/CSSLayout.h>` becomes `#import "CSSLayout.h"`. CSSLayout is not a framework or system dependency, so shouldn't (AFAIK) be included with angle brackets. Doing so breaks framework builds, such as when RN is used as a pod in a swift project. In combination with facebook/yoga#217 this fixes facebook#9014 (specifically swift cocoapods projects). There is then no need for a separate CSSLayout pod subspec. Tests run on the RN project in isolation (with changes inside `CSSLayout` itself also applied) and against a dummy swift project with RN included as a pod. NB: This effectively reverts facebook#9015 and may break non-swift cocoapods projects unless facebook/yoga#217 is merged and synced first. Update: As discussed with alloy and emilsjolander, wrap these imports in a preprocess Closes facebook#9544 Differential Revision: D3821791 Pulled By: javache fbshipit-source-id: d27ac8be9ce560d03479b43d3db740cd196c24da
Summary: This PR changes `#include <CSSLayout/*.h>` to `#include "*.h"` within the `CSSLayout` directory. Rationale: Quote includes are preferred for user (aka local/project) includes, whereas angle includes are preferred for standard libraries and external frameworks. In particular, XCode 7.1+ will not search user paths (even the current directory) when angle brackets are used unless "Always search user paths" is enabled - it is off by default and [Apple recommend](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW110) that it is only enabled for backwards compatibility. I think this is the best fix for facebook#9014, and seems like good practice in any case. Closes facebook/yoga#217 Reviewed By: majak Differential Revision: D3764132 Pulled By: emilsjolander fbshipit-source-id: c8a6e8d19db71455922e3ba8f6c72bd66018fa84
Summary: This PR changes `#include <CSSLayout/*.h>` to `#include "*.h"` within the `CSSLayout` directory. Rationale: Quote includes are preferred for user (aka local/project) includes, whereas angle includes are preferred for standard libraries and external frameworks. In particular, XCode 7.1+ will not search user paths (even the current directory) when angle brackets are used unless "Always search user paths" is enabled - it is off by default and [Apple recommend](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW110) that it is only enabled for backwards compatibility. I think this is the best fix for facebook#9014, and seems like good practice in any case. Closes facebook/yoga#217 Reviewed By: majak Differential Revision: D3764132 Pulled By: emilsjolander fbshipit-source-id: c8a6e8d19db71455922e3ba8f6c72bd66018fa84
Can anyone tell me how should I add a recursive user header search path for workaround before pr merged? |
Summary: To make React Native play nicely with our internal build infrastructure we need to properly namespace all of our header includes. Where previously you could do `#import "RCTBridge.h"`, you must now write this as `#import <React/RCTBridge.h>`. If your xcode project still has a custom header include path, both variants will likely continue to work, but for new projects, we're defaulting the header include path to `$(BUILT_PRODUCTS_DIR)/usr/local/include`, where the React and CSSLayout targets will copy a subset of headers too. To make Xcode copy headers phase work properly, you may need to add React as an explicit dependency to your app's scheme and disable "parallelize build". Reviewed By: mmmulani Differential Revision: D4213120 fbshipit-source-id: 84a32a4b250c27699e6795f43584f13d594a9a82
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/CSSLayout
or preserve the entire directory hierarchy and set up the header search path to be recursive I think.The text was updated successfully, but these errors were encountered: