react-native-admob-native-ads icon indicating copy to clipboard operation
react-native-admob-native-ads copied to clipboard

[M1 Silicon][0.6.0] Build workaround with react-native-google-mobile-ads[8.2.3]

Open AuroPick opened this issue 2 years ago • 9 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNAdMobUnifiedAdQueueWrapper.m b/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNAdMobUnifiedAdQueueWrapper.m
index 2f4724a..a636e31 100644
--- a/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNAdMobUnifiedAdQueueWrapper.m
+++ b/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNAdMobUnifiedAdQueueWrapper.m
@@ -13,7 +13,7 @@
 #import "CacheManager.h"
 @import GoogleMobileAds;
 #ifdef MEDIATION_FACEBOOK
-@import FacebookAdapter;
+@import MetaAdapter;
 #endif
 
 @implementation RNAdMobUnifiedAdQueueWrapper{
diff --git a/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNGADNativeView.m b/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNGADNativeView.m
index c876c8b..f4a82eb 100755
--- a/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNGADNativeView.m
+++ b/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNGADNativeView.m
@@ -8,7 +8,7 @@
 #import <React/RCTUIManagerUtils.h>
 
 #ifdef MEDIATION_FACEBOOK
-@import FacebookAdapter;
+@import MetaAdapter;
 #endif
 
 @implementation RNGADNativeView : GADNativeAdView
diff --git a/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNNativeAdMobUtils.h b/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNNativeAdMobUtils.h
index 4da2264..2d51e22 100755
--- a/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNNativeAdMobUtils.h
+++ b/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNNativeAdMobUtils.h
@@ -1,6 +1,6 @@
 #import <Foundation/Foundation.h>
 
-#if __has_include(<FacebookAdapter/FacebookAdapter.h>)
+#if __has_include(<MetaAdapter/MetaAdapter.h>)
 #define MEDIATION_FACEBOOK
 #endif
 
diff --git a/node_modules/react-native-admob-native-ads/react-native-admob-native-ads.podspec b/node_modules/react-native-admob-native-ads/react-native-admob-native-ads.podspec
index 7b92e8e..dad4d34 100755
--- a/node_modules/react-native-admob-native-ads/react-native-admob-native-ads.podspec
+++ b/node_modules/react-native-admob-native-ads/react-native-admob-native-ads.podspec
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
   # So instead we add the default location of the framework to the framework
   # search paths, and we rely on consumers of this library to add
   # Google-Mobile-Ads-SDK as a direct dependency.
-  s.weak_frameworks        = 'GoogleMobileAds', 'FacebookAdapter'
+  s.weak_frameworks        = 'GoogleMobileAds', 'MetaAdapter'
   s.pod_target_xcconfig    = {
     'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/Google-Mobile-Ads-SDK/Frameworks/**" '\
                                 '"$(PODS_ROOT)/FBAudienceNetwork/**" '\

This issue body was partially generated by patch-package.

and also I used pod-patch to create custom FBAudienceNetwork podspec to build in M1 environment

here is custom podspec and diff file I used:

{
  "name": "FBAudienceNetwork",
  "version": "6.12.0",
  "summary": "Facebook Audience Network Mobile App Ad SDK",
  "description": "Facebook's Audience Network allows you to monetize your iOS and Android apps with Facebook ads.",
  "homepage": "https://developers.facebook.com/docs/audience-network",
  "license": {
    "type": "Copyright",
    "text": "              Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.\n\n              You are hereby granted a non-exclusive, worldwide, royalty-free license to use,\n              copy, modify, and distribute this software in source code or binary form for use\n              in connection with the web services and APIs provided by Facebook.\n\n              As with any software that integrates with the Facebook platform, your use of\n              this software is subject to the Facebook Platform Policy\n              [http://developers.facebook.com/policy/]. This copyright notice shall be\n              included in all copies or substantial portions of the software.\n\n              THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n              IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n              FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n              COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n              IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n              CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  "authors": "Facebook",
  "platforms": {
    "ios": "10.0"
  },
  "source": {
    "http": "https://developers.facebook.com/resources/FBAudienceNetwork-6.12.0.zip",
    "sha1": "9d06f49050020e623b948089713ff55e2ba40c7d"
  },
  "source_files": "Static/FBAudienceNetwork.xcframework/**/*.h",
  "public_header_files": "Static/FBAudienceNetwork.xcframework/**/*.h",
  "frameworks": [
    "AudioToolbox",
    "StoreKit",
    "CoreGraphics",
    "UIKit",
    "Foundation",
    "Security",
    "CoreImage",
    "AVFoundation",
    "CoreMedia"
  ],
  "weak_frameworks": [
    "AdSupport",
    "CFNetwork",
    "CoreMotion",
    "CoreTelephony",
    "LocalAuthentication",
    "SafariServices",
    "SystemConfiguration",
    "VideoToolbox",
    "WebKit"
  ],
  "libraries": [
    "c++",
    "xml2",
    "z"
  ],
  "user_target_xcconfig": {
    "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64"
  },
  "pod_target_xcconfig": {
    "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64"
  },
  "vendored_frameworks": "Static/FBAudienceNetwork.xcframework",
  "requires_arc": true,
  "swift_versions": "5.0",
  "swift_version": "5.0"
}
--- FBAudienceNetwork.podspec.json	2023-01-11 23:15:22
+++ FBAudienceNetwork_new.podspec.json	2023-01-11 23:12:04
@@ -46,13 +46,13 @@
     "z"
   ],
   "user_target_xcconfig": {
-    "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "i386"
+    "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64"
   },
   "pod_target_xcconfig": {
-    "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "i386"
+    "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64"
   },
   "vendored_frameworks": "Static/FBAudienceNetwork.xcframework",
   "requires_arc": true,
   "swift_versions": "5.0",
   "swift_version": "5.0"
-}
+}
\ No newline at end of file

Screenshot 2023-01-12 at 16 06 00

here is my podfile:

target 'Project' do

  # ...

  # #region react-native-admob-native-ads pod dependencies
  pod 'FBAudienceNetwork', :podspec => './pod-patch/.patched/FBAudienceNetwork/6.12.0/FBAudienceNetwork.podspec.json'

  pod 'Google-Mobile-Ads-SDK', '9.12.0'
  pod 'GoogleMobileAdsMediationFacebook', '6.12.0.0'
  # #endregion

  # ...

after applying these changes simply run

cd ios && pod deintegrate && rm -rf Podfile.lock && cd ..

cd ios && pod install --repo-update && cd ..

AuroPick avatar Jan 12 '23 13:01 AuroPick

what react-native-google-mobile-ads version did you use? Also can you provide little more detail on how pod-patch was created?

retireearly avatar Apr 25 '23 21:04 retireearly

what react-native-google-mobile-ads version did you use? Also can you provide little more detail on how pod-patch was created?

8.2.3

AuroPick avatar Apr 25 '23 21:04 AuroPick

check pod-patch documentation

AuroPick avatar Apr 25 '23 21:04 AuroPick

Thanks for the help. I have more issue.

When I call AdManager.isTestDevice, I am getting RNAdmobNativeAdsManager.isTestDevice was called with 0 arguments but expects 1 arguments. How did you resolve this?

retireearly avatar Apr 25 '23 22:04 retireearly

Command PhaseScriptExecution failed with a nonzero exit code

getting this

ihdev524 avatar Apr 26 '23 13:04 ihdev524

Thanks for the help. I have more issue.

When I call AdManager.isTestDevice, I am getting RNAdmobNativeAdsManager.isTestDevice was called with 0 arguments but expects 1 arguments. How did you resolve this?

actually i did not use isTestDevice anywhere in my code but when I look to source code it looks like isTestDevice wants an argument but does not provided in js side. I am not the library owner so i do not have any idea

https://github.com/ammarahm-ed/react-native-admob-native-ads/blob/3948fcc6a005d1e7bc0167819d8c10d4a179822d/src/AdManager.js#L11

https://github.com/ammarahm-ed/react-native-admob-native-ads/blob/3948fcc6a005d1e7bc0167819d8c10d4a179822d/android/src/main/java/com/ammarahmed/rnadmob/nativeads/RNAdmobNativeAdsManager.java#L88

AuroPick avatar Apr 26 '23 19:04 AuroPick

Command PhaseScriptExecution failed with a nonzero exit code

getting this

I have no idea but it can be an issue with the pods

AuroPick avatar Apr 26 '23 19:04 AuroPick

@AuroPick any solution for android? It crashes for the same reason

absolutezero13 avatar Jun 26 '23 08:06 absolutezero13

@absolutezero13 Try v0.6.3. It builds correctly on both android & ios.

ammarahm-ed avatar Jun 27 '23 11:06 ammarahm-ed