swift-package-manager

When using Swift Package Manager how can I generate an Xcode project file for development

纵然是瞬间 提交于 2019-12-05 09:52:51
问题 I am using the new open source Swift Package Manager and am able to download the files. I want the manager to create a "development environment" (Through Xcode) based on the packages it retrieved. Has anybody dealt with this? 回答1: Update: as mentioned in other answers, you can now generate Xcode project files with this command: swift package generate-xcodeproj Original answer: The Swift Package Manger (SPM) is cross platform, It works on Mac and Linux. The Xcode is Mac OS only, so I don't

Swift package manager unable to compile ncurses installed through Homebrew

强颜欢笑 提交于 2019-12-05 03:35:07
I'm trying to use ncurses in a library using Swift Package Manager and I'd like to use a specific version of ncurses, not the one included in OS X. To do so I installed a more recent version (6.1) using Homebrew. This is how my Package.swift looks like: // swift-tools-version:5.0 import PackageDescription let package = Package( name: "NcursesExample", products: [ .executable(name: "NcursesExample", targets: ["NcursesExample"]), ], dependencies: [ ], targets: [ .systemLibrary(name: "Cncurses"), .target(name: "NcursesExample", dependencies: ["Cncurses"]), ] ) Under the Sources directory I have a

Set macOS target for `swift package generate-xcodeproj`?

青春壹個敷衍的年華 提交于 2019-12-05 02:38:58
Is there a way to set the macOS target for swift package generate-xcodeproj generates Xcode projects? For example, set default target to "x86_64-apple-macosx10.12". Background Currently, the Xcode 9.2 Swift toolchain shows the following versions on the command line: swift --version # Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2) # Target: x86_64-apple-macosx10.9 swift package --version # Apple Swift Package Manager - Swift 4.0.0-dev (swiftpm-13752) The result of swift package generate-xcodeproj is an Xcode project with a macOS target of 10.10. Note: the generated Xcode 10

How do I put a swift package in Edit Mode?

天涯浪子 提交于 2019-12-04 11:13:10
So I want to edit some files in a swift package in Xcode 11.0 beta (11M336w) on MacOS 10.15 Beta (19A471t). Let's take https://github.com/AndyQ/NFCPassportReader as an example. It has an example app which uses the repo from GitHub. Suppose I want to make some source code changes. How do I tell the system I want to edit the package? I tried " swift package edit NFCPassportReader " on the command line. If I run it from the example app's root folder I get " error: root manifest not found " If I run it from the root of the package I get " error: Could not find dependency 'NFCPassportReader' " What

Use resources in unit tests with Swift Package Manager

旧巷老猫 提交于 2019-12-04 09:24:15
问题 I'm trying to use a resource file in unit tests and access it with Bundle.path , but it returns nil. This call in MyProjectTests.swift returns nil: Bundle(for: type(of: self)).path(forResource: "TestAudio", ofType: "m4a") Here is my project hierarchy. I also tried moving TestAudio.m4a to a Resources folder: ├── Package.swift ├── Sources │ └── MyProject │ ├── ... └── Tests └── MyProjectTests ├── MyProjectTests.swift └── TestAudio.m4a Here is my package description: // swift-tools-version:4.0

When using Swift Package Manager how can I generate an Xcode project file for development

别说谁变了你拦得住时间么 提交于 2019-12-03 22:29:48
I am using the new open source Swift Package Manager and am able to download the files. I want the manager to create a "development environment" (Through Xcode) based on the packages it retrieved. Has anybody dealt with this? Kostiantyn Koval Update: as mentioned in other answers, you can now generate Xcode project files with this command: swift package generate-xcodeproj Original answer: The Swift Package Manger (SPM) is cross platform, It works on Mac and Linux. The Xcode is Mac OS only, so I don't think SPM will be hard integrate to work with Xcode. SPM can do 2 things: Build swift source

Swift Package Manager - UIKit Dependency

孤者浪人 提交于 2019-12-03 15:24:17
问题 I have a Package.swift in my project like: import PackageDescription let package = Package( name: "ProjectName", dependencies: [ .Package(url: "https://github.com/intellum/neeman.git", majorVersion: 0) ] ) When I run swift build I get errors like… /project/Packages/WebViewController.swift:1:8: error: no such module 'UIKit' import UIKit ^ Where should I tell the swift package manager where to find UIKit? 回答1: The Swift Package Manager builds executables to run on OS X (or Linux); UIKit is a

Swift Package Manager - Swift 4 syntax

我与影子孤独终老i 提交于 2019-12-03 11:12:08
I'm trying to use updated SPM for Swift4 with the following Package.swift file - PackageDescription API Version 4 import PackageDescription let package = Package( name: "Name", dependencies : [ .package(url: "url", .branch("swift4")) ], exclude: ["Tests"] ) I have a correct version of SPM also: Apple Swift Package Manager - Swift 4.0.0-dev (swiftpm-13081.9) But I can not build the library by swift build command. I see the following error: ... error: type 'Version' has no member 'branch' You're missing the tools version specifier in your manifest; add the following as the first line of your

How to Install Package in Xcode via Swift Package Manager

别来无恙 提交于 2019-12-03 08:14:12
问题 I'm working on a project in Xcode and am attempting to install and use the CryptoSwift package via the Swift Package Manager. I read the documentation on SPM, but I don't see instructions on how to invoke the SPM through Xcode. The examples often refer to calling $ swift build . Does this mean that the SPM is only accessible from the command line? And if so, where exactly am I supposed to create the Package.swift file? I'm reasonably familiar with Xcode, but I don't really understand the

What is import func, struct, class, and @_exported in Swift?

ε祈祈猫儿з 提交于 2019-12-03 06:53:45
In Apple's github for the Swift Package manager they use import func POSIX.isatty import func libc.strerror_r import var libc.EINVAL import var libc.ERANGE import struct PackageModel.Manifest source There is also a file where the only code in it is @_exported source @_exported import func libc.fileno Is this a Swift 3 feature? I can not find anywhere that you can import a type in the Swift documentation and nothing on @_exported . You can import only a specific part of a module, not a whole module: Providing more detail limits which symbols are imported—you can specify a specific submodule or