Bird
0
0

How can you specify a dependency on an external package hosted on GitHub in your Package.swift?

hard📝 Application Q9 of 15
Swift - Basics and Runtime
How can you specify a dependency on an external package hosted on GitHub in your Package.swift?
AAdd the URL as a comment in Package.swift
BDownload manually and place in Sources folder
CAdd it in dependencies with .package(url: "https://github.com/user/repo.git", from: "1.0.0")
DInclude the URL in the Tests folder
Step-by-Step Solution
Solution:
  1. Step 1: Recall how to add external dependencies

    Use the dependencies array with .package(url:from:) syntax.
  2. Step 2: Reject incorrect methods

    Manual download or comments do not link dependencies; Tests folder is unrelated.
  3. Final Answer:

    Add it in dependencies with .package(url: "https://github.com/user/repo.git", from: "1.0.0") -> Option C
  4. Quick Check:

    External package = .package(url:from:) in dependencies [OK]
Quick Trick: Use .package(url:from:) to add GitHub dependencies [OK]
Common Mistakes:
  • Manually copying code
  • Adding URL as comment
  • Placing URL in Tests folder

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes