[iOS] React Native's headers fail a Swift import built with SWIFT_TREAT_WARNINGS_AS_ERRORS (nullability and deprecation warnings)
維護者通常 2 天內回覆
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 70/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- ios, objective-c, react-native
- 領域
- mobile
研究方向
Read PR #59240 to see the prior fix pattern for nullability warnings. Edit RCTWebSocketModule.h:23, RCTReactTaggedView.h:29, RCTRedBox+Internal.h, RCTRedBox2Controller+Internal.h, RCTRedBox2ErrorParser+Internal.h and RCTUIConfiguratorProtocol.h:40 to add missing nullability specifiers or drop deprecated RCTRootView. Build the linked reproducer with SWIFT_TREAT_WARNINGS_AS_ERRORS=YES; done when xcodebuild emits no pcm errors.
由索引模型根據 Issue 內容生成。
描述
Description
An app or a library whose Swift target sets SWIFT_TREAT_WARNINGS_AS_ERRORS = YES cannot import React Native's modules: Xcode precompiles the imported Clang module with the target's warnings as errors, and React Native's own public headers warn there. This happens on main, with both the default prebuilt core and a source build.
https://github.com/react/react-native/pull/59240 fixed the same kind of warning in RCTHTTPRequestHandler.h and RCTMultipartDataTask.h. These headers still warn on main (f1f1474058; the nightly I ran is e57dcb3cc, four commits behind, and its copies of these headers match main):
React/CoreModules/RCTWebSocketModule.h:23:typedef SRWebSocket * (^SRWebSocketProvider)(NSURLRequest *request);is insideNS_ASSUME_NONNULL, but the block typedef's pointers are not inferred, so-Wnullability-completenessfires.React/Fabric/Utils/RCTReactTaggedView.h:29:- (BOOL)isEqual:(id)other;insideNS_ASSUME_NONNULLmakes the parameternonnull, which conflicts with NSObject'snullable id.React/CoreModules/RCTRedBox+Internal.h,RCTRedBox2Controller+Internal.handRCTRedBox2ErrorParser+Internal.h: each hasnullablemembers and noNS_ASSUME_NONNULLregion, so every other pointer warns.Libraries/AppDelegate/RCTUIConfiguratorProtocol.h:40:- (void)customizeRootView:(RCTRootView *)rootView;uses the deprecatedRCTRootView, so-Wdeprecated-declarationsfires in the module build.
The source build stops at the first module that fails (React_RCTAppDelegate), so it does not reach RCTWebSocketModule.h, which the prebuilt run shows.
Steps to reproduce
The reproducer is the reproducer template with [email protected] (built from main), @react-native-community/[email protected] (the nightly needs it for autolinking), and SWIFT_TREAT_WARNINGS_AS_ERRORS = YES on the app target. The template's SceneDelegate.swift already has import React and import React_RCTAppDelegate. No simulator or signing is needed.
cd ReproducerApp && npm installcd ios && pod installxcodebuild -workspace ReproducerApp.xcworkspace -scheme ReproducerApp -configuration Debug -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' CODE_SIGNING_ALLOWED=NO build- Then
RCT_USE_PREBUILT_RNCORE=0 pod installand the samexcodebuildcommand, to build React Native from source.
Expected: the app builds, since nothing in it warns.
Seen: ** BUILD FAILED ** in SwiftExplicitDependencyGeneratePcm, on warnings in React Native's headers (see the logs below).
React Native Version
0.89.0-nightly-20261031-e57dcb3cc
Affected Platforms
Runtime - iOS, Build - MacOS
Output of npx @react-native-community/cli info
System:
OS: macOS 27.0.1
CPU: (8) arm64 Apple M1
Memory: 500.36 MB / 8.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 26.12.1
path: /Users/yevhenii/.nvm/versions/node/v26.12.1/bin/node
Yarn: Not Found
npm:
version: 12.2.1
path: /Users/yevhenii/.nvm/versions/node/v26.12.1/bin/npm
Watchman:
version: 2026.10.19.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.17.0
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 27.2
- iOS 27.2
- macOS 27.2
- tvOS 27.2
- visionOS 27.2
- watchOS 27.2
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 27.2/27B52
path: /usr/bin/xcodebuild
Languages:
Java: Not Found
Ruby:
version: 4.0.9
path: /opt/homebrew/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 21.0.0-alpha.1
wanted: 21.0.0-alpha.1
react:
installed: 19.3.0
wanted: 19.3.0
react-native:
installed: 0.89.0-nightly-20261031-e57dcb3cc
wanted: 0.89.0-nightly-20261031-e57dcb3cc
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: false
Stacktrace or Logs
# step 3, default prebuilt core (paths below the temporary folder shortened to …/)
…/derived-data/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/React-Core-prebuilt/React.framework/Headers/RCTReactTaggedView.h:29:21: error: conflicting nullability specifier on parameter types, 'nonnull' conflicts with existing specifier 'nullable'
…/derived-data/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/React-Core-prebuilt/React.framework/Headers/RCTWebSocketModule.h:23:21: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
<unknown>:0: error: failed to emit precompiled module '…/derived-data/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules/React-EB9M1Z4OHNICYJK47EJBN2CQ0.pcm' for module map '…/derived-data/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/React-Core-prebuilt/React.framework/Modules/module.modulemap'
** BUILD FAILED **
The following build commands failed:
SwiftExplicitDependencyGeneratePcm arm64 …/derived-data/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules/React-EB9M1Z4OHNICYJK47EJBN2CQ0.pcm
# step 4, RCT_USE_PREBUILT_RNCORE=0
…/ReproducerApp/ios/Pods/Headers/Public/React-Core/React/RCTRedBox+Internal.h:17:44: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
…/ReproducerApp/ios/Pods/Headers/Public/React-Core/React/RCTRedBox2Controller+Internal.h:20:4: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
…/ReproducerApp/ios/Pods/Headers/Public/React-Core/React/RCTRedBox2ErrorParser+Internal.h:17:38: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
…/ReproducerApp/ios/Pods/Headers/Public/React-Core/React/RCTRedBox2ErrorParser+Internal.h:41:24: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
…/ReproducerApp/ios/Pods/Headers/Public/React-Core/React/RCTRedBox2ErrorParser+Internal.h:41:54: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
…/ReproducerApp/ios/Pods/Headers/Public/React-RCTAppDelegate/RCTUIConfiguratorProtocol.h:40:28: error: 'RCTRootView' is deprecated: This API will be removed along with the legacy architecture.
<unknown>:0: error: failed to emit precompiled module '…/derived-data/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules/React_RCTAppDelegate-B8C35ZXJIXKD5SNK3CAGCPF8S.pcm' for module map '…/ReproducerApp/ios/Pods/Headers/Public/React_RCTAppDelegate/React-RCTAppDelegate.modulemap'
** BUILD FAILED **
The following build commands failed:
SwiftExplicitDependencyGeneratePcm x86_64 …/derived-data/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules/React_RCTAppDelegate-B8C35ZXJIXKD5SNK3CAGCPF8S.pcm
macOS 27.0.1, Xcode 27.2 (27B52), Apple Swift 6.4.2, CocoaPods 1.17.0, Node 26.12.1, npm 12.2.1.
https://github.com/react/react-native/issues/57524 reported the RCTWebSocketModule.h warning under the prebuilt path in 0.86.0 and was closed without a reproducer.
MANDATORY Reproducer
https://github.com/YevheniiKotyrlo/react-native-react-core-headers-warnings-as-errors
Screenshots and Videos
No response
- 主要語言
- C++
- 星號
- 127k
- 分支
- 25.4k
- 平均合併
- 3 天 1 小時
- 30 天內合併 PR
- 108
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
react/react-native 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
react/react-native#59722 ·
維護者通常 2 天內回覆
-
Android: new WebSocket() crashes the app for a URL that OkHttp or java.net.URI rejects可能已有人在做 @sorinc03 於 1 天前認領。 未關閉🌐Networking Needs: Author Feedback Needs: Repro Platform: Android
難度 2/5 1-3 小時 新手友好度 72/100
react/react-native#59704 · 1 則留言 ·
維護者通常 2 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
react/react-native#59694 ·
維護者通常 2 天內回覆
-
Image.resolveAssetSource's TypeScript declaration drops the null it returns for an unknown asset可能已有人在做 @Hassan1305 於 4 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
react/react-native#59648 · 1 則留言 ·
維護者通常 2 天內回覆
-
Linking.getInitialURL() returns the task's first link after a link relaunches a reclaimed Android app可能已有人在做 @YevheniiKotyrlo 於 21 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
react/react-native#59006 · 2 則留言 ·
維護者通常 2 天內回覆
查看 react/react-native 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
meshcore-dev/MeshCore#3760 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
deepseek-ai/DeepGEMM-Ascend#29 ·
維護者通常 1 天內回覆
-
documentation
難度 2/5 1-3 小時 新手友好度 70/100
EchoTools/nevr-runtime#2042 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
emscripten-core/emscripten#28160 · 1 則留言 ·
維護者通常 1 天內回覆
-
Download size and speed show scientific notation between 1000 and 1023 units可能已有人在做 @RaphaelFakhri 今天認領。 未關閉
難度 2/5 1 小時以內 新手友好度 88/100
kiwix/kiwix-desktop#1570 ·
維護者通常 1 天內回覆