为什么我从命令行中找不到 xcodebuild 致命错误模块映射文件

Why do i get xcodebuild fatal error module map file not found from command line

我有一个使用 SPM 的项目(不使用 cocoapods)。 它编译并且运行没问题。

我可以从命令行 运行 SwiftLint 自动更正,这也行得通。

但是,当我尝试 运行 jazzy 时,出现了这个错误:

fatal error: module map file '/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/buil d/GeneratedModuleMaps/iphoneos/RealmCore.modulemap' not found

我经历了很多类似的问题"fixes":我更新了系统偏好设置以允许终端访问开发者工具等

jazzy 命令适用于我的其他项目,其中一些项目使用 SPM,这让我有点困惑。作为解决方法,我将删除 SPM 并使用 carthage 来创建我需要的 Realm 和 RealmSwift 框架。

完美主义者:

命令行调用:

2 /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -target Answers -sdk iphoneos
3
4 Build settings from command line:
5 SDKROOT = iphoneos13.4
6
7 Resolve Package Graph
8
9 Resolved source packages:
10 Realm: https://github.com/realm/realm-cocoa.git @ 4.4.1
11 Alamofire: https://github.com/Alamofire/Alamofire.git @ 5.1.0
12 RealmCore: https://github.com/realm/realm-core @ 5.23.8
13
14
15 note: Using new build system
16 note: Planning build
17 note: Using build description from disk
18 CompileC /Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/build/Realm.build/Release -iphoneos/Realm.build/Objects-normal/arm64/collection_notifications.o /Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/Realm/ObjectStore/src/collection_notifications.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'Realm' from project 'Realm')
19 cd /Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa

20 export LANG=en_US.US-ASCII

21 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target arm64-apple-ios8.0 -fmessage-length=0 -fdiag nostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=c++14 -fmodules -gmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild -session-file=/var/folders/by/cr9r24wn2fn47wpyjnrq73qc0000gn/C/org.llvm.clang/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build -session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -fmodule-name=Realm -Wno-trigraphs -fpascal-strings -Os - Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missin g-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enu m-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions - DSWIFT_PACKAGE -DREALM_SPM=1 -DREALM_COCOA_VERSION=@\"4.4.1\" -DREALM_VERSION=\"5.23.8\" -DREALM_NO_CONFIG -DREALM_INSTALL_LIBEXECDIR= -DREALM_ENABLE_ASSERT IONS=1 -DREALM_ENABLE_ENCRYPTION=1 -DREALM_VERSION_MAJOR=5 -DREALM_VERSION_MINOR=23 -DREALM_VERSION_PATCH=8 -DREALM_VERSION_EXTRA=\"\" -DREALM_VERSION_STRING=\"5.23.8\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.4.sdk -fstrict-aliasing -Wdeprecated -declarations -Winvalid-offsetof -g -fvisibility-inlines-hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autorel easing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -fembed-bitcode-marker -I/Users/Alex/Library/Developer/Xcode/Derive dData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-core/src -I/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrke wvufnejnpluej/SourcePackages/checkouts/realm-cocoa/build/Release-iphoneos/include -I/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkew vufnejnpluej/SourcePackages/checkouts/realm-cocoa/include -I/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePacka ges/checkouts/realm-cocoa -I/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/includ e -I/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/Realm/ObjectStore/src -I/Users /Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/build/Realm.build/Release-iphoneos/Realm .build/DerivedSources-normal/arm64 -I/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/build/Realm.build/Release-iphoneos/Realm.build/DerivedSources/arm64 -I/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnplue j/SourcePackages/checkouts/realm-cocoa/build/Realm.build/Release-iphoneos/Realm.build/DerivedSources -F/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/build/Release-iphoneos -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS. platform/Developer/Library/Frameworks -fmodule-map-file=/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/ checkouts/realm-cocoa/build/GeneratedModuleMaps/iphoneos/RealmCore.modulemap -DXcode -MMD -MT dependencies -MF /Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/build/Realm.build/Release-iphoneos/Realm.build/Objects-normal/arm64/collection_ notifications.d --serialize-diagnostics /Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm- cocoa/build/Realm.build/Release-iphoneos/Realm.build/Objects-normal/arm64/collection_notifications.dia -c /Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/Realm/ObjectStore/src/collection_notifications.cpp -o /Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/build/Realm.build/Release-iphoneos/Realm.build/Objects-normal/ar m64/collection_notifications.o
22 fatal error: module map file '/Users/Alex/Library/Developer/Xcode/DerivedData/Answers-akfeigwudbzjrkewvufnejnpluej/SourcePackages/checkouts/realm-cocoa/buil d/GeneratedModuleMaps/iphoneos/RealmCore.modulemap' not found
23 warning: Could not read serialized diagnostics file: Cannot Load File: Failed to open diagnostics file (in target 'Realm' from project 'Realm')

有人认识这些症状吗?

首先,刚刚投票的人 - 谢谢! (它提醒我回到这个问题并解决它)

解决方案(现在)很简单——使用最新版本的 RealmSwift

注意“位置”列中的 url。这就是您所需要的。

删除你正在使用的任何不起作用的东西。

重新开始,使用 url:

"https://github.com/realm/realm-cocoa.git" 

并接受默认值

图片中: