Getting Started - adform/adform-ios-sdk GitHub Wiki

Getting Started

Important iOS 14 support

Apple introduced a new AppTrackingTransparency framework and tracking permission in iOS 14. To support these changes you will need to make a couple of small changes in Adform Tracking SDK integration.

  1. Ask the user for permission to access the Advertising Identifier using requestTrackingPermissions method. Calling this method will present a systemic permissions alert, therefore it's up to you to decide when it is most appropriate to show it.

Swift

if #available(iOS 14.0, *) {
    AdformSDK.requestTrackingPermissions(nil)
}
Objective-C
if (@available(iOS 14.0, *)) {
    [AdformSDK requestTrackingPermissions:nil];
}
  1. Add NSUserTrackingUsageDescription entry to your apps Info.plist file.

App Transport Security

Adform Advertising SDK is fully compatible with Apple security requirements and supports ATS, so no additional changes required for that.

Query schemes

In iOS 9 you must whitelist any URL schemes that your App wants to query. Our sdk uses "sms" and "tel" URL schemes to determine if device can send sms and make phone calls. Therefore, to avoid possible problems on IOS9 we recommend you to add "sms" and "tel" schemes to the white-list. To do so, developers should add the following to their plist:

    <key>LSApplicationQueriesSchemes</key>  
    <array>  
         <string>sms</string>  
         <string>tel</string>  
    </array>  

1. General Info

The use of Adform SDK requires the following:

  • Xcode 14.0 or later.
  • Requires deployment target 9.0 or later

SDK is Automatic Reference Counting (ARC) compliant.

2. How to import Adform Advertising SDK to your iOS project?

2.1. Using Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

You can add Adform Advertising SDK as a dependency to your project through Xcode UI or add it to your project's Package.swift file like this:

dependencies: [
    .package(url: "https://github.com/adform/adform-ios-sdk", .upToNextMajor(from: "2.19.0"))
]

Important! Xcode 12 has a bug where static frameworks distributed through SPM sometimes get embedded incorrectly into the app. This issue is mentioned in Xcode 12.4 release notes. If the validation of your archived app fails you may need to use a workaround that strips the embedded frameworks after the build. You can use this build phase script to remove embedded frameworks from the app:

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

rm -rf "${APP_PATH}/Frameworks/AdformAdvertising.framework"
rm -rf "${APP_PATH}/Plugins/AdformAdvertising.framework"

2.2. Using CocoaPods

Adform Advertising SDK is available via CocoaPods. To integrate SDK using CocoaPods, you need to edit Podfile and specify the AdformAdvertising pod.

pod 'AdformAdvertising', '~> 2.19.0'

For more information about CocoaPods visit CocoaPods site.

2.3. Using Carthage

Adform Advertising SDK is available via Carthage.

  • To integrate SDK using Carthage, you need to specify it in Cartfile.
binary "https://raw.githubusercontent.com/adform/adform-ios-sdk/master/AdformAdvertising.json" ~> 2.19.0
  • Adform Advertising SDK is distributed as a static framework. Therefore, you should not add it as input/output files in Carthage copy-frameworks Build Phase.

For more information about Carthage visit Carthage site.

2.4. Manually

  • Download the latest build version of Adform Advertising SDK.
  • Drag AdformAdvertising.xcframework to your project.

alt tag

  • When asked select Copy items into destination group's folder.

alt tag

  • Then select AdformAdvertising.xcframework in the project navigator, go to file inspector, and add it to your application's target (Target Membership).

  • Finally import AdformAdvertising and you are ready to use Adform mobile banners:

Swift

import AdformAdvertising
Objective-C
@import AdformAdvertising;

2.4. Troubleshooting

  • First of all, try enabling Debug mode to see additional SDK logs in the console. You can find instructions how to do so here.

  • If you get a missing symbols error, it may mean that automatic framework linking has failed, in this case try to add these dependencies explicitly to your project:

    • UIKit.framework;
    • CoreGraphics.framework;
    • QuartzCore.framework;
    • SystemConfiguration.framework;
    • MediaPlayer.framework;
    • AdSupport.framework;
    • CoreTelephony.framework;
    • CoreLocation.framework;
    • CoreMedia.framework;
    • AVFoundation.framework;
    • SafariServices.framework;
    • WebKit.framework;
    • AppTrackingTransparency.framework;
  • If you get a bundle format unrecognized, invalid, or unsuitable error while integrating the SDK, it probably means one of two problems:

    • That you are integrating SDK with Carthage and have added AdformAdvertising.framework to input/output files in Carthage copy-frameworks Build Phase. You should not add this framework to copy-frameworks Build Phase.
    • You have selected Embed in Framework and Libraries project configuration. This configuration should be selected to Do Not Embed.

To start coding check basic AdInline integration guide.

⚠️ **GitHub.com Fallback** ⚠️