Skip to content

Commit 8b15d28

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Testing: Remove private headers from podspecs (facebook#36993)
Summary: 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. But also I have no idea what I'm doing here, so this will be exported and built. Changelog: [Internal] Differential Revision: D45139075 fbshipit-source-id: 80e50effd28a22065932a43e5c605c00b25f9b01
1 parent 6babe4a commit 8b15d28

File tree

16 files changed

+6
-45
lines changed

16 files changed

+6
-45
lines changed

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/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 & 0 deletions
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/yoga\"",
8586
]
8687

8788
if ENV['USE_FRAMEWORKS']
@@ -126,6 +127,7 @@ Pod::Spec.new do |s|
126127
sss.source_files = "react/renderer/components/activityindicator/**/*.{m,mm,cpp,h}"
127128
sss.exclude_files = "react/renderer/components/activityindicator/tests"
128129
sss.header_dir = "react/renderer/components/activityindicator"
130+
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/Yoga/yoga\"" }
129131
end
130132

131133
ss.subspec "image" do |sss|

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ 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'
54+
header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h'
5555
header_files = File.join('ReactCommon/yoga', header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
5656
spec.public_header_files = header_files
5757
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

packages/react-native/ReactCommon/yoga/yoga/YGNode.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 <cstdint>
1311
#include <stdio.h>
1412
#include "BitUtils.h"
@@ -351,5 +349,3 @@ struct YOGA_EXPORT YGNode {
351349
bool isNodeFlexible();
352350
void reset();
353351
};
354-
355-
#endif

0 commit comments

Comments
 (0)