Skip to content

Commit 285eea1

Browse files
committed
perf(ci): patch prebuilt RNCore instead of disabling — saves 5-10 min
之前禁 prebuilt(RCT_USE_PREBUILT_RNCORE=0) 绕开 'memory' file not found, 代价是 CI 每次从源码编译 React-Core 慢 5-10 分钟。改成原地 patch prebuilt xcframework 里的 React-umbrella.h + module.modulemap (react/react-native#56862 改的 ios-prebuild/templates/)。 变更: - example/ios/Podfile post_install: ruby patch 把 RCTDefines.h 移到 RCTBridgeConstants.h 之前 + 删 modulemap wildcard sub-module - ci.yml build-ios: RCT_USE_PREBUILT_RNCORE=1, RCT_USE_RN_DEP=1 恢复 本地验证: prebuilt+patch 模式 yarn build:ios 成功生成 .app,零 'memory' file not found 报错。 清理时机: RN 0.86.0 stable (rc.2 已验证含 fix) → 升 RN + 删 patch。
1 parent c288b45 commit 285eea1

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,8 @@ jobs:
122122
env:
123123
XCODE_VERSION: 26
124124
TURBO_CACHE_DIR: .turbo/ios
125-
# RN 0.85.3 + Xcode 26 + prebuilt RNCore 三者组合下 ReactCodegen .cpp
126-
# 编译报 'memory' file not found(umbrella header 顺序 + module 隔离 bug)。
127-
# 等 RN 0.85.4 含 PR #56862 fix 后可恢复 prebuilt。
128-
RCT_USE_RN_DEP: 0
129-
RCT_USE_PREBUILT_RNCORE: 0
125+
RCT_USE_RN_DEP: 1
126+
RCT_USE_PREBUILT_RNCORE: 1
130127

131128
steps:
132129
- name: Checkout

example/ios/Podfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,39 @@ target 'ReactNativeUmengExample' do
3030
:mac_catalyst_enabled => false,
3131
# :ccache_enabled => true
3232
)
33+
34+
# ─── RN 0.85.3 prebuilt RNCore patch (facebook/react-native#56862) ───
35+
# Xcode 26 + RCT_USE_PREBUILT_RNCORE=1 时 ReactCodegen 编译 .cpp 报
36+
# 'memory' file not found / could not build module 'ReactCodegen'。
37+
# 根因:React umbrella 把 RCTBridgeConstants.h 放在 RCTDefines.h 之前
38+
# + module.modulemap 用 wildcard 子模块隔离了 header 解析作用域。
39+
# 这里原地 patch prebuilt xcframework 里那两个文件,等 RN 0.85.4 含
40+
# PR #56862 backport 后可删除整段。
41+
pods_root = installer.sandbox.root.to_s
42+
umbrella_path = "#{pods_root}/React-Core-prebuilt/React.xcframework/Headers/React_Core/React_Core-umbrella.h"
43+
if File.exist?(umbrella_path)
44+
content = File.read(umbrella_path)
45+
marker = '// RN-0.85.3-patch: load RCTDefines.h first (#56862)'
46+
unless content.include?(marker)
47+
# 在 `#import <React/CoreModulesPlugins.h>` 之前插入,确保宏先可见
48+
patched = content.sub(
49+
/^#import <React\/CoreModulesPlugins\.h>$/,
50+
"#{marker}\n#import <React/RCTDefines.h>\n\n#import <React/CoreModulesPlugins.h>"
51+
)
52+
if patched != content
53+
File.write(umbrella_path, patched)
54+
Pod::UI.puts " patched #{umbrella_path.sub(pods_root, 'Pods')}".yellow
55+
end
56+
end
57+
end
58+
59+
Dir.glob("#{pods_root}/React-Core-prebuilt/React.xcframework/**/module.modulemap").each do |mm|
60+
content = File.read(mm)
61+
next unless content.include?('module * { export * }')
62+
patched = content.gsub(/^\s*module \* \{ export \* \}\s*$\n?/, '')
63+
File.write(mm, patched)
64+
Pod::UI.puts " patched #{mm.sub(pods_root, 'Pods')}".yellow
65+
end
66+
# ─── end RN 0.85.3 prebuilt RNCore patch ───
3367
end
3468
end

0 commit comments

Comments
 (0)