Xcodebuild fails with 'missing module map file' when compiling framework with a package dependency

I'm trying to create a Framework with a package dependency of EmarsysSDK.
xcodebuild compiles fine until I add import EmarsysSDK to start using the added package. Then xcodebuild won't compile anymore with

<unknown>:0: error: module map file 'PROJECTPATH/build/GeneratedModuleMaps-iphonesimulator/EmarsysSDK.modulemap' not found
/PROJECTPATH/Emarsys.swift:9:29: error: no such module 'EmarsysSDK'
@_implementationOnly import EmarsysSDK

I don't see other errors in output though at the end it says 2 failures.

Here is command line
xcodebuild -sdk iphonesimulator16.2 -project EmarsysBridge.xcodeproj -configuration Release

I've tried using @_implementationOnly (as seen above) with import, but it doesn't change anything. XCode is 14.2. running on x64.
The project is really a vanilla Framework from template with package dependency added and that import statement.
I see that missing file in question is mentioned few times in xcodebuild output though.

Am I missing something obvious?

Failed to mention that the same project compiles just fine within XCode.

Nevermind, it was a combination of factors, most importantly build output not being there where I expected it to be and I didn't pass -schema or -target argument to xcodebuild.