xcodebuild resolves dependency, but can't import the package

Viewed 526

I have a simple command line application, written in swift 5.3, which uses the ArgumentParser package from Apple.

It builds and runs just fine from within Xcode (12.4). However, if I run xcodebuild, as such:

xcodebuild -target mailfilter

It gives this error:

/Users/hacksaw/Documents/src/mailfilter/mailfilter/main.swift:10:8: error: no such module 'ArgumentParser'
import ArgumentParser
       ^

The relevant project info:

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

Resolve Package Graph

Resolved source packages:
  swift-argument-parser: https://github.com/apple/swift-argument-parser @ 0.3.2

Information about project "mailfilter":
    Targets:
        mailfilter

    Build Configurations:
        Debug
        Release

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

    Schemes:
        mailfilter


% xcodebuild -version
Xcode 12.4
Build version 12D4e

So, what command line ought I run for it to build correctly?

1 Answers

So the (still unsatisfying) answer to this is indeed that -scheme needs to be included, so this works:

xcodebuild -scheme mailfilter -target mailfilter

An article I read somewhere said something about xcodebuild having a "legacy" mode which is invoked if you don't include a -scheme argument, but didn't go into detail.

I'd love a more complete answer to this, but for now, I'm leaving it.

Related