I am exploring the SPM, now I need to know how to import Alamofire via SPM in my project.
Asked
Active
Viewed 8,154 times
5
-
The Alamofire repository includes installation instructions: https://github.com/Alamofire/Alamofire#installation – Hodson Apr 11 '17 at 09:23
1 Answers
9
Create a .swift file named Package
in your project root folder and your dependencies inside like
import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
dependencies: [
.Package(url: "https://github.com/Alamofire/Alamofire.git", majorVersion: 4)
]
)
Than run swift build
command in your root folder directory

abdullahselek
- 7,893
- 3
- 50
- 40
-
1Hi abdullah, thank you for your response but still i got some issue //My package file import PackageDescription let package = Package( name: "SMPPOCProj", dependencies: [ .Package(url: "https://github.com/Alamofire/Alamofire.git", majorVersion: 4) ], exclude: ["Tests","SMPPOCProjTests","SMPPOCProjUITests"] ) – Vignesh Apr 11 '17 at 10:13
-
This is the issue **"Compile Swift Module 'SMPPOCProj' (2 sources) /Users/vt016/Desktop/temp/SMPPOCProj/SMPPOCProj/AppDelegate.swift:9:8: error: no such module 'UIKit' import UIKit ^ /Users/vt016/Desktop/temp/SMPPOCProj/SMPPOCProj/AppDelegate.swift:9:8: error: no such module 'UIKit' import UIKit ^
:0: error: build had 1 command failures"** – Vignesh Apr 11 '17 at 10:14 -
1I think you are trying to use it on your iOS project but for now it is not supported by Swift Package Manager. `Note that at this time the Package Manager has no support for iOS, watchOS, or tvOS platforms.` [Swift Package Manager](https://github.com/apple/swift-package-manager) Try using CocoaPods or Carthage if you want to use it with dependency management tool. – abdullahselek Apr 11 '17 at 10:19
-
Abdullah, I am trying to use it in iOS project. Thank you for helping me – Vignesh Apr 11 '17 at 10:24
-
you can use SPM to add frameworks to your project without any trouble. there is no support to build your iOS or MacOS application with SPM. i am using SPM for all my common C and Swift code in one xcode project, which targets Cli (osx), osx app, and ios app. Cli target is created with SPM, ios and osx app via xcode. to incorporate Alamofire via SPM to your ios project, you have to create executable (default Hello World) package and define it as dependent on Alamofire package. next generate xcode project and use the framework as usualy in your ios or osx app target. – user3441734 Jul 25 '17 at 20:19
-