swift-package-manager

How to build optimized version of Swift Package using the Swift Package Manager `swift build` command

风格不统一 提交于 2019-12-11 07:08:19
问题 I want to compile my swift code written in the new Swift Package Manager format into highly optimized binary code. This is possible currently using swiftc -O somefile.swift But since the swift packages are built using swift build command, I cannot pass -O option as it does not accept it. So is there a way to specify to optimize the code during the compile process? 回答1: You can build in a release configuration with: swift build --configuration release . You can also see the tool usage via: $

Swift package manager conditional compile not respecting flags

隐身守侯 提交于 2019-12-11 02:14:42
问题 I have a Package.swift file with the following structure var package = Package( name: "MyProject", targets: [ Target(name: "MyProject") ], dependencies: [], exclude: ["Exclude"] ) #if DEBUG package.dependencies.append(Package.Dependency.Package(url: "Dependency-One.git", majorVersion: 0, minor: 0)) #else package.dependencies.append(Package.Dependency.Package(url: "Dependency-Two.git", majorVersion: 0, minor: 0)) #endif When I build this with any of the following: swift build swift build -c

How to build a custom Swift framework and how is it related to the SPM?

[亡魂溺海] 提交于 2019-12-10 17:29:21
问题 I am currently building code that I would really like to use as a framework by being able to import MyCustomFramework as I would with Apple frameworks (in the future I would also like to distribute them). I have some questions about that : What is the easiest way to build a framework as what I want? Is this possible to do it directly in Xcode or do I need to use command line tools in the Terminal? Will this framework be compatible with multiple platforms (I am thinking about all Apple

Swift Package Manager and Xcode: Retaining Xcode Settings?

落爺英雄遲暮 提交于 2019-12-10 16:48:43
问题 I am developing a server in Swift and using the Swift Package Manager. And find it convenient when doing my development on my Mac OS system to generate a Xcode project to use Xcode as my IDE (i.e., From time to time, my package dependencies have to be updated. I've been using swift package generate-xcodeproj to do this. My problem comes in at this point-- I have created some settings in Xcode. E.g., I've set a DEBUG flag, and I have a .plist file that is in the Copy Files Phase. These get

Save packages downloaded by SPM into project GIT using Xcode 11

房东的猫 提交于 2019-12-10 09:41:09
问题 I started using new Xcode 11 which integrates SPM. I added first dependency to my project: but detected that files are not fetched into my project folder but into Xcode's cache: I would like to commit all my dependencies files into my main project repository so my question is: Is it possible to change location of fetched packages via SPM using Xcode 11? 回答1: SwiftPM integration has been setup to prevent this. It clones the files into a DerivedData/ProjectName-[RandomStuff]. You should commit

Cleanly handling /usr/local/ with Swift package manager and libevent

安稳与你 提交于 2019-12-08 06:23:56
问题 I have 2 dependencies in my project libevent and libressl . Both of which are installed locally ( respectively under /usr/local/include and /usr/local/opt/libressl/include ) What I am looking for to achieve is for SPM to automatically understand to search in those directories. I know I can pass flags to swift build to achieve this; but my ultimate goal is that I can properly generate xcode projects from the command line without having to constantly add custom build flags in Xcode. I'm pretty

Xcode: missing required module error

大兔子大兔子 提交于 2019-12-08 02:34:06
问题 I have looked at answers to similar problems and I'm still confused. Background I had a project working, but I'm trying to recreate it in Xcode 8.3.1. I start by using the Swift Package Manager with one dependency: [.Package(url: "https://github.com/OpenKitten/MongoKitten.git", majorVersion: 3)]. I then follow my notes to convert from Cocoa to iOS (because SPM doesn't directly support iOS) that worked in previous project starts: Make starting Package.swift file swift package generate

Swift package manager unable to compile ncurses installed through Homebrew

最后都变了- 提交于 2019-12-06 23:43: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")

Cleanly handling /usr/local/ with Swift package manager and libevent

拈花ヽ惹草 提交于 2019-12-06 16:46:09
I have 2 dependencies in my project libevent and libressl . Both of which are installed locally ( respectively under /usr/local/include and /usr/local/opt/libressl/include ) What I am looking for to achieve is for SPM to automatically understand to search in those directories. I know I can pass flags to swift build to achieve this; but my ultimate goal is that I can properly generate xcode projects from the command line without having to constantly add custom build flags in Xcode. I'm pretty sure it is possible, since I do not have to enter the custom settings for PostgreSQL. Swift-tools

How do I put a swift package in Edit Mode?

我与影子孤独终老i 提交于 2019-12-06 04:59:06
问题 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