How to update swift package imported to Xcode Project via Swift Package Manager?
Option 1: (Xcode 13 and above)
Right-click on the package from the left navigation pan and select Update Package
Option 2:
Double click on the package in the tab you mentioned and change the version to anything else. It will then recheck the remote repo. The benefit of doing this is to only update the selected package. (Also, it's better to have the current using version be set in the package.)
Option 3:
From File -> Swift Packages -> Update to Latest Package Versions
How to use dependencies in a Swift Package
Found my answer.
In the target dependencies, need to include the package name as a string:
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "DBCore",
dependencies: [
"AgileDB"
]),
.testTarget(
name: "DBCoreTests",
dependencies: ["DBCore"]),
]
Add dependencies to binary targets in Swift Package Manager
I think the real issue here is that the dependencies don't need to be a part of your modules's public interface. You would need to replace all instances of import
for the dependencies in your code to @_implementationOnly import
E.g.
@_implementationOnly import CocoaLumberjack
You can read more about @_implementationOnly
here
Xcode: Using packages in Xcode 14
There is a change in the syntax for local packages, the .package(url: …
syntax that used to work for packages within the project does not work anymore.
With Xcode 14 local packages that do no have their own repo MUST be referred as:
dependencies: [
.package(path: "../MyLibrary"),
]
Now this works just fine in Xcode 14 beta, but if you're going back to the Xcode release version, you'll get numerous errors. To fix those, reset the package caches by calling
File > Packages > Reset Package Caches
I had the same issue in a project with 14 internal packages, some of them dependent on each other, and it runs fine now in both Xcode 13.4 and Xcode 14 beta.
Hope it helps
SPM dependencies branch is deprecated on Xcode 13.3 and Swift 5.6
It is necessary to set the dependency as a product.
Specifically with .product(name: [PackageName], package: [Name of repository])
, example:
// swift-tools-version:5.6
import PackageDescription
let package = Package(
name: "MyPackage",
platforms: [
.iOS(.v15)
],
products: [
.library(
name: "MyPackage",
targets: ["MyTarget"]),
],
dependencies: [
.package(
url: "https://github.com/someorg/somepackage.git",
branch: "main")
],
targets: [
.target(
name: "MyTarget",
dependencies: [
.product(
name: "MyDependency",
package: "somepackage")])
]
)
Related Topics
Swift: How to Fully Strip Internal/Inline Symbols
Variable Captured by Closure Before Being Initialized
How to Launch an External Process
Swift - Take Nil as Argument in Generic Function with Optional Argument
Check for Launching from Uilocalnotification in Swift
iOS 11 Black Bar Appears on Navigation Bar When Pushing View Controller
How to Initialise Cvpixelbufferref in Swift
Nsurlsession/Nsurlconnection Http Load Failed (Kcfstreamerrordomainssl, -9802)
Is There No Default(T) in Swift
Swift Combine Alternative to Rx Observable.Create
Get the Current Position of Scrollview in Swiftui
Accessing Self from Instance Properties Which Are Closures
How to Implement a Thread Safe Hashtable (Phonebook) Data Structure in Swift
Catch Objective-C Exception in Swift
How to Call Initializer for Subclass of Generic Type
Swiftui - How to Set the Title of a Navigationview to Large Title (Or Small)
Add Links to Swift Classes in the Quick Help Documentation Comments
Cancelling an Alamofire Request Wrapped in Nsoperation Causes Multiple Kvo