Skip to content

Commit 33cc489

Browse files
committed
add podspec file for cocoapods support
when using React Native AdMob with cocoapods, you have to add `Google-Mobile-Ads-SDK` to your `Podfile` manually, because that framework contains a binary framework, which isn't supported when used with `use_frameworks!`.
1 parent 4990613 commit 33cc489

3 files changed

Lines changed: 40 additions & 10 deletions

File tree

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ You can use npm or Yarn to install the latest beta version:
2020

2121
In order to use this library, you have to link it to your project first. There's excellent documentation on how to do this in the [React Native Docs](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#content).
2222

23+
Alternatively for iOS you can install the library with CocoaPods by adding a line to your `Podfile`;
24+
25+
pod 'react-native-admob', path: '../node_modules/react-native-admob'
26+
2327
### iOS
2428

2529
For iOS you will have to add the [Google Mobile Ads SDK](https://developers.google.com/admob/ios/quick-start#import_the_mobile_ads_sdk) to your Xcode project.
@@ -75,7 +79,7 @@ For a full example reference to the [example project](Example).
7579

7680
##### `adSize`
7781

78-
*Corresponding to [iOS framework banner size constants](https://developers.google.com/admob/ios/banner)*
82+
_Corresponding to [iOS framework banner size constants](https://developers.google.com/admob/ios/banner)_
7983

8084
<table>
8185
<thead>
@@ -84,7 +88,7 @@ For a full example reference to the [example project](Example).
8488
<th>Description</th>
8589
<th>Availability</th>
8690
<th>Size (WxH)</th>
87-
</t>
91+
</tr>
8892
</thead>
8993
<tbody>
9094
<tr>
@@ -129,7 +133,7 @@ For a full example reference to the [example project](Example).
129133
</tbody>
130134
</table>
131135

132-
*Note: There is no `smartBannerPortrait` and `smartBannerLandscape` on Android. Both prop values will map to `smartBanner`*
136+
_Note: There is no `smartBannerPortrait` and `smartBannerLandscape` on Android. Both prop values will map to `smartBanner`_
133137

134138
##### `onAdLoaded`
135139

@@ -155,8 +159,7 @@ Accepts a function. Called when a user click will open another app (such as the
155159

156160
Accepts a function. Called when the size of the banner changes. The function is called with an object containing the width and the height.
157161

158-
159-
*Above names correspond to the [Ad lifecycle event callbacks](https://developers.google.com/admob/android/banner#ad_events)*
162+
_Above names correspond to the [Ad lifecycle event callbacks](https://developers.google.com/admob/android/banner#ad_events)_
160163

161164
### PublisherBanner
162165

@@ -190,7 +193,7 @@ Sets the AdUnit ID for all future ad requests.
190193

191194
Sets the devices which are served test ads.
192195

193-
*For simulators/emulators you can use `AdMobInterstitial.simulatorId` for the test device ID.*
196+
_For simulators/emulators you can use `AdMobInterstitial.simulatorId` for the test device ID._
194197

195198
##### `requestAd()`
196199

@@ -204,7 +207,6 @@ Shows an interstitial and returns a promise, which resolves when an ad is going
204207

205208
Calls callback with a boolean value whether the interstitial is ready to be shown.
206209

207-
208210
#### Events
209211

210212
Unfortunately, events are not consistent across iOS and Android. To have one unified API, new event names are introduced for pairs that are roughly equivalent.
@@ -265,7 +267,7 @@ Sets the AdUnit ID for all future ad requests.
265267

266268
Sets the devices which are served test ads.
267269

268-
*For simulators/emulators you can use `AdMobRewarded.simulatorId` for the test device ID.*
270+
_For simulators/emulators you can use `AdMobRewarded.simulatorId` for the test device ID._
269271

270272
##### `requestAd()`
271273

@@ -289,7 +291,7 @@ Unfortunately, events are not consistent across iOS and Android. To have one uni
289291
<th>This library</th>
290292
<th>iOS</th>
291293
<th>Android</th>
292-
</t>
294+
</tr>
293295
</thead>
294296
<tbody>
295297
<tr>

ios/RNDFPBannerView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if __has_include(<React/RCTComponent.h>)
1+
#if __has_include(<React/RCTView.h>)
22
#import <React/RCTView.h>
33
#else
44
#import "RCTView.h"

react-native-admob.podspec

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'json'
2+
3+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4+
version = package['version']
5+
6+
Pod::Spec.new do |s|
7+
s.name = 'react-native-admob'
8+
s.version = version
9+
s.summary = 'A react-native component for Google AdMob banners'
10+
s.homepage = 'https://github.com/sbugert/react-native-admob'
11+
s.license = package['license']
12+
s.author = 'Simon Bugert <simon.bugert@gmail.com>, Koen Punt <koen@koenpunt.nl>'
13+
s.platforms = { :ios => '9.0', :tvos => '9.2' }
14+
s.source = { :git => 'https://github.com/sbugert/react-native-admob.git', :tag => "v#{version}" }
15+
s.source_files = 'ios/*.{h,m}'
16+
17+
# We can't add the Google-Mobile-Ads-SDK as a dependency, as it would prevent
18+
# this library to be used with `use_frameworks!`.
19+
# So instead we add the default location of the framework to the framework
20+
# search paths, and we rely on consumers of this library to add
21+
# Google-Mobile-Ads-SDK as a direct dependency.
22+
s.weak_frameworks = 'GoogleMobileAds'
23+
s.pod_target_xcconfig = {
24+
'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/Google-Mobile-Ads-SDK/Frameworks/**"',
25+
}
26+
27+
s.dependency 'React'
28+
end

0 commit comments

Comments
 (0)