swift-package-manager

Use resources in unit tests with Swift Package Manager

本小妞迷上赌 提交于 2019-12-03 06:45:23
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 import PackageDescription let package = Package( name: "MyProject", products: [ .library( name:

Getting 'no such module' error when importing a Swift Package Manager dependency

末鹿安然 提交于 2019-12-03 06:19:16
问题 I'm running Xcode 11 Beta 4. I'm using CocoaPods, and wanted to use one of my dependencies with Swift Package Manager as a static library instead of as a framework. On a fresh project created with Xcode 11, the dependency can be imported successfully, but on my existing CocoaPods workspace, it does not. I think it's likely related, but I'm also getting this link warning in Xcode: directory not found for option '-L/Users/username/Library/Developer/Xcode/DerivedData/App

Swift Package Manager - UIKit Dependency

爱⌒轻易说出口 提交于 2019-12-03 06:00:07
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? The Swift Package Manager builds executables to run on OS X (or Linux); UIKit is a framework in iOS and won't be accessible. It may be iOS, tvOS and others become accessible as Swift Package

How to Install Package in Xcode via Swift Package Manager

独自空忆成欢 提交于 2019-12-02 21:52:29
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 meaning of the build settings part of a project, or how Swift modules are used. EDIT: This question was

How to include assets / resources in a Swift Package Manager library?

为君一笑 提交于 2019-11-30 16:54:45
I would like to ship my library using Apple's Swift Package Manager. However my lib includes a .bundle file with several strings translated in different languages. Using cocoapods, I can include it using spec.resource. But in SwiftPM, I cannot do it. Any solution? The package manager does not yet have any definition for how resources will be bundled with targets. We are aware of the need for this, but don't yet have a concrete proposal for it. I filed https://bugs.swift.org/browse/SR-2866 to ensure we have a bug tracking this. Due to framework bundles not being supported yet , the only way to

Swift test give error “Undefined symbols for architecture x86_64”

£可爱£侵袭症+ 提交于 2019-11-30 11:21:28
问题 I'm running swift test from the command line to run the test cases. This is the test case: import XCTest @testable import vnk_swift class KeyMappingTests: XCTestCase { static var allTests : [(String, (KeyMappingTests) -> () throws -> Void)] { return [ // ("testExample", testExample), ] } func testExample() { let keyMapping = KeyMapping() XCTAssertNotNil(keyMapping , "PASS") } } And here is the output message. If I remove the usage of KeyMapping , everything works fine: func testExample() { //

Swift test give error “Undefined symbols for architecture x86_64”

↘锁芯ラ 提交于 2019-11-29 23:56:29
I'm running swift test from the command line to run the test cases. This is the test case: import XCTest @testable import vnk_swift class KeyMappingTests: XCTestCase { static var allTests : [(String, (KeyMappingTests) -> () throws -> Void)] { return [ // ("testExample", testExample), ] } func testExample() { let keyMapping = KeyMapping() XCTAssertNotNil(keyMapping , "PASS") } } And here is the output message. If I remove the usage of KeyMapping , everything works fine: func testExample() { // let keyMapping = KeyMapping() XCTAssertNotNil(true , "PASS") } Looks like there is a problem when I'm

Adding Swift 3 packages to Xcode 8 using the Swift package manager

試著忘記壹切 提交于 2019-11-29 21:00:46
I am new to Swift and Xcode. I am running macOS Sierra and Swift 3. For my first forays in Swift, I am developing a simple command line tool. There are a couple of Swift packages that I want to use and the installation instructions for both packages on GitHub says to use the Swift package manager by simply adding them as dependencies in the package manifest file. What I can't figure out is how to do this in Xcode. Do I just create a 'package.swift' file in the root of my project? Doing this and then running the project doesn't seem to work as the required packages don't seem to be added to my

Adding Swift 3 packages to Xcode 8 using the Swift package manager

我的未来我决定 提交于 2019-11-28 17:11:37
问题 I am new to Swift and Xcode. I am running macOS Sierra and Swift 3. For my first forays in Swift, I am developing a simple command line tool. There are a couple of Swift packages that I want to use and the installation instructions for both packages on GitHub says to use the Swift package manager by simply adding them as dependencies in the package manifest file. What I can't figure out is how to do this in Xcode. Do I just create a 'package.swift' file in the root of my project? Doing this

How to include assets / resources in a Swift Package Manager library?

不打扰是莪最后的温柔 提交于 2019-11-27 22:57:23
问题 I would like to ship my library using Apple's Swift Package Manager. However my lib includes a .bundle file with several strings translated in different languages. Using cocoapods, I can include it using spec.resource. But in SwiftPM, I cannot do it. Any solution? 回答1: The package manager does not yet have any definition for how resources will be bundled with targets. We are aware of the need for this, but don't yet have a concrete proposal for it. I filed https://bugs.swift.org/browse/SR