These instructions assume you already have a project in mind that you'd like to add DiscordKit to. If not, follow Creating a bot using an Xcode Project first for step-by-step instructions for creating a new project.
Swift Package Manager
Currently, the only supported method of adding DiscordKit to your project is through Swift Package Manager (SPM).
I've done this sort of thing before
Package URL:
https://github.com/SwiftcordApp/DiscordKit
Branch:
main
Product:
Step-by-step instructions (Non-Xcode)
Open the Package.swift file in the text editor of your choice. It should look something like this:
// swift-tools-version: 5.8// The swift-tools-version declares the minimum version of Swift required to build this package.importPackageDescriptionletpackage=Package( name:"MyWonderfulBot", targets: [// Targets are the basic building blocks of a package, defining a module or a test suite.// Targets can depend on other targets in this package and products from dependencies. .executableTarget( name:"MyWonderfulBot", path:"Sources"), ])
Under the first name property, add the following lines:
By now, your file should look something like this:
// swift-tools-version: 5.8// The swift-tools-version declares the minimum version of Swift required to build this package.importPackageDescriptionletpackage=Package( name:"MyWonderfulBot", dependencies: [ .package(url:"https://github.com/SwiftcordApp/DiscordKit", branch:"main") ], targets: [// Targets are the basic building blocks of a package, defining a module or a test suite.// Targets can depend on other targets in this package and products from dependencies. .executableTarget( name:"MyWonderfulBot", dependencies: [ .product(name:"DiscordKitBot", package:"DiscordKit") ], path:"Sources"), ])
Save the file, then in a terminal run swift package resolve. If the command finished with no errors, then DiscordKit was installed correctly!
Step-by-step instructions (Xcode)
With the project that you'd like to add DiscordKit to open in Xcode, click on File > Add Packages... in the menu bar
In the dialog that appears, paste https://github.com/SwiftcordApp/DiscordKit in the text field at the top right corner
Give Xcode a moment to look up the package, and set the Dependency Rule to the main branch as shown in the image below
Hit the Add Package button ensure the DiscordKitBot package product is checked. Then, press the Add Package button once again.
If you've followed these steps successfully, you've just added DiscordKit for bots to your project!