หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
This article describes how to integrate iOS SDK v9.x into your Xcode project. For instructions on displaying different ad types, see iOS SDK ad units.
Requirements
- Your app must target iOS 15.0 or later.
- To request ads, use a valid placement ID. For supported ad units, you can instead use a valid member ID and inventory code.
Installation
Important
Swift Package Manager (SPM) is the primary and recommended method for integrating the iOS SDK. CocoaPods support will be discontinued in the next SDK release.
Choose an installation method:
| Method | Status |
|---|---|
| Swift Package Manager | Recommended |
| XCFramework | Manual integration |
| Carthage | Alternative integration |
| CocoaPods | Support ending |
Swift Package Manager
Open your project in Xcode.
Select the project in the Project navigator, and then select Package Dependencies.
Select the + button to add a package dependency.
Enter the following package URL in the search box, and then press Return:
https://github.com/appnexus/mobile-sdk-ios-spm
Choose the version setting that fits your project. For new projects, select Up to Next Major Version. Then select Add Package.
In the Choose Package Products for mobile-sdk-ios-spm window, select AppNexusSDK and your app target. Then select Add Package.
Verify that AppNexusSDK appears under Package Dependencies.
Alternative installation methods
Use these methods only when Swift Package Manager doesn't meet your project's requirements.
XCFramework
Download iOS SDK v9.14.0. The ZIP file contains the following frameworks and resource bundle. Use AppNexusSDK for a general integration.
| Framework | Description |
|---|---|
| AppNexusSDK | Supports all ad types. |
| AppNexusNativeSDK | This framework only supports native ads on iOS. |
| AppNexusNativeMacOSSDK | This framework only supports native ads on macOS. |
| ANSmartAdapter | A mediation adapter for Smart Ad Server. |
| ANGoogleAdapter | A mediation adapter for Google's AdMob. |
| ANFacebookCSRAdapter | A client side rendering adapter for Facebook Audience Network. |
| ANVungleAdapter | A mediation adapter for Vungle. |
| ANSDKResources.bundle | This contains necessary files which the SDK utilizes. |
Open the app’s Xcode project or workspace.
Go to the app target’s General configuration page.
To use the
AppNexusSDK, add theAppNexusSDK.xcframeworkandANSDKResources.bundle.To import the
AppNexusSDK.xcframework:- Navigate to your project's Target settings.
- Navigate to Target > General.
- Click the
+button under the Frameworks, Libraries, and Embedded Content section. - Click Add Other and then Add Files.
- Choose the
AppNexusSDK.xcframeworkfile and click Open.
To include the
ANSDKResources.bundle:- Navigate to Target > Build Phase.
- Expand the Copy Bundle Resources row and click the
+icon. - Choose the
ANSDKResources.bundlefile and click Open.
Carthage
If you are unfamiliar with Carthage, review the Carthage documentation. After installing Carthage, follow these steps:
Open Terminal and navigate to the root directory of your project. Create a Cartfile:
touch CartfileOpen the Cartfile in Xcode:
open -a Xcode CartfileAdd the following lines to the Cartfile:
binary "https://adsdkprod.azureedge.net/mobile/ios/releases/carthage/AppNexusSDK.json" binary "https://adsdkprod.azureedge.net/mobile/ios/releases/carthage/OMSDK_Microsoft.json"Tip
Use straight quotation marks in the Cartfile. Carthage doesn't recognize smart quotation marks inserted by some text editors.
Save the Cartfile, and then update the dependencies:
carthage update --use-xcframeworksAdd
AppNexusSDKDynamic.xcframeworkandOMSDK_AppNexus.xcframeworkto Target > General > Embedded Binaries.For an application target, select Embed & Sign. For other targets, select Do Not Embed.
CocoaPods
Warning
CocoaPods support will be discontinued in the next SDK release. Use Swift Package Manager for new integrations.
If you are unfamiliar with CocoaPods, review the CocoaPods documentation. After installing CocoaPods, follow these steps:
In Terminal, navigate to the root directory of your project and create a Podfile:
pod initOpen the Podfile, set the platform version to 15.0, and add
AppNexusSDKto the target:platform :ios, '15.0' project 'FunBanner' target 'FunBanner' do pod 'AppNexusSDK' endSave the Podfile, and then install the dependency:
pod installClose the open Xcode project, and then open the generated
.xcworkspacefile.