0
0
Swiftprogramming~10 mins

Project structure and Swift Package Manager basics - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Apackage
BMyLibrary
C"MyLibrary"
DpackageName
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the package name in quotes.
Using a variable name instead of a string.
2fill in blank
medium

Complete 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'
A6.0
B4.2
C5.0
D5.7
Attempts:
3 left
💡 Hint
Common Mistakes
Using an outdated Swift tools version.
Using a version number without the correct format.
3fill in blank
hard

Fix 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'
A1.0.0
B"1.0.0"
C"from: 1.0.0"
Dfrom: "1.0.0"
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out quotes around the version number.
Adding extra labels inside the version string.
4fill in blank
hard

Fill 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'
A"Collections"
B"SwiftCollections"
C"swift-collections"
D"CollectionsPackage"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the URL or package name instead of the target name.
Using incorrect capitalization.
5fill in blank
hard

Fill 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'
A"MyLibrary"
B"MyLib"
D"MyLibraryTarget"
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching product and target names.
Forgetting quotes around names.