### BannerAdViewDelegate Required Methods Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/07_ad_delegates.md Implement all methods for BannerAdViewDelegate to manage banner ad loading, failures, clicks, and impression tracking. Refer to Step 6 for initial setup. ```swift func bannerAdViewDidLoad(_ bannerAdView: BannerAdView) func bannerAdViewDidFailLoading(_ bannerAdView: BannerAdView, error: any Error) func bannerAdViewDidClick(_ bannerAdView: BannerAdView) func bannerAdView(_ bannerAdView: BannerAdView, didTrackImpression impressionData: ImpressionData?) ``` -------------------------------- ### Setup Video Playback Controls for Native Ads Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/changelog/YandexMobileAds.md Use this method to override mute and progress controls for video playback in native ads. It's available on the `NativeVideoPlaybackControls` class. ```swift func setupVideoPlaybackControls(to view: YMANativeMediaView) ``` -------------------------------- ### Install/Update CocoaPods Dependencies Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/02_dependencies.md After updating the Podfile, run this command to install or update your project's dependencies, including the Yandex Mobile Ads SDK. ```bash pod install --repo-update ``` -------------------------------- ### Update Native Ad Object Properties (SDK 7 vs SDK 8) Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/08_native.md Use these code examples to update how you access native ad properties when migrating from SDK 7 to SDK 8. SDK 8 consolidates information under `adInfo` and uses `creatives` for creative-specific data. ```swift // SDK 7 let attributes = nativeAd.adAttributes let info = nativeAd.info ``` ```swift // SDK 8 let creatives = nativeAd.adInfo.creatives let extraData = nativeAd.adInfo.extraData ``` -------------------------------- ### SDK 8 AdRequest Initialization Error Example Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/04_adrequest.md Demonstrates a compilation error in SDK 8 when attempting to assign properties to an immutable AdRequest after initialization. All properties must be passed to the initializer. ```swift // SDK 8 — will NOT compile let request = AdRequest(adUnitID: "R-M-XXXXX-YY") request.parameters = ["key": "value"] // ERROR: 'parameters' is a 'let' constant // SDK 8 — correct let request = AdRequest(adUnitID: "R-M-XXXXX-YY", parameters: ["key": "value"]) ``` -------------------------------- ### Migrate Banner Ad Initialization and Loading Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/06_banner.md Compares the initialization and ad loading process for banner ads between SDK 7 and SDK 8. SDK 8 requires passing `adUnitID` within an `AdRequest` object. ```swift // SDK 7 let adView = AdView(adUnitID: "R-M-XXXXX-YY", adSize: adSize) adView.delegate = self adView.loadAd() // SDK 8 let bannerAdView = BannerAdView(adSize: adSize) bannerAdView.delegate = self let request = AdRequest(adUnitID: "R-M-XXXXX-YY") bannerAdView.loadAd(with: request) ``` -------------------------------- ### Rename BannerAdSize Factory Methods Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/03_mechanical_renames.md The factory methods for creating `BannerAdSize` have been renamed for brevity. For example, `fixedSize(withWidth:)` is now `fixed(width:)`. ```swift BannerAdSize.fixedSize(withWidth:…) ``` ```swift BannerAdSize.fixed(width:…) ``` ```swift BannerAdSize.inlineSize(withWidth:…) ``` ```swift BannerAdSize.inline(width:…) ``` ```swift BannerAdSize.stickySize(withContainerWidth:…) ``` ```swift BannerAdSize.sticky(containerWidth:…) ``` -------------------------------- ### AppOpenAdDelegate Required Methods Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/07_ad_delegates.md Implement all methods for AppOpenAdDelegate to handle ad events like showing, dismissing, clicking, and impression tracking. ```swift func appOpenAd(_ appOpenAd: AppOpenAd, didFailToShow error: any Error) func appOpenAdDidShow(_ appOpenAd: AppOpenAd) func appOpenAdDidDismiss(_ appOpenAd: AppOpenAd) func appOpenAdDidClick(_ appOpenAd: AppOpenAd) func appOpenAd(_ appOpenAd: AppOpenAd, didTrackImpression impressionData: ImpressionData?) ``` -------------------------------- ### Load Bidder Token for Banner Ads (SDK 7 vs SDK 8) Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/05_loaders.md Compares the SDK 7 approach using `BidderTokenRequestConfiguration` with mutable properties to the SDK 8 factory method `BidderTokenRequest.banner`. ```swift let config = BidderTokenRequestConfiguration(adType: .banner) config.bannerAdSize = adSize config.targetInfo = adTargetInfo tokenLoader.loadBidderToken(requestConfiguration: config) { token in ... } ``` ```swift let targeting = AdTargeting() let request = BidderTokenRequest.banner( size: adSize, targeting: targeting, parameters: ["key": "value"]) tokenLoader.loadBidderToken(request: request) { token in ... } ``` -------------------------------- ### Update BidderTokenLoader and Adapter Identity (SDK 7 vs SDK 8) Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/05_loaders.md Compares the SDK 7 approach of initializing BidderTokenLoader with a network name to the SDK 8 approach, which requires setting a global adapter identity before SDK initialization and using a default BidderTokenLoader. ```swift // SDK 7 let tokenLoader = BidderTokenLoader(mediationNetworkName: "AdMob") ``` ```swift // SDK 8 let adapterIdentity = AdapterIdentity( adapterNetworkName: "AdMob", adapterVersion: "1.0.0", adapterNetworkVersion: "23.5.0" ) YandexAds.setAdapterIdentity(adapterIdentity) YandexAds.initializeSDK(completionHandler: nil) let tokenLoader = BidderTokenLoader() ``` -------------------------------- ### Verification: Swift Code Search Commands Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/08_native.md These bash commands help verify the migration by searching for specific SDK 7 patterns that should be removed or updated in SDK 8. They target Swift files, excluding common build directories. ```bash swift0() { find . -name "*.swift" -not -path "*/Pods/*" -not -path "*/.build/*" -not -path "*/DerivedData/*" -print0; } swift0 | xargs -0 grep -sn "NativeAdImageLoadingObserver\|addImageLoadingObserver" ``` ```bash swift0 | xargs -0 grep -sn "bind(toSliderView" ``` ```bash swift0 | xargs -0 grep -sn "VideoController\|VideoDelegate" ``` ```bash swift0 | xargs -0 grep -sn "NativeTemplateAppearance\|NativeBannerView" ``` ```bash swift0 | xargs -0 grep -sn "NativeVideoPlaybackProgressControl\.reset" ``` ```bash swift0 | xargs -0 grep -sn "\.adAttributes" ``` ```bash swift0 | xargs -0 grep -sn "\.adInfo\.adSize" ``` ```bash swift0 | xargs -0 grep -sn "func setRating\|func rating()" ``` -------------------------------- ### Identify Yandex Mobile Ads SDK Usage in Objective-C Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/01_discovery.md Scan Objective-C files for imports and references to the Yandex Mobile Ads SDK. This helps identify all locations where the SDK is actively used, noting that the migration guide primarily covers Swift. ```objectivec #import ``` -------------------------------- ### Manually Initialize Yandex Mobile Ads SDK Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Examples/ThirdPartyMediationAdapterTemplate/README.md Manually initialize the SDK to potentially speed up the first ad load. This method is safe to reinvoke if the SDK is already initialized. ```swift let adapterIdentity = AdapterIdentity( adapterNetworkName: "MEDIATION_NETWORK_NAME", adapterVersion: "YANDEX_ADAPTER_VERSION", adapterNetworkVersion: "MEDIATION_NETWORK_SDK_VERSION" ) YandexAds.setAdapterIdentity(adapterIdentity) YandexAds.initializeSDK() ``` -------------------------------- ### Load Bidder Token for Other Ad Types (SDK 8) Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/05_loaders.md Demonstrates the use of SDK 8 factory methods for loading bidder tokens for interstitial, rewarded, native, and app open ad types. All parameters are optional. ```swift let request = BidderTokenRequest.interstitial() let request = BidderTokenRequest.rewarded() let request = BidderTokenRequest.native() let request = BidderTokenRequest.appOpenAd() ``` -------------------------------- ### RewardedAdDelegate Required Methods Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/07_ad_delegates.md Implement all methods for RewardedAdDelegate to handle rewarded ad events, including rewards, showing, dismissal, clicks, and impression tracking. ```swift func rewardedAd(_ rewardedAd: RewardedAd, didReward reward: Reward) func rewardedAd(_ rewardedAd: RewardedAd, didFailToShow error: any Error) func rewardedAdDidShow(_ rewardedAd: RewardedAd) func rewardedAdDidDismiss(_ rewardedAd: RewardedAd) func rewardedAdDidClick(_ rewardedAd: RewardedAd) func rewardedAd(_ rewardedAd: RewardedAd, didTrackImpression impressionData: ImpressionData?) ``` -------------------------------- ### Migrate Multiple Properties: SDK 7 vs SDK 8 Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/04_adrequest.md Demonstrates migrating an AdRequest with multiple properties, including 'parameters', 'biddingData', and 'targeting'. SDK 8 consolidates all these into the AdRequest initializer. ```swift // SDK 7 let request = MutableAdRequestConfiguration(adUnitID: "R-M-XXXXX-YY") request.parameters = ["key": "value"] request.biddingData = biddingData let targeting = AdTargeting() targeting.age = 25 request.targeting = targeting // SDK 8 let targeting = AdTargeting( age: 25, gender: .male, location: location ) let request = AdRequest( adUnitID: "R-M-XXXXX-YY", targeting: targeting, parameters: ["key": "value"], biddingData: biddingData ) ``` -------------------------------- ### Verify Banner Ad Migration with Swift Code Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/06_banner.md Provides bash commands to verify the migration by searching for old class names, delegate methods, and initialization patterns in Swift files. It helps ensure that all SDK 7 specific code has been updated to SDK 8. ```bash swift0() { find . -name "*.swift" -not -path "*/Pods/*" -not -path "*/.build/*" -not -path "*/DerivedData/*" -print0; } # Check for old class names (be careful: "AdView" may appear as part of "BannerAdView") swift0 | xargs -0 grep -sn "\bAdView\b" | grep -v "BannerAdView" | grep -v "import" swift0 | xargs -0 grep -sn "\bAdViewDelegate\b" | grep -v "BannerAdViewDelegate" swift0 | xargs -0 grep -sn "adViewDidLoad\|adViewDidFailLoading\|adViewDidClick" | grep -v "bannerAdView" swift0 | xargs -0 grep -sn "adViewWillLeaveApplication\|willPresentScreen\|didDismissScreen" ``` -------------------------------- ### Verify Dependency Updates with grep Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/02_dependencies.md Use grep to confirm that the YandexMobileAds dependency is correctly updated in your Podfile or Package.swift file. ```bash # CocoaPods grep -n "YandexMobileAds" Podfile ``` ```bash # SPM grep -rn "YandexMobileAds" Package.swift 2>/dev/null ``` -------------------------------- ### Run Final Verification Script Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/final_verification.md Execute this script from your app project root to check for forbidden patterns after migration. An exit code of 0 indicates success, while 1 means issues remain and require re-running the script after fixes. ```bash bash "$MIGRATION_PACK/scripts/run_final_verification.sh" . ``` -------------------------------- ### Migrate parameters Assignment: SDK 7 vs SDK 8 Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/04_adrequest.md Shows the migration of setting the 'parameters' property for an AdRequest. In SDK 7, 'parameters' was mutable and set after initialization. In SDK 8, it must be passed directly to the AdRequest initializer. ```swift // SDK 7 let request = MutableAdRequest() request.adUnitID = "R-M-XXXXX-YY" request.parameters = ["key": "value"] bannerAdView.loadAd(with: request) // SDK 8 let request = AdRequest(adUnitID: "R-M-XXXXX-YY", parameters: ["key": "value"]) bannerAdView.loadAd(with: request) ``` -------------------------------- ### SDK 8 Interstitial Ad Loading with Async/Await Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/05_loaders.md This snippet shows the SDK 8 asynchronous approach using async/await for loading interstitial ads. This provides a more modern and often cleaner way to handle asynchronous operations. ```swift class ViewController: UIViewController { let loader = InterstitialAdLoader() func loadAd() async throws { let request = AdRequest(adUnitID: "R-M-XXXXX-YY") let ad = try await loader.loadAd(with: request) } } ``` -------------------------------- ### SDK 8 Interstitial Ad Loading with Completion Handler Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/05_loaders.md This snippet demonstrates the SDK 8 approach using a completion handler for loading interstitial ads. The logic for success or failure is handled directly within the closure. ```swift class ViewController: UIViewController { let loader = InterstitialAdLoader() func loadAd() { let request = AdRequest(adUnitID: "R-M-XXXXX-YY") loader.loadAd(with: request) { [weak self] result in switch result { case .success(let ad): // ad loaded case .failure(let error): // error } } } } ``` -------------------------------- ### Verify Old Delegate Method Names Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/07_ad_delegates.md Use these bash commands to search for occurrences of old delegate method names in your Swift files. This helps ensure that no outdated methods are still in use. ```bash swift0() { find . -name "*.swift" -not -path "*/Pods/*" -not -path "*/.build/*" -not -path "*/DerivedData/*" -print0; } swift0 | xargs -0 grep -sn "didFailToShowWithError\|didTrackImpressionWith[^a-zA-Z]" ``` ```bash swift0 | xargs -0 grep -sn "nativeAdWillLeaveApplication\|sliderAdWillLeaveApplication\|sliderAdDidClose\|viewControllerForPresentingModalView" ``` -------------------------------- ### Migration Progress Tracking Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/SKILL.md Maintain a running status list to track the progress of each migration step. Use checkboxes to indicate completion status. ```markdown ## Migration Progress - [x] Step 1: Discovery — found N files - [x] Step 2: Dependencies — updated Podfile/Package.swift - [-] Step 3: Simple renames — processing (M/N files done) - [ ] Step 4: AdRequest - [ ] Step 5: Loaders - [ ] Step 6: Banner - [ ] Step 7: Ad delegates - [ ] Step 8: Native - [ ] Step 9: @MainActor - [ ] Final verification ``` -------------------------------- ### SDK 7 Interstitial Ad Loading with Delegate Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/05_loaders.md This snippet shows the older SDK 7 approach to loading an interstitial ad using a delegate. It requires conforming to `InterstitialAdLoaderDelegate` and implementing its methods. ```swift class ViewController: UIViewController, InterstitialAdLoaderDelegate { let loader = InterstitialAdLoader() func loadAd() { let configuration = AdRequestConfiguration(adUnitID: "R-M-XXXXX-YY") loader.delegate = self loader.loadAd(with: configuration) } func interstitialAdLoader(_ adLoader: InterstitialAdLoader, didLoad ad: InterstitialAd) { // ad loaded } func interstitialAdLoader(_ adLoader: InterstitialAdLoader, didFailToLoadWithError error: AdRequestError) { // error } } ``` -------------------------------- ### Update Ad Show Method Signature Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/changelog/YandexMobileAds.md The `show` method signature for `AppOpenAd`, `InterstitialAd`, and `RewardedAd` has been updated. The `viewController` parameter is now optional. ```swift func show(from viewController: UIViewController?) ``` -------------------------------- ### Migrate biddingData Assignment: SDK 7 vs SDK 8 Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/04_adrequest.md Illustrates the change in assigning 'biddingData' for an AdRequest. SDK 7 allowed post-initialization assignment, while SDK 8 requires 'biddingData' to be included in the AdRequest initializer. ```swift // SDK 7 let request = MutableAdRequestConfiguration(adUnitID: "R-M-XXXXX-YY") request.biddingData = biddingData // SDK 8 let request = AdRequest(adUnitID: "R-M-XXXXX-YY", biddingData: biddingData) ``` -------------------------------- ### NativeAdDelegate Required Methods Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/07_ad_delegates.md Implement the required methods for NativeAdDelegate to manage native ad interactions, including clicks and impression tracking. ```swift func nativeAdDidClick(_ ad: any NativeAd) func nativeAd(_ ad: any NativeAd, didTrackImpression impressionData: ImpressionData?) ``` -------------------------------- ### Rename BidderTokenRequestConfiguration Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/03_mechanical_renames.md The `BidderTokenRequestConfiguration` class and its associated method `loadBidderToken` have been renamed to `BidderTokenRequest` and `loadBidderToken(request:)` respectively. Note that `BidderTokenRequest` now uses factory methods. ```swift BidderTokenRequestConfiguration ``` ```swift BidderTokenRequest ``` ```swift loadBidderToken(requestConfiguration:…) ``` ```swift loadBidderToken(request:…) ``` -------------------------------- ### Verification Script for @MainActor Compliance Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/migrate-yandex-ads-sdk-from-7-to-8/steps/09_mainactor.md This bash script helps identify Swift files that conform to specific Yandex Ads SDK delegate protocols, which may require @MainActor annotations. It excludes files within Pods, .build, and DerivedData directories. ```bash swift0() { find . -name "*.swift" -not -path "*/Pods/*" -not -path "*/.build/*" -not -path "*/DerivedData/*" -print0; } # Find classes conforming to SDK delegates that may need @MainActor swift0 | xargs -0 grep -sn "AppOpenAdDelegate\|InterstitialAdDelegate\|RewardedAdDelegate\|NativeAdDelegate\|SliderAdDelegate\|BannerAdViewDelegate" ``` -------------------------------- ### Reference SKILL.md for Cursor IDE Source: https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Skills/README.md In Cursor IDE, copy the skill folder to your project and reference the SKILL.md file using the '@' symbol. ```markdown @migrate-yandex-ads-sdk-from-7-to-8/SKILL.md ```