作者:虎爷在江湖 | 来源:互联网 | 2023-10-17 14:10
imnewtotheswiftandxcodeworld,soimhavingaproblemtryingtointegrateapackagetomypro
im new to the swift and xcode world, so i'm having a problem trying to integrate a package to my project.
我是swift和xcode世界的新手,所以我在尝试将软件包集成到我的项目时遇到了问题。
I want to add Alamofire dependency, with the following commands:
我想使用以下命令添加Alamofire依赖项:
Inside my root project folder:
在我的根项目文件夹中:
swift init
this creates the Package.swift file, i add the dependency inside, run then:
这会创建Package.swift文件,我在里面添加依赖项,然后运行:
swift build
Everything seems to be ok, but im my project when i try to import my library:
一切似乎都没问题,但是当我尝试导入我的库时,我的项目是:
import Alamofire
I get an error, it says that the module is not recognized. So my question here is, what is the correct steps to integrate Package Manager and a dependency on a existing project without crashing everything.
我收到错误,它说模块无法识别。所以我的问题是,在没有崩溃的情况下,将Package Manager和依赖项集成到现有项目的正确步骤是什么。
UPDATE:
更新:
swift build
outputs:
输出:
Resolved version: 4.3.0
Compile Swift Module 'Alamofire' (17 sources)
Compile Swift Module 'Sample' (1 sources)
And my Package.swift is:
我的Package.swift是:
import PackageDescription
let package = Package(
name: "Sample",
dependencies: [
.Package(url: "https://github.com/Alamofire/Alamofire.git", majorVersion: 4)
]
)
1 个解决方案