简体   繁体   English

Flutter 插件:iOS 原生代码中没有这样的模块“google_mobile_ads”

[英]Flutter plugin: No such module 'google_mobile_ads' in iOS native code

I create a Flutter plugin for Admob to reuse in my different projects for banner, interstitial, native ad and rewarded ads.我为 Admob 创建了一个 Flutter 插件,以便在我的横幅、插页式、原生广告和奖励广告的不同项目中重复使用。 I create it so that I can just add the plugin to other project's pubspec.yaml and use without recode everytime.我创建它,以便我可以将插件添加到其他项目的 pubspec.yaml 并使用而无需每次重新编码。

It works fine on Android code, the "google_mobile_ads" sdk is recognized and can be accessed without adding any dependency.它在 Android 代码上运行良好,“google_mobile_ads”sdk 被识别并且可以在不添加任何依赖项的情况下访问。

But, the problem is that the google_mobile_ads is not recognized in my iOS code (to create the Native Ad Factory) when Run Build in Xcode.但是,问题是在 Xcode 中运行构建时,我的 iOS 代码(以创建原生广告工厂)中无法识别google_mobile_ads When I use "Ctrl + Click" the "FLTNativeAdFactory" class to "Jump to Definition" in Xcode, it works but the build fail with the error.当我在 Xcode 中使用“Ctrl + Click”将“FLTNativeAdFactory”类“跳转到定义”时,它可以工作,但构建失败并出现错误。 See the attached image.见附图。

Here is my code and setup:这是我的代码和设置:

  • admob_ads plugin pubspec.yaml admob_ads 插件 pubspec.yaml admob_ads 插件 pubspec.yaml

  • the ios code podspec ios 代码 podspec

Pod::Spec.new do |s|
  s.name             = 'admob_ads'
  s.version          = '0.0.1'
  s.summary          = 'A new Flutter plugin project.'
  s.description      = <<-DESC
A new Flutter plugin project.
                       DESC
  s.homepage         = 'http://example.com'
  s.license          = { :file => '../LICENSE' }
  s.author           = { 'Your Company' => 'email@example.com' }
  s.source           = { :path => '.' }
  s.source_files = 'Classes/**/*'
  s.dependency 'Flutter'
  s.dependency 'Cosmos', '~> 23.0'
  s.platform = :ios, '9.0'

  # Flutter.framework does not contain a i386 slice.
  s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
  s.swift_version = '5.0'
end
  • The ios code tree and error: ios代码树和错误: 在此处输入图像描述

Please help!请帮忙!

You can refer to this error log: https://github.com/googleads/googleads-mobile-flutter/issues/594你可以参考这个错误日志: https ://github.com/googleads/googleads-mobile-flutter/issues/594

Until it gets fixed, this is the current workaround:在它得到修复之前,这是当前的解决方法:

In your pubspec.yaml, change在您的 pubspec.yaml 中,更改

google_mobile_ads: ^1.0.1 google_mobile_ads:^1.0.1

to:至:

  google_mobile_ads:
    git:
      url: https://github.com/googleads/googleads-mobile-flutter
      ref: 356875362ddb2ac2e0056385d2729c093722fb8d
      path: packages/google_mobile_ads

or this:或这个:

  google_mobile_ads:
    git:
      url: https://github.com/jjliu15/googleads-mobile-flutter-1.git
      path: packages/google_mobile_ads/

I found it worked better when I took the ref: out.当我拿出 ref: out 时,我发现它效果更好。

You could try this one:你可以试试这个:

  google_mobile_ads:
    git:
      url: https://github.com/jjliu15/googleads-mobile-flutter-1.git
      ref: delete_deprecations
      path: packages/google_mobile_ads/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter 谷歌移动广告仅在 IOS 上显示测试广告 - Flutter google mobile ads only shows test ads on IOS Google Mobile Native Express广告iOS-[AnyObject]问题 - Google Mobile Native Express ads iOS - Issues with [AnyObject] 如何在flutter插件中调试iOS本机代码? - How to debug iOS native code in a flutter plugin? Expo 应用程序因 react-native-google-mobile-ads 崩溃 [在 app.json 中的 react-native-google-mobile-ads 键中找不到 ios_appd_id 键] - Expo app crashes with react-native-google-mobile-ads [ios_appd_id key not found in react-native-google-mobile-ads key in app.json] Google统一移动广告(iOS)显示错误 - Google mobile ads in unity (iOS) shows error Flutter Firebase_Admob“Google移动广告SDK需要iOS 8.0或更高版本的部署目标。”iOS错误 - Flutter Firebase_Admob “The Google Mobile Ads SDK requires a deployment target of iOS 8.0 or later.” iOS error iOS / Google Ads链接器代码失败 - iOS/Google Ads giving Linker Code Failure 谷歌移动广告的实施减慢了 flutter 应用程序 - Google mobile Ads implementation slowed down flutter App iOS版Facebook上的移动广告 - Mobile Ads on Facebook for iOS Google移动广告统一在iOS启动时使应用程序崩溃 - google mobile ads unity crashes app on startup in iOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM