[英]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:这是我的代码和设置:
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
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.