Questions tagged [swift-package]
103 questions
11
votes
2 answers
Swift Package Manager could not be resolved all libraries, project
This error always happens whenever I add a new Package via Swift Package Manager in Xcode:
Cannot fetch library
I've already configured my GitHub Auth Token setting in Xcode and registered my GitHub account.
My macOS version is Monterey 12.1, my…

iostaeha
- 127
- 1
- 4
10
votes
2 answers
How do I show code coverage in Swift Packages?
On my M1 mac, using Xcode 13.3, I created a package and displayed the code coverage bar (Editor menu –> Code Coverage).
After running tests, there is no indication of code coverage at all in the source code.
How do I get code coverage when testing a…

Aaron Bratcher
- 6,051
- 2
- 39
- 70
8
votes
2 answers
Link to fat Static Library inside Swift Package
I’m trying to build a Swift Package that wraps a fat static library written in C: libndi_advanced_ios.a from NewTek's Apple Advanced NDI SDK.
I am having trouble linking the pre-compiled library (only headers files and .a binary package is…

alessionossa
- 923
- 2
- 15
- 41
8
votes
1 answer
Editing a Package Dependency as a Local Package
Overview
I have a project that uses a remote swift package.
I would like to edit this package in the same project so that I can refine it based on the usage.
Aim:
To do this I am trying to add the same package as a local package so that I can…

user1046037
- 16,755
- 12
- 92
- 138
8
votes
2 answers
Incomplete file/copyright headers in Swift Package with Xcode 12 / 13
Is there any way to automatically add package/target name and copyright + company name to the header when creating new files while developing a swift package with Xcode 12/13?
Just create a new package (File > New > Package) and add a new file to…

neatchuck
- 731
- 4
- 14
7
votes
1 answer
Why Doesn't Swift Package Manager Ask For A Filename?
In a regular Xcode project app, when I create a new file, it will offer me a template (eg. SwiftUI/Swift/Storyboard) to choose from. I choose a template, click on next, and the prompt will allow me to input the filename. After that, Xcode…

Richard Witherspoon
- 4,082
- 3
- 17
- 33
6
votes
1 answer
Swift Package Manifest - What is the difference between library targets and target dependencies?
In Package.swift, what is the difference between adding a target the array of targets within a library versus adding a target to the array of dependencies.
In this first example, 'Helpers' is added as a dependency to the 'MySwiftPackage' target.
let…

Nobadi
- 121
- 2
- 13
5
votes
0 answers
Swift Package Manager: two similar targets different only with the dependencies
I'm migrating a library built and tested as an Xcode Project to Swift Package Manager. The project contains 3 targets: the library itself, the same library but with different dependency and the test (application) target.
So far, porting the library…

Richard Topchii
- 7,075
- 8
- 48
- 115
5
votes
2 answers
How to use other swift packages in an own swift package?
I'm currently developing a Swift Package in which I would like to use other Swift Packages. To do so I added the packages I want to use to the dependencies in my Package.swift
dependencies: [
// Dependencies declare other packages that this…

Tim Langner
- 357
- 3
- 16
5
votes
1 answer
No such module in a Swift Package using Xcode - package listed in dependencies
I create a blank template package:
> swift package init --name Temp
> open Package.swift
Xcode Version 13.2.1 (13C100) opens the package.
I add a dependency to the package.
dependencies: [
.package(url:…

bshirley
- 8,217
- 1
- 37
- 43
5
votes
1 answer
Swift Package - How to exclude files in root git directory from the actual Swift Package?
I am creating a Swift Package that is essentially a wrapper for multiple XCFrameworks generated from Objective-C frameworks so they can be installed via SPM.
Everything works fine as far as creating the SP and ability to add it as a dependency to an…

JimmyJammed
- 9,598
- 19
- 79
- 146
4
votes
1 answer
Xcode won't display README when viewing a Swift Package
I converted an iOS framework project to a Swift Package.
Everything went smoothly and I can find and add the package to other projects. But Xcode won't display the README for the project. It only displays, "Unable to load the Read Me."
I've stripped…

Eric Crichlow
- 116
- 7
4
votes
0 answers
@_exported import but in Objective-C
Swift has an interesting keyword, which can be declared in the ModuleA:
@_exported import Foundation
Then, when in some other module (e.g. ModuleB) I import the ModuleA:
import ModuleA
let currentDate = Date() // using a Foundation struct
... I'm…

Richard Topchii
- 7,075
- 8
- 48
- 115
4
votes
4 answers
Xcode build reports "no such module" for Swift Package Manager packages. Building again and again eventually fixes it
I get "no such module" errors when trying to build after doing a "Clean Build Folder". Repeatedly trying to build eventually results in no errors.
IMPORTANT: The modules that can not be found are local packages with Swift Package Manager, i.e. not…

TJez
- 1,969
- 2
- 19
- 24
4
votes
0 answers
Swift Package Manager Public Headers with Complicated Layouts
I have a sample Swift Package Manager package (let's call it TestPackage), that is structured in the following way:
TestPackage/
Sources/
TestPackage/
Services/
Services.h
Services.m
TestPackageUI/
…

B. Morfe
- 61
- 4