Installation
Follow these steps to add the Magify Swift SDK to your project.
Requirements
Before installing the SDK, make sure your environment meets the following requirements:
- iOS 15.0 or later
- Xcode 15 or later
- Swift 5.9 or later
Downloading Magify SDK
Download the latest SDK package from the Releases page.
After extracting the archive, you should see the SDK folder that contains the Swift package files.
Adding the package
Open your Xcode project and launch Swift Package Manager.
- In the menu bar, select File → Add Packages...
magify-sdk-ios-swift-add-local - Click Add Local...
magify-sdk-ios-swift-add-package - Select the unzipped SDK folder.
- Click Add Package.
Wait until Xcode resolves the package and installs it into your project.
Adding package to the target
After the package is resolved, select the Magify library and your application target, then click Add Package.
magify-sdk-ios-swift-add-package-target
Adding the configuration file
The SDK requires a Magify-Config.json configuration file generated in the Magify Dashboard.
Download the configuration file and add it to your Xcode project.
Make sure the file is included in your application target.
magify-sdk-ios-swift-finish
SDK initialization
Create a shared MagifyClient instance and initialize the SDK during application launch.
import UIKit
import Magify
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
lazy var magify: MagifyClient = {
let configURL = Bundle.main.url(
forResource: "Magify-Config",
withExtension: "json"
)!
let magify = MagifyClient(
for: "MyApplication",
defaultConfigURL: configURL,
isSandbox: false
)
return magify
}()
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
magify.setup()
return true
}
}
Dummy configuration example
If you need a temporary configuration file for local testing, you can use the following example:
{
"limits": {
"impression_per_session_limit": null,
"interstitials_per_session_limit": null,
"sessions_interval": null,
"global_interval": null,
"interstitial_interval": null,
"required_campaign_types": []
},
"native_elements": [],
"campaigns": [],
"features": {},
"content": {}
}
Next step
Now that the SDK is installed, you can proceed to the Configuration section to customize the SDK behavior for your application.