I would like to open the discussion of added Ads via Google Mobile Ads/Firebase Admob to JUCE. I’ll start by explaining how I got it to “work” on my end, getting around the issue of Google wanting us to use CocoaPods to install/configure Firebase-AdMob with our xcode projects. So, without further adieu…
After downloading the SDK from the Google Firebase website, and creating a generic JUCE GUI application for iOS:
I was able to get it working/compiling by doing the following:
- I had to include the following Apple frameworks manually in ProJucer:
CoreMotion,
MediaPlayer,
AdSupport,
MessageUI,
MobileCoreServices,
CoreTelephony,
Security,
StoreKit,
SystemConfiguration,
UIKit,
Foundation,
CoreMedia,
GLKit,
- then the Firebase core frameworks:
/Volumes/Thunderbay/MyBook2/Programming/Firebase/Analytics/FirebaseAnalytics,
/Volumes/Thunderbay/MyBook2/Programming/Firebase/Analytics/FirebaseCore,
/Volumes/Thunderbay/MyBook2/Programming/Firebase/Analytics/FirebaseCoreDiagnostics,
/Volumes/Thunderbay/MyBook2/Programming/Firebase/Analytics/FirebaseInstanceID,
/Volumes/Thunderbay/MyBook2/Programming/Firebase/Analytics/GoogleAppMeasurement,
/Volumes/Thunderbay/MyBook2/Programming/Firebase/Analytics/GoogleUtilities,
/Volumes/Thunderbay/MyBook2/Programming/Firebase/Analytics/MeasurementNanoPB,
/Volumes/Thunderbay/MyBook2/Programming/Firebase/Analytics/nanopb,
- and finally, the AdMob framework:
/Volumes/Thunderbay/MyBook2/Programming/Firebase/AdMob/GoogleMobileAds,
All of these are added to the Extra Frameworks
field in Projucer.
- All of the frameworks that get used need to be included as a single string, separated via spaces, inside quotes as the argument to
FRAMEWORK_SEARCH_PATHS="/path/to/A /path/to/B"
underCustom Xcode Flags
in ProJucer add:
FRAMEWORK_SEARCH_PATHS="/Volumes/Thunderbay/MyBook2/Programming/Firebase/Analytics /Volumes/Thunderbay/MyBook2/Programming/Firebase/Admob"
- These are the projucer Extra Linker Flags that are required:
$(OTHER_LDFLAGS) -ObjC -lsqlite3 -lz
- the
Header search paths
andExtra library search paths
:
/Volumes/Thunderbay/MyBook2/Programming/Firebase/Analytics;
/Volumes/Thunderbay/MyBook2/Programming/Firebase/AdMob;
both fields get the same paths.
- Finally:
remove Main.cpp as a compile target in Projucer. Add a file that ends in .mm to Projucer and set that as the Compile target.
Inside that .mm file, add this:
#pragma once
#import "Firebase.h"
#include "Main.cpp"
Firebase.h
needs to be added to ProJucer via “Add Existing File”. it’s in the main Firebase Directory.
- now, inside
initialise()
in Main.cpp, and every other file in the project (because they all end up being included inside Main.cpp) you can write Objective C.
#include "../JuceLibraryCode/JuceHeader.h"
#include "MainComponent.h"
//Google's test ID for admob
NSString *adID = @"ca-app-pub-3940256099942544/4411468910";
//==============================================================================
class FirebaseAdMobApplication : public JUCEApplication
{
public:
//==============================================================================
FirebaseAdMobApplication() {}
const String getApplicationName() override { return ProjectInfo::projectName; }
const String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override { return true; }
//==============================================================================
void initialise (const String& commandLine) override
{
// This method is where you should put your application's initialisation code..
[GADMobileAds configureWithApplicationID:adID];
mainWindow = new MainWindow (getApplicationName());
}
and you’re off and running!
I think JUCE for IOS and Android would be way more popular as a development platform if it was much easier to monetize via Ads for the developers. I’ve been asking a lot of questions in the IOS Developers slack server, and although there are ~20K iOS developers on that server, practically none of them have heard of JUCE for iOS development.
So, let’s get the discussion going, and see if we can bring some ad revenue to the iOS side of JUCE for all the folks writing cool AUv3 plugins and iOS Audio Apps!