How to integrate Firebase C++ SDK into iOS JUCE app
Based on https://forum.juce.com/t/juce-firebase-admob-lets-monetize-our-juce-ios-apps-with-ads-partial-how-to/29369/5 and https://www.youtube.com/watch?v=vBaQaqaJjZ8
But due to changes in latest Firebase iOS SDK. Tutorial required some additional steps.
This tutorial will show how to setup Analytics and Crashlytics
Pre-requisites
https://github.com/firebase/firebase-ios-sdk/releases/tag/10.20.0
https://github.com/firebase/firebase-cpp-sdk/releases/tag/v11.8.0
Tested libraries: Analytics Crashlitics Push Notifications
- Download Firebase C++ SDK
- Download Firebase iOS Frameworks Zip ~1gb (https://firebase.google.com/docs/ios/setup)
- Build custom Projucer from Source.
New Firebase iOS SDK consists of .framework and .xcframework. Bundled Juce Projucer version has few issues with .xcframework.
So we have to make few changes to Xcode Exporter and build Projucer from Source.
jucer_ProjectExport_Xcode.h:
- Comment out line:
writeWorkspaceSettings();
(This will ensure that once we change build system in Xcode to NEW BUILD SYSTEM, it won't reset to Legacy on saving project. We have to use NEW BUILD system in XCode to use .xcframewoks) - Ignore addition of .framework extention to .xcframework paths
String addCustomFramework(String frameworkPath){
if (! frameworkPath.endsWithIgnoreCase (".framework") && !frameworkPath.endsWithIgnoreCase(".xcframework"))
frameworkPath << ".framework";
...
}
This will ensure that we will be able to specify extension in Extra Custom Frameworks field in Project (aka. path/FirebaseAnAlytics.xcframework) 3. Build Projucer and open Juce Project using it
Project Config:
- Setup Firebase project
- Download GoogleServices-Info.plist into Source folder and add to project ass 'Xcode Resource'
- Edit GoogleServices-Info.plist: change
xml<key>IS_ANALYTICS_ENABLED</key>
totrue
- Add reference to Firebase.h to Sources
- Configure Xcode (iOS) exporter:
- Shared:
- Extra Compiler Flags:
-fno-aligned-allocation
- Extra Linker Flags:
$(OTHER_LDFLAGS) -ObjC -lsqlite3 -lz
- Custom PList:
<plist version="1.0"> <dict> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> </dict> </plist>
- Extra System Frameworks:
CoreMotion, MediaPlayer, AdSupport, MessageUI, CoreServices, CoreTelephony, Security, StoreKit, SystemConfiguration, UIKit, Foundation, CoreMedia, GLKit
- Frameworkds Search Path:
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics; /Users/home/Documents/git_projects/Firebase/FirebaseCrashlytics; /Users/home/Documents/git_projects/firebase_cpp_sdk/xcframeworks
- Extra Custom Frameworks:
- Extra Compiler Flags:
- Shared:
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics/FBLPromises.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics/FirebaseAnalytics.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics/FirebaseCore.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics/FirebaseCoreInternal.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics/FirebaseInstallations.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics/GoogleAppMeasurement.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics/GoogleAppMeasurementIdentitySupport.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics/GoogleUtilities.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics/nanopb.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseCrashlytics/FirebaseCoreExtension.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseCrashlytics/FirebaseCrashlytics.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseCrashlytics/FirebaseSessions.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseCrashlytics/PromisesSwift.xcframework
/Users/home/Documents/git_projects/firebase_cpp_sdk/xcframeworks/firebase_analytics.xcframework
/Users/home/Documents/git_projects/firebase_cpp_sdk/xcframeworks/firebase.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseMessaging/FirebaseMessaging.xcframework
/Users/home/Documents/git_projects/Firebase/FirebaseMessaging/GoogleDataTransport.xcframework
- Debug/Release
- Header Search Paths:
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics; /Users/home/Documents/git_projects/Firebase/FirebaseCrashlytics; /Users/home/Documents/git_projects/Firebase/FirebaseMessaging/FirebaseMessaging; /Users/home/Documents/git_projects/firebase_cpp_sdk/xcframeworks
- Extra Search Library Paths:
- Header Search Paths:
/Users/home/Documents/git_projects/Firebase/FirebaseAnalytics;
/Users/home/Documents/git_projects/Firebase/FirebaseMessaging;
/Users/home/Documents/git_projects/Firebase/FirebaseCrashlytics;
/Users/home/Documents/git_projects/firebase_cpp_sdk/xcframeworks
$(SDKROOT)/usr/lib/swift;
$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME);
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME);
4. Custom XCode Flags:
GCC_GENERATE_DEBUGGING_SYMBOLS=YES,
GCC_DEBUGGING_SYMBOLS = full,
DEBUG_INFORMATION_FORMAT=dwarf-with-dsym,
DWARF_DSYM_FILE_NAME = "$(TARGET_NAME).dSYM",
DWARF_DSYM_FOLDER_PATH = "$(CONFIGURATION_BUILD_DIR)/dSyms",
COPY_PHASE_STRIP=YES,
CONFIGURATION_BUILD_DIR="$(inherited)",
SWIFT_VERSION=5.0,
SWIFT_OPTIMIZATION_LEVEL="-Onone",
LD_VERIFY_BITCODE=NO,
LD_RUNPATH_SEARCH_PATHS=/usr/lib/swift,
ALWAYS_EMBED_SWIFT_STANDART_LIBRARIES=YES
- Export iOS project to XCode
- Under
Project->Build Options->Debug Information Format
change toDWARF with dSYM File
(we will need these files to upload to Firebase for de-obfuscating crash reports) - Build app and check Verify that app showed up in Analytics
/Users/home/Documents/git_projects/Firebase/FirebaseCrashlytics/upload-symbols -gsp /Users/home/JuceProjects/Pulsar-Projuser/Source/GoogleService-Info.plist -p ios "<path xcode archive>/dSyms/"
Few useful debug arguments for XCode Schemas (Arguments passed on Launch):
-FIRAnalyticsDebugEnabled
-FIRDebugEnabled
Links: Firebase C++ SDK Guide: https://firebase.google.com/docs/cpp/setup?platform=ios Firebase Setup without Cocaposds: https://firebase.google.com/docs/ios/setup