Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare the package name in Package.swift.
Swift
let package = Package(name: [1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the package name in quotes.
Using a variable name instead of a string.
✗ Incorrect
The package name must be a string literal, so it needs quotes.
2fill in blank
mediumComplete the code to specify the Swift tools version at the top of Package.swift.
Swift
// swift-tools-version:[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an outdated Swift tools version.
Using a version number without the correct format.
✗ Incorrect
The current recommended Swift tools version is 5.7 for modern packages.
3fill in blank
hardFix the error in the dependencies array by completing the code.
Swift
dependencies: [
.package(url: "https://github.com/apple/swift-collections.git", from: [1])
], Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out quotes around the version number.
Adding extra labels inside the version string.
✗ Incorrect
The version must be a string literal inside quotes.
4fill in blank
hardFill in the blank to define a target with a dependency on the swift-collections package.
Swift
targets: [
.target(
name: "MyLibrary",
dependencies: [.product(name: [1], package: "swift-collections")]
)
], Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the URL or package name instead of the target name.
Using incorrect capitalization.
✗ Incorrect
The dependency name is "Collections" as defined by the swift-collections package.
5fill in blank
hardFill both blanks to create a library product named MyLibrary with the target MyLibrary.
Swift
products: [
.library(
name: [1],
targets: [[2]]
)
], Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching product and target names.
Forgetting quotes around names.
✗ Incorrect
The product name and target name must match exactly and be string literals.