React Native 构建失败 - xcodebuild:错误:名为“foo”的工作区不包含名为“foo”的方案

gra*_*ury 8 xcode react-native-ios lottie

我有一个反应本机应用程序,当从 XCode 运行时,它按预期工作(在模拟器上构建和运行)。但是当我尝试从我的终端运行它时

\n
npx react-native run-ios\n
Run Code Online (Sandbox Code Playgroud)\n

我收到错误:

\n
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening foo.xcworkspace.\nCommand line invocation:\n    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace foo.xcworkspace -configuration Debug -scheme foo -destination id=FEB37\n\nUser defaults from command line:\n    IDEPackageSupportUseBuiltinSCM = YES\n\nxcodebuild: error: The workspace named "foo" does not contain a scheme named "foo". The "-list" option can be used to find the names of the schemes in the workspace.\n
Run Code Online (Sandbox Code Playgroud)\n

可能跟我的计划有关系

\n

当我在 XCode 中管理我的方案时,我看不到方案 \'foo\'。它是一个通用应用程序,因此它使用 XCode 管理 gui 中的方案“bar”。

\n

我也尝试过

\n
npx react-native run-ios --configuration Debug --scheme Development\n
Run Code Online (Sandbox Code Playgroud)\n

并得到一个非常大的注销,其结尾为:

\n
** BUILD FAILED **\n\nThe following build commands failed:\n        MergeSwiftModule normal x86_64\n        CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler\n
Run Code Online (Sandbox Code Playgroud)\n

如果我将 XCode 从 12.5 降级到 12.0.1,它会按预期工作。但我想使用最新的XCode。

\n

如果我跑react-native info

\n
info Fetching system and libraries information...\n(node:11609) Warning: Accessing non-existent property \'padLevels\' of module exports inside circular dependency\n(Use `node --trace-warnings ...` to show where the warning was created)\nSystem:\n    OS: macOS 11.4\n    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz\n    Memory: 905.50 MB / 16.00 GB\n    Shell: 5.8 - /bin/zsh\n  Binaries:\n    Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node\n    Yarn: 1.22.4 - /usr/local/bin/yarn\n    npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm\n    Watchman: 4.9.0 - /usr/local/bin/watchman\n  Managers:\n    CocoaPods: 1.10.1 - /usr/local/bin/pod\n  SDKs:\n    iOS SDK:\n      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4\n    Android SDK:\n      API Levels: 28, 29, 30\n      Build Tools: 29.0.2, 30.0.3, 31.0.0\n      System Images: android-28 | Google Play Intel x86 Atom, android-29 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom\n      Android NDK: Not Found\n  IDEs:\n    Android Studio: 4.2 AI-202.7660.26.42.7351085\n    Xcode: 12.5/12E262 - /usr/bin/xcodebuild\n  Languages:\n    Java: 15.0.2 - /usr/bin/javac\n  npmPackages:\n    @react-native-community/cli: Not Found\n    react: 17.0.2 => 17.0.2 \n    react-native: 0.64.0 => 0.64.0 \n    react-native-macos: Not Found\n  npmGlobalPackages:\n    *react-native*: Not Found\n
Run Code Online (Sandbox Code Playgroud)\n

我已尝试重新启动我的 Mac ...\n我是否必须等待依赖项更新

\n

这是 Podfile

\n
require_relative \'../node_modules/react-native/scripts/react_native_pods\'\nrequire_relative \'../node_modules/@react-native-community/cli-platform-ios/native_modules\'\nplatform :ios, \'10.0\'\n\n\ntarget \'vicinity\' do\n  config = use_native_modules!\n\n  use_react_native!(\n    :path => config[:reactNativePath],\n    # to enable hermes on iOS, change `false` to `true` and then install pods\n    :hermes_enabled => false\n  )\nend\n\npost_install do |installer|\n  react_native_post_install(installer)\nend\n
Run Code Online (Sandbox Code Playgroud)\n

我还尝试清理并重新运行启动脚本。

\n

任何将其内置于终端的帮助都会很棒。

\n

这是构建失败日志的最后一点:

\n
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -merge-modules -emit-module /Users/grant/Library/Developer/Xcode/Derivtes.noindex/Pods.build/Debug-iphonesimulator/lottie-react-native.build/Objects-normal/x86_64/lottie_react_native.swiftmodule\n<unknown>:0: error: fatal error encountered while reading from module \'lottie_react_native\'; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project\n<unknown>:0: note: module \'lottie_react_native\' full misc version is \'5.4(5.4)/Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)\'\n\n*** DESERIALIZATION FAILURE (please include this section in any bug report) ***\ncould not deserialize type for \'ContainerView\': top-level value not found\nCross-reference to module \'lottie_react_native\'\n... RCTView\n\nPlease submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.\nStack dump:\n0.  Program arguments: /Applications/Xcode.app/Contents/Devel...ld/Debug-iphonesimulator/lottie-react-native.build/Objects-normal/x86_64/lottie_react_native.swiftmodule\n1.  Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)\n2.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for module lottie_react_native)\n0  swift-frontend           0x000000010c7e5e85 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37\n1  swift-frontend           0x000000010c7e4e78 llvm::sys::RunSignalHandlers() + 248\n2  swift-frontend           0x000000010c7e6446 SignalHandler(int) + 262\n3  libsystem_platform.dylib 0x00007fff2066ed7d _sigtramp + 29\n4  libdyld.dylib            0x00007fff20643d08 _dyld_fast_stub_entry(void*, long) + 65\n5  libsystem_c.dylib        0x00007fff2057e411 abort + 120\n6  swift-frontend           0x0000000108554384 swift::ModuleFileSharedCore::fatal(llvm::Error) + 100\n7  swift-frontend           0x00000001084d9b48 swift::ModuleFile::fatal(llvm::Error) + 2600\n8  swift-frontend           0x000000010853d824 swift::SILDeserializer::readVTable(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2532\n9  swift-frontend           0x00000001085c21cb swift::SILDeserializer::getAll(bool) + 107\n10 swift-frontend           0x0000000107ea2393 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 10899\n11 swift-frontend           0x0000000107fae50d swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 205\n12 swift-frontend           0x0000000107ea64ac llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 780\n13 swift-frontend           0x0000000107ea2d3f swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 143\n14 swift-frontend           0x0000000107a0602e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7150\n15 swift-frontend           0x0000000107987e82 main + 1266\n16 libdyld.dylib            0x00007fff20644f5d start + 1\n17 libdyld.dylib            0x0000000000000087 start + 18446603339972718891\n\n=== BUILD TARGET react-native-splash-screen OF PROJECT Pods WITH CONFIGURATION Debug ===\n\nCheck dependencies\n\nCompileC /Users/grant/Library/Developer/Xcode/Derive...t-native-splash-screen/react-native-splash-screen-dummy.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler\n    cd /Users/grant/repos/foo/foo-centres-app/packages/app/ios/Pods\n    export LANG=en_US.US-ASCII\n    export PATH="/Applications/Xcode.app/Contents/De...dk/tools:/Users/grant/Library/Android/sdk/tools/bin:/Users/grant/Library/Android/sdk/platform-tools"\n    /Applications/Xcode.app/Contents/Developer/Toolc...ld/Debug-iphonesimulator/react-native-splash-screen.build/Objects-normal/x86_64/react-native-splash-screen-dummy.o\n\nCompileC /Users/grant/Library/Developer/Xcode/Derived...app/node_modules/react-native-splash-screen/ios/RNSplashScreen.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler\n    cd /Users/grant/repos/foo/foo-centres-app/packages/app/ios/Pods\n    export LANG=en_US.US-ASCII\n    export PATH="/Applications/Xcode.app/Contents/D...y/Android/sdk/tools/bin:/Users/grant/Library/Android/sdk/platform-tools"\n    /Applications/Xcode.app/Contents/Developer/...uild/Debug-iphonesimulator/react-native-splash-screen.build/Objects-normal/x86_64/RNSplashScreen.o\n\n\n** BUILD FAILED **\n\n\nThe following build commands failed:\n    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler\n    MergeSwiftModule normal x86_64 /Users/grant/Library/Developer/Xcode/DerivedData/foo-...or/lottie-react-native.build/Objects-normal/x86_64/lottie_react_native.swiftmodule\n(2 failures)\n\ninfo Run CLI with --verbose flag for more details.\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! @foo/foo-centres-app-app@3.0.3 start: `scripts/start`\nnpm ERR! Exit status 1\nnpm ERR!\nnpm ERR! Failed at the @foo/foo-centres-app-app@3.0.3 start script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\n\xe2\x9e\x9c  ~/repos/foo/foo-centres-app/packages/app git:(update-release-app-v2) \xe2\x9c\x97\n
Run Code Online (Sandbox Code Playgroud)\n

的输出xcodebuild -list

\n
Command line invocation:\n    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -list\n\nUser defaults from command line:\n    IDEPackageSupportUseBuiltinSCM = YES\n\nInformation about project "foo":\n    Targets:\n        foo\n\n    Build Configurations:\n        Debug\n        Release\n        Emp\n        Chad\n        Test\n        PreProduction\n        Master\n\n    If no build configuration is specified and -scheme is not passed then "Release" is used.\n\n    Schemes:\n        Chad\n        Development\n        Emp\n        Master\n        PreProduction\n        Release\n        Test\n
Run Code Online (Sandbox Code Playgroud)\n

Ben*_*rth 1

  • 您能否通过运行xed --version. 可能与 React Native 正在使用的 Xcode 版本不匹配(这并不是说这本身就会导致问题)?您可以使用 更改它xcode-select

  • 您可以尝试升级lottie-react-native4.0.2, 使用npm i lottie-react-native@4.0.2,您正在使用 3.5.0.

  • 您可以尝试升级lottie-ios3.2.3,使用npm i lottie-ios@3.2.3

  • 然后确保你跑cd ios了并且pod install

  • 如果您收到链接器警告,请按照此操作

如果你绝望了,你可以删除该ios文件夹并通过创建一个同名的新项目运行来重新生成它,并将 iOS 文件夹复制到现有项目中。或者您可以比较这两个项目/方案,看看您缺少什么。

祝你好运