简体   繁体   English

在Xcode中使用Swift Package Manager

[英]Using Swift Package Manager with Xcode

I am trying to use the following library in my XCode project 我试图在我的XCode项目中使用以下库

https://github.com/czechboy0/Socks https://github.com/czechboy0/Socks

It says to use the Swift Package Manager to use the library however I am not sure where I am supposed to put this line??? 它说使用Swift包管理器来使用库但是我不知道我应该把这行放在哪里???

.Package(url: "https://github.com/czechboy0/Socks.git", majorVersion: 0, minor: 10)

I am running mac OS 10.12 Sierra with XCode 8 beta. 我正在使用XCode 8 beta运行mac OS 10.12 Sierra。

I believe that the Swift Package Manager is supposed to come with Swift 3 and Swift 3 is supposed to be part of XCode 8 beta however I am at a loss as to how to actually use the package manager in swift. 我相信Swift Package Manager应该配备Swift 3,而Swift 3应该是XCode 8 beta的一部分,但我对如何在swift中实际使用包管理器感到茫然。 Any help would be greatly appreciated. 任何帮助将不胜感激。 I am rather new to iOS development and this issue is frustrating ... 我对iOS开发很新,这个问题令人沮丧......

If you need me to provide any additional info please ask :) 如果您需要我提供任何其他信息,请询问:)

The easiest way to use the Swift Package Manager with Xcode, assuming you have Xcode 8.0+ installed is to use the following command in the project root directory: 假设安装了Xcode 8.0+,将Swift Package Manager与Xcode一起使用的最简单方法是在项目根目录中使用以下命令:

swift package generate-xcodeproj

This will create a new Xcode Project with Sources and Dependencies imported into the project. 这将创建一个新的Xcode项目,其中包含导入项目的SourcesDependencies

Swift Package Manager is a tool for managing the distribution of Swift code. Swift Package Manager是一个管理Swift代码分发的工具。 It's integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. 它与Swift构建系统集成,以自动化下载,编译和链接依赖项的过程。 :swift.org says :swift.org说

To use Socks must be added to Package.swift manifest file. 要使用Socks必须添加到Package.swift清单文件中。

This is how your manifest file should look like 这就是清单文件的样子

import PackageDescription

    let package = Package(
        name: "DeckOfPlayingCards",
        targets: [],
        dependencies: [
            .Package(url: "https://github.com/czechboy0/Socks.git", majorVersion: 0, minor: 10)
        ]
    )

When swift build command runs it will downloads all dependencies like Carthage or Cocoapodes do. swift build命令运行时,它将下载所有依赖项,如Carthage或Cocoapodes。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Xcode 8上使用Swift3软件包管理器没有运气 - Using Swift3 Package Manager with Xcode 8 with no luck Xcode:Swift Package Manager 中的自定义构建配置 - Xcode: Custom build configurations in Swift Package Manager 在现有的 xcode 项目上使用 swift 包管理器 - Use swift package manager on existing xcode project 代理后面的 XCode Swift 包管理器错误 - XCode Swift package manager error behind proxy 没有这样的模块 'Firebase' - Xcode 和 Swift Package 经理 - No such module 'Firebase' - Xcode and Swift Package Manager 将 Swift Package Manager (SPM) 用于现有的 [iPhone App] XCode 项目(拥有 Swift + Objective C 文件) - Using Swift Package Manager (SPM) for Existing [iPhone App] XCode Project (Having Swift + Objective C Files) 使用 Swift Package Manager 时图像未显示在 SwiftUI 预览中 - 在 Xcode 项目中工作正常 - Image not showing in SwiftUI preview when using Swift Package Manager - works fine in Xcode project 在 Xcode 项目中使用 Swift Package 管理器添加依赖项时生成错误 - Build error when adding a dependency using Swift Package Manager in Xcode for a Flutter project 如何在 xcode 13 中添加 Swift package 管理器作为动态库? - How to add a Swift package manager as a dynamic library in xcode 13? Xcode 11 Swift软件包管理器无法解析软件包 - Xcode 11 swift package manager unable resolve packages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM