Skip to content

Commit 17f8666

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Remove private headers exposed by podspecs (microsoft#940)
Summary: X-link: facebook/litho#940 X-link: facebook/yoga#1252 Pull Request resolved: facebook#36993 Fabric relies on the private C++ internals of Yoga. This creates a conundrum in the open source build due to how header creation in Cocoapods works. 1. The default mechanism of specifying public headers needs to include the private headers for them to be made usable by fabric (by default) 2. Cocoapods will roll up all of the public headers when importing a module facebook#33381 fixed the Fabric Cocoapods build which ran into this. React Native relies on FlipperKit which relies on YogaKit, which in turn finally imports the Yoga podspec. Because YogaKit may use Swift, we can only expose the public Yoga C ABI. The first solution in that PR was to allow RN to access Yoga private headers, but this was changed to instead make all Yoga headers public, and to add ifdefs to all of them to no-op when included outside of a C++ environment. Talking to Kudo, we should be able to change back to the earlier approach in the PR, to instead expose the private headers to only RN. This lets us avoid exposing headers that we ideally wouldn't be, and lets us avoid the messy ifdefs in every Yoga header. Changelog: [Internal] Reviewed By: rshest Differential Revision: D45139075 fbshipit-source-id: ad6c0b5b5a7aa5fbf849c3ca62f3fe330601b19a
1 parent c1dea41 commit 17f8666

File tree

20 files changed

+43
-53
lines changed

20 files changed

+43
-53
lines changed

packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ header_search_paths = [
3636
"$(PODS_ROOT)/RCT-Folly",
3737
"${PODS_ROOT}/Headers/Public/FlipperKit",
3838
"$(PODS_ROOT)/Headers/Public/ReactCommon",
39-
"$(PODS_ROOT)/Headers/Public/React-RCTFabric"
39+
"$(PODS_ROOT)/Headers/Public/React-RCTFabric",
40+
"$(PODS_ROOT)/Headers/Private/Yoga",
4041
].concat(use_hermes ? [
4142
"$(PODS_ROOT)/Headers/Public/React-hermes",
4243
"$(PODS_ROOT)/Headers/Public/hermes-engine"
@@ -54,7 +55,7 @@ Pod::Spec.new do |s|
5455
s.version = version
5556
s.summary = "An utility library to simplify common operations for the New Architecture"
5657
s.homepage = "https://reactnative.dev/"
57-
s.documentation_url = "https://reactnative.dev/docs/actionsheetios"
58+
s.documentation_url = "https://reactnative.dev/"
5859
s.license = package["license"]
5960
s.author = "Meta Platforms, Inc. and its affiliates"
6061
s.platforms = { :ios => min_ios_version_supported }

packages/react-native/React/React-RCTFabric.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ header_search_paths = [
2727
"\"$(PODS_ROOT)/DoubleConversion\"",
2828
"\"$(PODS_ROOT)/RCT-Folly\"",
2929
"\"$(PODS_ROOT)/Headers/Private/React-Core\"",
30+
"\"$(PODS_ROOT)/Headers/Private/Yoga\"",
3031
"\"$(PODS_ROOT)/Headers/Public/React-Codegen\"",
3132
"\"${PODS_CONFIGURATION_BUILD_DIR}/React-Codegen/React_Codegen.framework/Headers\"",
3233

packages/react-native/ReactCommon/React-Fabric.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Pod::Spec.new do |s|
8282
"\"$(PODS_ROOT)/boost\"",
8383
"\"$(PODS_TARGET_SRCROOT)/ReactCommon\"",
8484
"\"$(PODS_ROOT)/RCT-Folly\"",
85+
"\"$(PODS_ROOT)/Headers/Private/Yoga\"",
8586
]
8687

8788
if ENV['USE_FRAMEWORKS']
@@ -220,7 +221,7 @@ Pod::Spec.new do |s|
220221
sss.source_files = "react/renderer/components/view/**/*.{m,mm,cpp,h}"
221222
sss.exclude_files = "react/renderer/components/view/tests"
222223
sss.header_dir = "react/renderer/components/view"
223-
224+
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/Yoga\"" }
224225
end
225226
end
226227

packages/react-native/ReactCommon/yoga/Yoga.podspec

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ Pod::Spec.new do |spec|
5151
source_files = File.join('ReactCommon/yoga', source_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
5252
spec.source_files = source_files
5353

54-
header_files = 'yoga/*.h'
55-
header_files = File.join('ReactCommon/yoga', header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
56-
spec.public_header_files = header_files
54+
public_header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h'
55+
public_header_files = File.join('ReactCommon/yoga', public_header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
56+
spec.public_header_files = public_header_files
57+
58+
# Fabric must be able to access private headers (which should not be included in the umbrella header)
59+
all_header_files = 'yoga/**/*.h'
60+
all_header_files = File.join('ReactCommon/yoga', all_header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
61+
spec.private_header_files = Dir.glob(all_header_files) - Dir.glob(public_header_files)
5762
end

packages/react-native/ReactCommon/yoga/yoga/BitUtils.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#pragma once
99

10-
#ifdef __cplusplus
11-
1210
#include <cstdio>
1311
#include <cstdint>
1412
#include "YGEnums.h"
@@ -67,5 +65,3 @@ inline void setBooleanData(uint8_t& flags, size_t index, bool value) {
6765
} // namespace detail
6866
} // namespace yoga
6967
} // namespace facebook
70-
71-
#endif

packages/react-native/ReactCommon/yoga/yoga/CompactValue.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#pragma once
99

10-
#ifdef __cplusplus
11-
1210
#if defined(__has_include) && __has_include(<version>)
1311
// needed to be able to evaluate defined(__cpp_lib_bit_cast)
1412
#include <version>
@@ -212,5 +210,3 @@ constexpr bool operator!=(CompactValue a, CompactValue b) noexcept {
212210
} // namespace detail
213211
} // namespace yoga
214212
} // namespace facebook
215-
216-
#endif

packages/react-native/ReactCommon/yoga/yoga/Utils.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#pragma once
99

10-
#ifdef __cplusplus
11-
1210
#include "YGNode.h"
1311
#include "Yoga-internal.h"
1412
#include "CompactValue.h"
@@ -146,5 +144,3 @@ inline YGFloatOptional YGResolveValueMargin(
146144
const float ownerSize) {
147145
return value.isAuto() ? YGFloatOptional{0} : YGResolveValue(value, ownerSize);
148146
}
149-
150-
#endif

packages/react-native/ReactCommon/yoga/yoga/YGConfig.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#pragma once
99

10-
#ifdef __cplusplus
11-
1210
#include "Yoga-internal.h"
1311
#include "Yoga.h"
1412

@@ -77,5 +75,3 @@ struct YOGA_EXPORT YGConfig {
7775
setCloneNodeCallback(YGCloneNodeFunc{nullptr});
7876
}
7977
};
80-
81-
#endif

packages/react-native/ReactCommon/yoga/yoga/YGFloatOptional.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#pragma once
99

10-
#ifdef __cplusplus
11-
1210
#include <cmath>
1311
#include <limits>
1412
#include "Yoga-internal.h"
@@ -70,5 +68,3 @@ inline bool operator>=(YGFloatOptional lhs, YGFloatOptional rhs) {
7068
inline bool operator<=(YGFloatOptional lhs, YGFloatOptional rhs) {
7169
return lhs < rhs || lhs == rhs;
7270
}
73-
74-
#endif

packages/react-native/ReactCommon/yoga/yoga/YGLayout.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#pragma once
99

10-
#ifdef __cplusplus
11-
1210
#include "BitUtils.h"
1311
#include "YGFloatOptional.h"
1412
#include "Yoga-internal.h"
@@ -63,5 +61,3 @@ struct YGLayout {
6361
bool operator==(YGLayout layout) const;
6462
bool operator!=(YGLayout layout) const { return !(*this == layout); }
6563
};
66-
67-
#endif

0 commit comments

Comments
 (0)