首先,我必须为这个宽泛的标题道歉,但我无法准确指出我遇到的问题的根源。我在尝试构建 React Native 应用程序时遇到问题。根据我使用的是 Xcode GUI、CLI 构建命令还是 npx react-native run-ios,错误会有所不同。详情如下:
node -v: v22.12.0
npm -v: 10.9.0
pod --version: 1.16.2
xcodebuild -version: Xcode 16.2
Build version 16C5032a
1。 Xcode GUI 构建错误
通过 Xcode 构建时(清理后),我遇到此错误:
error: Sandbox: rsync.samba(1739) deny(1) file-read-data /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/hermes-engine/Pre-built/hermes.framework/Info.plist (in target 'FrontEnd' from project 'FrontEnd')
error: Sandbox: rsync.samba(1771) deny(1) file-write-create /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Products/Debug-iphonesimulator/FrontEnd.app/Frameworks/hermes.framework/.hermes.U530o7 (in target 'FrontEnd' from project 'FrontEnd')
mkdir -p /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Products/Debug-iphonesimulator/FrontEnd.app/Frameworks
rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "/Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/hermes-engine/Pre-built/hermes.framework" "/Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Products/Debug-iphonesimulator/FrontEnd.app/Frameworks"
building file list ... done
hermes.framework/
rsync: send_files failed to open "/Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/hermes-engine/Pre-built/hermes.framework/Info.plist": Operation not permitted (1)
hermes.framework/hermes
rsync: mkstemp "/Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Products/Debug-iphonesimulator/FrontEnd.app/Frameworks/hermes.framework/.hermes.U530o7" failed: Operation not permitted (1)
sent 13644808 bytes received 70 bytes 27289756.00 bytes/sec
total size is 13643829 speedup is 1.00
rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/91a344b1-f985-11ee-b563-fe8bc7981bff/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
2。 CLI 构建错误 (xcodebuild) 运行 xcodebuild clean 然后 xcodebuild -workspace FrontEnd.xcworkspace -scheme FrontEnd -sdk iphonesimulator -configuration Debug 我得到:
warning: Run script build phase '[CP-User] [RN]Check rncore' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'React-FabricComponents' from project 'Pods')
warning: Run script build phase '[CP-User] [RN]Check rncore' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'React-Fabric' from project 'Pods')
warning: Run script build phase 'Bundle React Native code and images' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'FrontEnd' from project 'FrontEnd')
warning: Run script build phase '[CP-User] [Hermes] Replace Hermes for the right configuration, if needed' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'hermes-engine' from project 'Pods')
** BUILD FAILED **
The following build commands failed:
CompileC /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCodegen.build/Objects-normal/x86_64/safeareacontext-generated.o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/build/generated/ios/safeareacontext/safeareacontext-generated.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCodegen' from project 'Pods')
CompileC /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCodegen.build/Objects-normal/arm64/safeareacontextJSI-generated.o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/build/generated/ios/safeareacontextJSI-generated.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCodegen' from project 'Pods')
CompileC /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCodegen.build/Objects-normal/arm64/rnscreensJSI-generated.o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/build/generated/ios/rnscreensJSI-generated.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCodegen' from project 'Pods')
CompileC /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCodegen.build/Objects-normal/arm64/States-6f0d2878f77de8415f168216ca4f8bea.o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/build/generated/ios/react/renderer/components/rngesturehandler_codegen/States.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCodegen' from project 'Pods')
CompileC /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCodegen.build/Objects-normal/x86_64/safeareacontextJSI-generated.o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/build/generated/ios/safeareacontextJSI-generated.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCodegen' from project 'Pods')
CompileC /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCodegen.build/Objects-normal/x86_64/rnscreensJSI-generated.o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/build/generated/ios/rnscreensJSI-generated.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCodegen' from project 'Pods')
CompileC /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCodegen.build/Objects-normal/x86_64/rnscreens-generated.o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/build/generated/ios/rnscreens/rnscreens-generated.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCodegen' from project 'Pods')
CompileC /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCodegen.build/Objects-normal/x86_64/rnreanimatedJSI-generated.o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/build/generated/ios/rnreanimatedJSI-generated.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCodegen' from project 'Pods')
CompileC /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCodegen.build/Objects-normal/x86_64/rnreanimated-generated.o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/build/generated/ios/rnreanimated/rnreanimated-generated.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCodegen' from project 'Pods')
Building workspace FrontEnd with scheme FrontEnd and configuration Debug
(10 failures)
3. npx react-native run-ios 错误 --verbose
error \=non-modular-include-in-framework-module -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wimplicit-retain-self -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wdeprecated-implementations -Wno-c++11-extensions -Wno-implicit-fallthrough -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Index.noindex/DataStore -Wno-comma -Wno-shorten-64-to-32 @/Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTFabric.build/Objects-normal/arm64/af3fcb34312c57c0f52879cdce924b91-common-args.resp -DFOLLY_NO_CONFIG -DFOLLY_MOBILE\=1 -DFOLLY_USE_LIBCPP\=1 -DFOLLY_CFG_NO_COROUTINES\=1 -DFOLLY_HAVE_CLOCK_GETTIME\=1 -Wno-comma -Wno-shorten-64-to-32 -Wno-documentation -include /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/Pods/Target\ Support\ Files/React-RCTFabric/React-RCTFabric-prefix.pch -MMD -MT dependencies -MF /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTFabric.build/Objects-normal/arm64/RCTDebuggingOverlayComponentView.d --serialize-diagnostics /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTFabric.build/Objects-normal/arm64/RCTDebuggingOverlayComponentView.dia -c /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/node_modules/react-native/React/Fabric/Mounting/ComponentViews/DebuggingOverlay/RCTDebuggingOverlayComponentView.mm -o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTFabric.build/Objects-normal/arm64/RCTDebuggingOverlayComponentView.o -index-unit-output-path /Pods.build/Debug-iphonesimulator/React-RCTFabric.build/Objects-normal/arm64/RCTDebuggingOverlayComponentView.o
error \=non-modular-include-in-framework-module -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wimplicit-retain-self -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wdeprecated-implementations -Wno-c++11-extensions -Wno-implicit-fallthrough -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Index.noindex/DataStore -Wno-comma -Wno-shorten-64-to-32 @/Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTFabric.build/Objects-normal/arm64/af3fcb34312c57c0f52879cdce924b91-common-args.resp -DFOLLY_NO_CONFIG -DFOLLY_MOBILE\=1 -DFOLLY_USE_LIBCPP\=1 -DFOLLY_CFG_NO_COROUTINES\=1 -DFOLLY_HAVE_CLOCK_GETTIME\=1 -Wno-comma -Wno-shorten-64-to-32 -Wno-documentation -include /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/Pods/Target\ Support\ Files/React-RCTFabric/React-RCTFabric-prefix.pch -MMD -MT dependencies -MF /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTFabric.build/Objects-normal/arm64/RCTComponentViewFactory.d --serialize-diagnostics /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTFabric.build/Objects-normal/arm64/RCTComponentViewFactory.dia -c /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm -o /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTFabric.build/Objects-normal/arm64/RCTComponentViewFactory.o -index-unit-output-path /Pods.build/Debug-iphonesimulator/React-RCTFabric.build/Objects-normal/arm64/RCTComponentViewFactory.o
error export CLANG_WARN_EMPTY_BODY\=YES
error Sandbox: rsync.samba(7933) deny(1) file-read-data /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/hermes-engine/Pre-built/hermes.framework/Info.plist (in target 'FrontEnd' from project 'FrontEnd')
error Sandbox: rsync.samba(7936) deny(1) file-write-create /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/FrontEnd/Build/Products/Debug-iphonesimulator/FrontEnd.app/Frameworks/hermes.framework/.hermes.Vd2WZp (in target 'FrontEnd' from project 'FrontEnd')
error some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/91a344b1-f985-11ee-b563-fe8bc7981bff/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
error Failed to build ios project. "xcodebuild" exited with error code '65'. To debug build logs further, consider building your app with Xcode.app, by opening 'FrontEnd.xcworkspace'.
npx 反应本机医生输出:
npx react-native doctor
⠋ Running diagnostics...(node:87499) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
⠴ Running diagnostics.../bin/sh: adb: command not found
Common
✓ Node.js - Required to execute JavaScript code
✓ yarn - Required to install NPM dependencies
✓ npm - Required to install NPM dependencies
✓ Watchman - Used for watching changes in the filesystem when in development mode
● Metro - Metro Bundler is not running
Android
✖ Adb - No devices and/or emulators connected. Please create emulator with Android Studio or connect Android device.
✖ JDK - Required to compile Java code
- Version found: 21.0.4
- Version supported: >= 17 <= 20
✖ Android Studio - Required for building and installing your app on Android
✖ ANDROID_HOME - Environment variable that points to your Android SDK installation
✓ Gradlew - Build tool required for Android builds
✖ Android SDK - Required for building and installing your app on Android
- Versions found: N/A
- Version supported: 35.0.0
iOS
✓ Xcode - Required for building and installing your app on iOS
✓ Ruby - Required for installing iOS dependencies
✓ CocoaPods - Required for installing iOS dependencies
● ios-deploy - Required for installing your app on a physical device with the CLI
✓ .xcode.env - File to customize Xcode environment
Errors: 5
Warnings: 2
Usage
› Press f to try to fix issues.
› Press e to try to fix errors.
› Press w to try to fix warnings.
› Press Enter to exit.
到目前为止我尝试过的事情
这可能是由于限制性文件权限或 macOS 安全策略而发生的。
sudo chmod -R 755 /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData
另外,如果需要,请明确授予对 Info.plist 和其他文件的访问权限
sudo chmod 644 /Users/nicolassaade/Desktop/file_tree/projects/TikTok_Parser/FrontEnd/ios/DerivedData/.../Info.plist
清理派生数据
rm -rf ~/Library/Developer/Xcode/DerivedData
打开 Xcode,转到“构建设置”选项卡。
Set CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES to YES.
谢谢。