Castled SDK can be integrated into your iOS project using either CocoaPods or Swift Package Manager (SPM), two of the most popular dependency managers in the iOS ecosystem. Below, you’ll find step-by-step instructions for both methods.

Installation with CocoaPods

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. CocoaPods is built with Ruby and is installable with the default Ruby available on macOS.

Prerequisites

Before you begin, ensure you have CocoaPods installed on your system. If you haven’t, you can install it by running the following command in your terminal:

sudo gem install cocoapods

Installation Steps

  1. Navigate to your project directory in the terminal and run the following command to create a Podfile if you don’t already have one:
pod init
  1. Open your Podfile using a text editor and specify the CastledNotificationContent pod within your target:
target "YourTargetName" do
  use_frameworks!
  pod 'Castled'
end

Make sure to replace YourTargetName with the actual target name of your application.

  1. Save the Podfile and run the following command in the terminal to install the SDK:
pod init
  1. After the installation is complete, make sure to open the .xcworkspace file created by CocoaPods, as it includes all the necessary dependencies and configurations.

  2. Build your project to ensure the SDK is integrated properly.

With CocoaPods, you can easily manage updates to the Castled SDK. Simply run pod update in the terminal when a new version of the SDK is available.

Installation with Swift Package Manager (Xcode 11+)

Swift Package Manager (SwiftPM) is a tool for managing the distribution of Swift code as well as C-family dependency. From Xcode 11, SwiftPM got natively integrated with Xcode.

Integration via Xcode GUI

  1. Open your project in Xcode.

  2. Navigate to File > Add Packages…

  3. In the search field of the new window that appears, enter the following URL for the Castled SDK package repository:

https://github.com/castledio/castled-ios-sdk
  1. Select the version that you want to integrate into your project. It’s usually best to select the most recent version unless you have specific reasons for using an older one.

  2. Click Add Package to your project. Xcode will fetch the repository and integrate it into your project.

Once integrated, make sure to import the SDK module in your Swift files where you want to use it.

Integration via ‘Package.swift’

For package authors or those who prefer a more manual integration process, update your Package.swift file with the following dependencies entry:

Package.swift

let package = Package(
    name: "YourPackageName",
    // Define other package properties
    dependencies: [
        .package(url: "https://github.com/castledio/castled-ios-sdk", .upToNextMajor(from: "x.y.z"))
    ],
    // Define targets
)

Replace “x.y.z” with the version of Castled SDK being installed. After editing the Package.swift file, you can use swift build to fetch the dependency and compile your project.