Skip to content

Commit 0713dc4

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
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: 820cc2080ca66838741c9a87e192b83dad5bb129
1 parent 6babe4a commit 0713dc4

File tree

16 files changed

+5
-45
lines changed

16 files changed

+5
-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: 1 addition & 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']

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

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

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

1010
#pragma once
1111

12-
#ifdef __cplusplus
13-
1412
#include <string>
1513

1614
#include "Yoga.h"
@@ -28,5 +26,3 @@ void YGNodeToString(
2826
} // namespace facebook
2927

3028
#endif
31-
32-
#endif

packages/react-native/ReactCommon/yoga/yoga/YGStyle.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 <algorithm>
1311
#include <array>
1412
#include <cstdint>
@@ -237,5 +235,3 @@ YOGA_EXPORT bool operator==(const YGStyle& lhs, const YGStyle& rhs);
237235
YOGA_EXPORT inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
238236
return !(lhs == rhs);
239237
}
240-
241-
#endif

packages/react-native/ReactCommon/yoga/yoga/Yoga-internal.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 <algorithm>
1311
#include <array>
1412
#include <cmath>
@@ -154,5 +152,3 @@ static const float kDefaultFlexShrink = 0.0f;
154152
static const float kWebDefaultFlexShrink = 1.0f;
155153

156154
extern bool YGFloatsEqual(const float a, const float b);
157-
158-
#endif

packages/react-native/ReactCommon/yoga/yoga/log.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 "YGEnums.h"
1311

1412
struct YGNode;
@@ -38,5 +36,3 @@ struct Log {
3836
} // namespace detail
3937
} // namespace yoga
4038
} // namespace facebook
41-
42-
#endif

packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ def get_podspec_no_fabric_no_script
547547
"\"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\"",
548548
"\"$(PODS_ROOT)/Headers/Private/React-Fabric\"",
549549
"\"$(PODS_ROOT)/Headers/Private/React-RCTFabric\"",
550+
"\"$(PODS_ROOT)/Headers/Private/Yoga/yoga\"",
550551
].join(' ')
551552
},
552553
'dependencies': {

packages/react-native/scripts/cocoapods/codegen_utils.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fa
8383
"\"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\"",
8484
"\"$(PODS_ROOT)/Headers/Private/React-Fabric\"",
8585
"\"$(PODS_ROOT)/Headers/Private/React-RCTFabric\"",
86+
"\"$(PODS_ROOT)/Headers/Private/Yoga/yoga\"",
8687
]
8788
framework_search_paths = []
8889

0 commit comments

Comments
 (0)