Skip to content

Commit e2dce06

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: f784c38a8169d269a0aabeaffe386e927df32e31
1 parent 65f5cd7 commit e2dce06

File tree

18 files changed

+33
-47
lines changed

18 files changed

+33
-47
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 & 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\"",
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\"" }
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"
@@ -350,5 +348,3 @@ struct YOGA_EXPORT YGNode {
350348
bool isNodeFlexible();
351349
void reset();
352350
};
353-
354-
#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\"",
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\"",
8687
]
8788
framework_search_paths = []
8889

packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,10 @@
842842
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
843843
CODE_SIGN_ENTITLEMENTS = RNTester/RNTester.entitlements;
844844
DEVELOPMENT_TEAM = "";
845+
HEADER_SEARCH_PATHS = (
846+
"${PODS_ROOT}/Headers/Private/Yoga",
847+
"$(inherited)",
848+
);
845849
INFOPLIST_FILE = "$(SRCROOT)/RNTester/Info.plist";
846850
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
847851
LD_RUNPATH_SEARCH_PATHS = (
@@ -875,6 +879,10 @@
875879
CODE_SIGN_ENTITLEMENTS = RNTester/RNTester.entitlements;
876880
DEVELOPMENT_TEAM = "";
877881
EXCLUDED_ARCHS = "";
882+
HEADER_SEARCH_PATHS = (
883+
"${PODS_ROOT}/Headers/Private/Yoga",
884+
"$(inherited)",
885+
);
878886
INFOPLIST_FILE = "$(SRCROOT)/RNTester/Info.plist";
879887
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
880888
LD_RUNPATH_SEARCH_PATHS = (
@@ -1084,6 +1092,10 @@
10841092
CODE_SIGN_STYLE = Automatic;
10851093
DEBUG_INFORMATION_FORMAT = dwarf;
10861094
DEVELOPMENT_TEAM = "";
1095+
HEADER_SEARCH_PATHS = (
1096+
"${PODS_ROOT}/Headers/Private/Yoga",
1097+
"$(inherited)",
1098+
);
10871099
INFOPLIST_FILE = RNTesterUnitTests/Info.plist;
10881100
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
10891101
LD_RUNPATH_SEARCH_PATHS = (
@@ -1122,6 +1134,10 @@
11221134
COPY_PHASE_STRIP = NO;
11231135
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
11241136
DEVELOPMENT_TEAM = "";
1137+
HEADER_SEARCH_PATHS = (
1138+
"${PODS_ROOT}/Headers/Private/Yoga",
1139+
"$(inherited)",
1140+
);
11251141
INFOPLIST_FILE = RNTesterUnitTests/Info.plist;
11261142
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
11271143
LD_RUNPATH_SEARCH_PATHS = (
@@ -1163,6 +1179,10 @@
11631179
"FB_REFERENCE_IMAGE_DIR=\"\\\"$(SOURCE_ROOT)/RNTesterIntegrationTests/ReferenceImages\\\"\"",
11641180
"$(inherited)",
11651181
);
1182+
HEADER_SEARCH_PATHS = (
1183+
"${PODS_ROOT}/Headers/Private/Yoga",
1184+
"$(inherited)",
1185+
);
11661186
INFOPLIST_FILE = RNTesterIntegrationTests/Info.plist;
11671187
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
11681188
LD_RUNPATH_SEARCH_PATHS = (
@@ -1198,6 +1218,10 @@
11981218
COPY_PHASE_STRIP = NO;
11991219
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
12001220
DEVELOPMENT_TEAM = "";
1221+
HEADER_SEARCH_PATHS = (
1222+
"${PODS_ROOT}/Headers/Private/Yoga",
1223+
"$(inherited)",
1224+
);
12011225
INFOPLIST_FILE = RNTesterIntegrationTests/Info.plist;
12021226
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
12031227
LD_RUNPATH_SEARCH_PATHS = (

0 commit comments

Comments
 (0)