Open the Google Mobile Ads Mediation Test Suite in a Titanium iOS app
You can use this module if your app shows AdMob ads. It allows you to test whether you have correctly configured your app and ad units to be able to display ads from third-party networks through mediation (InMobi, Facebook Audience Network, etc...)
You don't need ti.gmamts
module if you use the ti.admob module, this method has been added since iOS version 4.8.0, so you can directly use:
If you use the ti.admob, Google Mobile Ads Mediation Test Suite is included starting with the iOS version 4.8.0, so you don't need ti.gmamtsm
module, but you can use it directly with ti.admob
:
var Admob = require('ti.admob');
Admob.showMediationTestSuite();
- iOS 10.0 or higher
- Create an AdMob account and register an app.
- Ensure you have correctly entered your app ID in your
tiapp.xml
.
<ios>
<plist>
<dict>
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX</string>
</dict>
</plist>
</ios>
tiapp.xml
...
...
<ios>
<plist>
<dict>
<key>GADApplicationIdentifier</key>
<string><!--YOUR ADMOB APP-ID HERE--></string>
</dict>
</plist>
</ios>
...
...
<modules>
<module platform="iphone">ti.gmamts</module>
</modules>
index.js
var gmamts = require('ti.gmamts');
gmamts.showMediationTestSuite();
This module is built using cocoapods. They are very useful for automatically downloading frameworks and their dependencies, but they are not officially supported for the development of Titanium iOS modules.
We need a binary to put into platform/
, otherwise it won't be packaged with the module and result in linker errors. To do so, we use cocoapods-binary
plugin. It generates the necessary *.framework that we can put into platform/
.
However you can use them by following these steps:
- If you haven't already, from a terminal install cocoapods and then cocoapods-binary
sudo gem install cocoapods
sudo gem install cocoapods-binary
- Change the current working directory to your workspace and run:
cd /PATH/TO/MODULE
- You can go to step 4. I show this step only for those who want to create a new module.:
ti create -t module -p ios -n gmats --id ti.gmamts
Titanium creates a basic Xcode project gmamts.xcodeproj
- Go to the module's
/ios
folder and create the Podfile
cd gmamts/ios
pod init
- This generates a Podfile. Open and edit the Podfile with the required frameworks:
# Uncomment the next line to define a global platform for your project
plugin 'cocoapods-binary'
install! 'cocoapods',
:integrate_targets => false
platform :ios, '12.0'
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
target 'gmamts' do
# Pods for gmamts
pod 'GoogleMobileAdsMediationTestSuite', :binary => true
end
- Install the pod with the command
pod install
This will do the magic, download and create binaries of all frameworks under Pods/_Prebuild/<FrameworkName>/<FrameworkName>.framework
-
Now we need to copy all the generated
<FrameworkName>.framework
into the/platform
folder -
The
install pod
generated a new Xcode project gmamts.xcworkspace. We have to use this new one to modify the module. We can open the project manually, or using the terminal
open gmamts.xcworkspace
At the end of the titanium.xcconfig
file we need to copy the contents of the Pods-gmamts.release.xcconfig
file. We find it on Xcode in gmamts > Pods > Pods-gmamts.release.xcconfig or at path /ios/Pods/Target Support Files/Pods-gmamts/Pods-gmamts.release.xcconfig
- Finally we need to set this config file to Xcode. By clicking on the project name and opening the tab gmamts > Info > Configurations, we need to change all the Based on Configuration Files from Pods-gmamts.debug/Pods-gmamts.release to titanium (as in the picture below).
- That's really all now, we just need to build the module:
ti build -p ios --build-only -l trace
Vittorio Sorbera - AstrovicApps