React native build failed - xcodebuild: error: The workspace named "foo" does not contain a scheme named "foo"

React native build failed - xcodebuild: error: The workspace named "foo" does not contain a scheme named "foo"

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

从我的终端尝试 运行 时
npx react-native run-ios

我收到错误:

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.
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace foo.xcworkspace -configuration Debug -scheme foo -destination id=FEB37

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

xcodebuild: 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.

可能和我的阴谋有关here

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

我也试过了

npx react-native run-ios --configuration Debug --scheme Development

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

** BUILD FAILED **

The following build commands failed:
        MergeSwiftModule normal x86_64
        CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler

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

如果我运行react-native info

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

我试过了restarting my mac... 我必须 吗?

这是 Podfile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'


target 'vicinity' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )
end

post_install do |installer|
  react_native_post_install(installer)
end

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

任何有助于在终端中构建它的帮助都会很棒。

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

/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
<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
<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)'

*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
could not deserialize type for 'ContainerView': top-level value not found
Cross-reference to module 'lottie_react_native'
... RCTView

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Devel...ld/Debug-iphonesimulator/lottie-react-native.build/Objects-normal/x86_64/lottie_react_native.swiftmodule
1.  Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
2.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for module lottie_react_native)
0  swift-frontend           0x000000010c7e5e85 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift-frontend           0x000000010c7e4e78 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010c7e6446 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff2066ed7d _sigtramp + 29
4  libdyld.dylib            0x00007fff20643d08 _dyld_fast_stub_entry(void*, long) + 65
5  libsystem_c.dylib        0x00007fff2057e411 abort + 120
6  swift-frontend           0x0000000108554384 swift::ModuleFileSharedCore::fatal(llvm::Error) + 100
7  swift-frontend           0x00000001084d9b48 swift::ModuleFile::fatal(llvm::Error) + 2600
8  swift-frontend           0x000000010853d824 swift::SILDeserializer::readVTable(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2532
9  swift-frontend           0x00000001085c21cb swift::SILDeserializer::getAll(bool) + 107
10 swift-frontend           0x0000000107ea2393 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 10899
11 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
12 swift-frontend           0x0000000107ea64ac llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 780
13 swift-frontend           0x0000000107ea2d3f swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 143
14 swift-frontend           0x0000000107a0602e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7150
15 swift-frontend           0x0000000107987e82 main + 1266
16 libdyld.dylib            0x00007fff20644f5d start + 1
17 libdyld.dylib            0x0000000000000087 start + 18446603339972718891

=== BUILD TARGET react-native-splash-screen OF PROJECT Pods WITH CONFIGURATION Debug ===

Check dependencies

CompileC /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
    cd /Users/grant/repos/foo/foo-centres-app/packages/app/ios/Pods
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/De...dk/tools:/Users/grant/Library/Android/sdk/tools/bin:/Users/grant/Library/Android/sdk/platform-tools"
    /Applications/Xcode.app/Contents/Developer/Toolc...ld/Debug-iphonesimulator/react-native-splash-screen.build/Objects-normal/x86_64/react-native-splash-screen-dummy.o

CompileC /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
    cd /Users/grant/repos/foo/foo-centres-app/packages/app/ios/Pods
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/D...y/Android/sdk/tools/bin:/Users/grant/Library/Android/sdk/platform-tools"
    /Applications/Xcode.app/Contents/Developer/...uild/Debug-iphonesimulator/react-native-splash-screen.build/Objects-normal/x86_64/RNSplashScreen.o


** BUILD FAILED **


The following build commands failed:
    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
    MergeSwiftModule normal x86_64 /Users/grant/Library/Developer/Xcode/DerivedData/foo-...or/lottie-react-native.build/Objects-normal/x86_64/lottie_react_native.swiftmodule
(2 failures)

info Run CLI with --verbose flag for more details.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @foo/foo-centres-app-app@3.0.3 start: `scripts/start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @foo/foo-centres-app-app@3.0.3 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

➜  ~/repos/foo/foo-centres-app/packages/app git:(update-release-app-v2) ✗

xcodebuild -list

的输出
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -list

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Information about project "foo":
    Targets:
        foo

    Build Configurations:
        Debug
        Release
        Emp
        Chad
        Test
        PreProduction
        Master

    If no build configuration is specified and -scheme is not passed then "Release" is used.

    Schemes:
        Chad
        Development
        Emp
        Master
        PreProduction
        Release
        Test

我怀疑还有其他事情..

请检查超出 的架构,例如accessibility/permission。由于 不止一个原因 可能会发生这种情况,我建议验证以下所有内容。

 // a very helpful debug 
 xcodebuild -list

Basic Debug xcodebuild -list; once they are configured correctly, shared they will successfully should up as shared for you.       

Schemes 的默认配置是 private 你必须 configure/make 它 shared 在 terminal/command-line 构建中,Xcode UI 永远不会运行,并且 xcoderun 工具没有自己的方案缓存。


第 1 步:使您的架构 可访问 command-line build

Make your schema accessible to the command-line build by changing it to a shared scheme.

  1. 菜单 > 产品 > 方案 > 管理方案
  2. Verify/Check 关闭该方案的 'Shared' 框
  • Select 您要创建的架构并单击 Edit 按钮
  • UncheckCheckoff 只是为了确保“共享”复选框。
  1. 现在去WorkspaceName.xcworkspace/xcshareddata/xcschemes
  2. 现在验证新的 .xcscheme 文件是否已在您的项目
    中创建 工作区名称.xcworkspace/xcshareddata/xcschemes.
  3. 请记住 commit 将此文件添加到您的存储库,以便您的 CI 构建也能正常工作
  4. 再次验证,因为文件夹名称是case sensitive

来自您的 build or release configuration 路径


第二步:你有cocoapods - yes/no

NO, If your project is NOT using cocoapods , then you should delete the .xcworkspace file from ./ios directory.

yes, or if you are using a workspace (e.g. with pods), debug/verify like so, here..

// a very helpful debug 
xcodebuild -workspace MyProject.xcworkspace -list

关于 SO 的另一个问题,with different approach


第 3 步:

If you previously created the folder from step 1, or for some reason renamed/edited project, then go in an update the names manually

  1. 在 finder 中将 Foo 作为目录打开。
  2. 打开文件夹xcshareddata/xcschemes
  3. 在那里重命名 xcscheme 文件
  • 运行ning xed --version,你能确定你使用的 Xcode 的版本是正确的吗?可能与 React Native 使用的 Xcode 版本不匹配(并不是说这本身会导致问题)?您可以使用 xcode-select.

    更改它
  • 您可以尝试使用 npm i lottie-react-native@4.0.2you're using 3.5.0.

    lottie-react-native 升级到 4.0.2
  • 您可以尝试使用 npm i lottie-ios@3.2.3

    lottie-ios 升级到 3.2.3
  • 然后确保 运行 cd iospod install

  • 如果您收到链接器警告,请遵循 this

如果你走投无路,你可以删除 ios 文件夹并通过 运行ning 重新生成它,方法是创建一个同名的新项目,并将 iOS 文件夹复制到您现有的项目。或者您可以只比较 2 个项目/方案,看看您缺少什么。

祝你好运

查看来自 xcodebuild -list

的输出
Information about project "foo":
    Targets:
        foo

    Build Configurations:
        Debug
        Release
        Emp
        Chad
        Test
        PreProduction
        Master

    If no build configuration is specified and -scheme is not passed then "Release" is used.

    Schemes:
        Chad
        Development
        Emp
        Master
        PreProduction
        Release
        Test

这个错误来自 npx react-native run-ios -

xcodebuild: 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.

错误表明 - 目标 foo(在输出中的 Targets: 下列出)应该有一个名为 foo 的对应方案(应该在 [=18 下列出) =] 在输出中)使用 npx react-native run-ios.

时找不到

正如你所说,你可以从Xcode成功运行这个,你应该注意你运行宁的方案。您可以在左上角找到它 - 就在播放/停止按钮旁边。 冒险iOS下图就是方案

记下它的名称(区分大小写),确保它在上面的输出中的 Schemes: 下列出,如果不是 - 确保它是共享的(编辑方案 > 选中共享复选框)。

之后,您可以 运行 使用命令行使用该方案名称,如下所示 - 假设您已成功 运行ning 来自 Xcode、运行 的“乍得”方案像这样使用命令行。

npx react-native run-ios --scheme "Chad"