iosxcodecommand-lineswift-package-managerjazzy

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


I have a project which uses SPM (and does not use cocoapods). It compiles and runs fine.

I can run SwiftLint autocorrect from the command line and that works too.

However, when I try to run jazzy on it, I am getting this error:

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

I went through many "fixes" for similar problems: I updated system preferences to allow terminal access to Developer Tools, etc.

SPM Configuration

The jazzy command works for my other projects, some of which use the SPM, which baffles me a bit. As a workaround, I will remove SPM and use carthage to create the Realm and RealmSwift frameworks I need.

For completists:

Command line invocation:

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

Does anyone recognize these symptoms?


Solution

  • First of all, whoever just upvoted this - thank you! (it reminded me to come back to this and resolve it)

    The solution (now) is simple - use the latest version of RealmSwift

    screenshot

    SPM product url

    Notice the url in the "Location" column. That's all you need.

    Delete whatever you are using that doesn't work.

    Starting fresh, use the url:

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

    and accept the defaults

    In pictures:

    SPM Configure 1

    valid url