yandexmobile / yandex-ads-sdk-ios

Yandex Mobile Ads SDK iOS
https://yandex.com/dev/mobile-ads/
Other
40 stars 8 forks source link

6.3.0 fails to build with Objective-C. #191

Closed Lerg closed 6 months ago

Lerg commented 9 months ago

In 6.3.0 the structure (or bundling) of the framework was changed.

Before 6.3.0 the YandexMobileAds.h included everything:

#import <YandexMobileAds/YMAMobileAds.h>
#import <YandexMobileAds/YMAAdView.h>
#import <YandexMobileAds/YMABannerAdSize.h>
#import <YandexMobileAds/YMAAdRequest.h>
#import <YandexMobileAds/YMAAudioSessionManager.h>
#import <YandexMobileAds/YMAAudioSessionManagerDelegate.h>
#import <YandexMobileAds/YMAReward.h>
#import <YandexMobileAds/YMAErrors.h>
#import <YandexMobileAds/YMAVersion.h>
#import <YandexMobileAds/YMAVideoController.h>
#import <YandexMobileAds/YMAVideoDelegate.h>
#import <YandexMobileAds/YMAImpressionData.h>
#import <YandexMobileAds/YMABidderTokenLoader.h>
#import <YandexMobileAds/YMAGender.h>
#import <YandexMobileAds/YMAAdTheme.h>

#import <YandexMobileAds/YMARewardedAd.h>
#import <YandexMobileAds/YMARewardedAdDelegate.h>
#import <YandexMobileAds/YMARewardedAdLoader.h>
#import <YandexMobileAds/YMARewardedAdLoaderDelegate.h>
#import <YandexMobileAds/YMAInterstitialAd.h>
#import <YandexMobileAds/YMAInterstitialAdDelegate.h>
#import <YandexMobileAds/YMAInterstitialAdLoader.h>
#import <YandexMobileAds/YMAInterstitialAdLoaderDelegate.h>
#import <YandexMobileAds/YMAAdRequestConfiguration.h>
#import <YandexMobileAds/YMAMutableAdRequestConfiguration.h>
#import <YandexMobileAds/YMAAdRequestError.h>
#import <YandexMobileAds/YMAAppOpenAdLoaderDelegate.h>
#import <YandexMobileAds/YMAAppOpenAdLoader.h>
#import <YandexMobileAds/YMAAppOpenAd.h>

In 6.3.0 the YandexMobileAds.h includes only a small part of the SDK:

#ifndef YandexMobileAds_h
#define YandexMobileAds_h

#import <YandexMobileAds/YMAErrors.h>
#import <YandexMobileAds/YMAHorizontalOffset.h>
#import <YandexMobileAds/YMAVersion.h>
#import <YandexMobileAds/YMANativeAdErrors.h>
#import <YandexMobileAds/YMANativeAdView.h>
#import <YandexMobileAds/YMANativeMediaView.h>
#import <YandexMobileAds/YMAGender.h>

#endif /* YandexMobileAds_h */

Which results in a breaking change, old ObjC projects fail to compile.

Changing #import <YandexMobileAds/YandexMobileAds.h> to #import <YandexMobileAds/YandexMobileAds-Swift.h> doesn't fix the issue. The app fails to link:

    ld: warning: ignoring duplicate libraries: '-lc++'
    ld: warning: Could not find or use auto-linked library 'swiftObservation': library 'swiftObservation' not found
    ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
    ld: warning: Could not find or use auto-linked framework 'MACAVPlayer': framework 'MACAVPlayer' not found
    ld: warning: Could not find or use auto-linked framework 'MACAnalytics': framework 'MACAnalytics' not found
    ld: warning: Could not find or use auto-linked framework 'MACBase': framework 'MACBase' not found
    ld: warning: Could not find or use auto-linked framework 'MACBaseUI': framework 'MACBaseUI' not found
    ld: warning: Could not find or use auto-linked framework 'MACCAChallengeHandler': framework 'MACCAChallengeHandler' not found
    ld: warning: Could not find or use auto-linked framework 'MACConsent': framework 'MACConsent' not found
    ld: warning: Could not find or use auto-linked framework 'MACConstants': framework 'MACConstants' not found
    ld: warning: Could not find or use auto-linked framework 'MACDependenciesUmbrella': framework 'MACDependenciesUmbrella' not found
    ld: warning: Could not find or use auto-linked framework 'MACDivKit': framework 'MACDivKit' not found
    ld: warning: Could not find or use auto-linked framework 'MACEncryption': framework 'MACEncryption' not found
    ld: warning: Could not find or use auto-linked framework 'MACEventTracking': framework 'MACEventTracking' not found
    ld: warning: Could not find or use auto-linked framework 'MACFeatureFlags': framework 'MACFeatureFlags' not found
    ld: warning: Could not find or use auto-linked framework 'MACHeaderBidding': framework 'MACHeaderBidding' not found
    ld: warning: Could not find or use auto-linked framework 'MACLogging': framework 'MACLogging' not found
    ld: warning: Could not find or use auto-linked framework 'MACMediation': framework 'MACMediation' not found
    ld: warning: Could not find or use auto-linked framework 'MACMraid': framework 'MACMraid' not found
    ld: warning: Could not find or use auto-linked framework 'MACNative': framework 'MACNative' not found
    ld: warning: Could not find or use auto-linked framework 'MACNetworking': framework 'MACNetworking' not found
    ld: warning: Could not find or use auto-linked framework 'MACPlatformDescription': framework 'MACPlatformDescription' not found
    ld: warning: Could not find or use auto-linked framework 'MACSDKConfiguration': framework 'MACSDKConfiguration' not found
    ld: warning: Could not find or use auto-linked framework 'MACStoreKit': framework 'MACStoreKit' not found
    ld: warning: Could not find or use auto-linked framework 'MACTimeTracking': framework 'MACTimeTracking' not found
    ld: warning: Could not find or use auto-linked framework 'MACVASTKit': framework 'MACVASTKit' not found
    ld: warning: Could not find or use auto-linked framework 'MobileAdsCore': framework 'MobileAdsCore' not found
    ld: warning: Could not find or use auto-linked framework 'Symbols': framework 'Symbols' not found
    ld: warning: Could not find or use auto-linked framework 'YandexMobileAds_Private': framework 'YandexMobileAds_Private' not found
    ld: Undefined symbols:
  Foundation.URL.init(string: __shared Swift.String, encodingInvalidCharacters: Swift.Bool) -> Foundation.URL?, referenced from:
      (extension in MACBase):Foundation.URL.init(stringWithoutEncodingInvalidCharacters: Swift.String) -> Foundation.URL? in YandexMobileAds[792](URLExtensions.o)
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

How to use the framework in an Obj-C app now? (it's an extension for a game engine)

mobile-ads-github commented 9 months ago

Try to add #import <YandexMobileAds/YandexMobileAds-Swift.h> next to your #import YandexMobileAds.h

Lerg commented 9 months ago

Try to add #import <YandexMobileAds/YandexMobileAds-Swift.h> next to your #import YandexMobileAds.h

Unfortunately the same linking error.

mobile-ads-github commented 9 months ago

Спасибо за Ваше обращение, для разбора создана задача с номером PCODESUP-2772. Мы ознакомимся и вернемся с ответом в течение 2 дней, возможно запросим дополнительную информацию.

Thank you for your message, a task with the number PCODESUP-2772 has been created for analysis. We will get acquainted and return with the answer within 2 days, we may request additional information.

mobile-ads-github commented 9 months ago

Can your provide, swift and Xcode version and describe your project setup? It would be great, If you could provide a sample project, that reproduces the problem.

Lerg commented 9 months ago

Can your provide, swift and Xcode version and describe your project setup? It would be great, If you could provide a sample project, that reproduces the problem.

Sure.

  1. Download and install the Defold game engine (free, no account is required) https://defold.com/download/

  2. Download and extract the sample project attached to this message extension-yandexads-6.3.0.zip

  3. Open Defold and open the extracted project (select game.project file)

  4. In Defold open the game.project file and set your iOS bundle identifier

    bundle_identifier

    Actually it might not be required if you just want to test the compilation.

  5. Select menu Project -> Bundle -> iOS Application, choose your signing identity and provisioning profile and hit Create Bundle

    bundle_window
  6. After about 10 minutes of bundling you will see the error message

    build_error

The relevant source code is in extension-yandexads/src/extension_ios.mm The Podfile is in extension-yandexads/manifests/ios/

This extension on github but with the 6.1.0 version of the SDK (this one works) https://github.com/Lerg/extension-yandexads

mobile-ads-github commented 8 months ago

Can you try to check it on the latest version of Defold?