Bird
0
0

You wrote a Package.swift file but when running swift build, you get an error about missing targets. What is a likely cause?

medium📝 Debug Q14 of 15
Swift - Basics and Runtime
You wrote a Package.swift file but when running swift build, you get an error about missing targets. What is a likely cause?
AYou forgot to create the <code>Tests</code> folder.
BThe <code>targets</code> array in <code>Package.swift</code> is empty or missing the source target.
CYou ran <code>swift build</code> outside the package directory.
DThe Swift compiler is not installed.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the error about missing targets

    Missing targets usually mean the Package.swift file does not list the source targets properly in its targets array.
  2. Step 2: Check other options

    While running outside the directory or missing compiler causes other errors, the specific missing target error points to the manifest file's targets section.
  3. Final Answer:

    The targets array in Package.swift is empty or missing the source target. -> Option B
  4. Quick Check:

    Missing targets error = fix targets array in Package.swift [OK]
Quick Trick: Check targets array in Package.swift if build says missing targets. [OK]
Common Mistakes:
  • Ignoring the targets section in Package.swift
  • Assuming missing Tests folder causes target errors
  • Not verifying current directory before building

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes