Frederick C. Lee
Frederick C. Lee

Reputation: 9493

Swift Package Dependency: "No Such Module..." - Why?

Goal: To learn how to add an import to a Swift package.
Modus Operandi: Use an Apple-supplied Example as base. Add another import (i.e., Alamofire)
Result: Alamofire does import; but its module "can't be found".

The Package:

enter image description here

The Sources:

enter image description here

Question: Why is this happening?
What am I missing?

Upvotes: 4

Views: 1344

Answers (2)

Soorej Babu
Soorej Babu

Reputation: 368

Inside the .target section in your targets section in package.swift file, add your dependencies as like array objects 👇🏻

.target(
        name: "DeckOfPlayingCards",
        dependencies: ["PlayingCard", "Alamofire"]),

This solved my problem. I was also having the same issue showing No such module "Alamofire". Not only Alamofire but also every other. I forgot to put my dependencies there.

I hope this will help someone sometime.

Upvotes: 0

king wang
king wang

Reputation: 568

Check the target DeckOfPlayingCards, select the General tab, check Framework, Libraries, and Embedded Contents, make sure Alamofire is on the list

Upvotes: 5

Related Questions