Skip to content

Instantly share code, notes, and snippets.

@quangDecember
Created March 21, 2019 12:01
Show Gist options
  • Save quangDecember/27de893de13fb967dfb2975973d78bab to your computer and use it in GitHub Desktop.
Save quangDecember/27de893de13fb967dfb2975973d78bab to your computer and use it in GitHub Desktop.
iOS SDK Modularization: A survey

iOS SDK modularization: a survey

SDK in the survey:

  • Fabric Crashlytics
  • Firebase
  • Facebook SDK: Swift & Objective-C

Fabric Crashlytics

Crashlytics is a crash reporting library for mobile apps, a close-sourced binary framework.

Modules required: Fabric.framework, Crashlytics.framework

Keys are required to be put in Info.plist file to be shared among modules

Fabrice framework is responsible/required for initialize chilren framework Crashlytics:

Fabric.with([Crashlytics.self])

others feature included in Fabric framework

/**
 *  This BOOL enables or disables debug logging, such as kit version information. The default value is NO.
 */
@property (nonatomic, assign) BOOL debug;

References: Integration guide,

Google Firebase

Firebase requires developer to add a config file (plist file on iOS and json file on Android), which contains server keys and configurations. Any changes on the Firebase dashboard requires re-downloading the config file. Firebase is partly open source.

Besides, configure is required at the beginning to inititalize all the components

import Firebase
// Use Firebase library to configure APIs
FirebaseApp.configure()

A config file contains keys for all the services: ... Firebase Core contains many frameworks:

  • Firebase Core : initialization, logger level
  • Firebase Analytics: send tracking event to dashboard
  • Google Toolbox: GTMLogger, GTMLocalizedString,
  • Firebase Instance ID: token for Firebase Messaging,

...

Transition from Fabric Crashlytics to Firebase Crashlytics

Since Fabric team aquired by Google, developers can have a new way of integrate of Fabric:

  • add Firebase to your project (frameworks and Info.plist file)
  • configure Crashlytics on Firebase dashboard
  • adding Fabric, Crashlytics to your iOS project as usual.

Differences from integrating only Fabric Crashlytics

  • Keys of Crashlytics are included in Google-Info.plist file of Firebase
  • the post build script is only "${PODS_ROOT}/Fabric/run" , and not required adding the keys

Reference: Add Firebase to iOS project, Firebase Crashlytics,

Facebook SDK

Facebook SDK is open source, (don't mistake it with Facebook Audience network for advertising, which is not open source), a SDK to integrate Facebook service to your mobile app.

Core module: FBSDKCoreKit Children modules: FBSDKLoginKit, FBSDKShareKit

Facebook SDK doesn't requires server keys to initialize, but requires your bundle ID to match with the one you registed on Facebook Developer dashboard.

It is required in documentation that all App Delegate calls must be passed to Facebook SDK.

[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
    openURL:url
    sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
    annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
  ];
[FBSDKAppEvents activateApp];

Classes in Facebook Core: FBSDKAccessToken for managing user login token, AppEvent for application event that can be logged to Facebook Analytics, UserProfile represents an immutable Facebook profile.

Note: there are a lot of @testable import FacebookCore in Login and Share module to access user information and access token

References: Getting started, facebook-objc-sdk on GitHub, facebook-swift-sdk on GitHub

@adrianod1as
Copy link

Hi @quangDecember, thanks for the gist! o/
https://gist.github.com/quangDecember/27de893de13fb967dfb2975973d78bab#google-firebase
Do you know how to deal with Firebase Analytics and Crashlytics installation and its use on features modules on a modular project like this:
https://edit.theappbusiness.com/modular-ios-strangling-the-monolith-4a6843a28992
?

@quangDecember
Copy link
Author

Hi @quangDecember, thanks for the gist! o/
https://gist.github.com/quangDecember/27de893de13fb967dfb2975973d78bab#google-firebase
Do you know how to deal with Firebase Analytics and Crashlytics installation and its use on features modules on a modular project like this:
https://edit.theappbusiness.com/modular-ios-strangling-the-monolith-4a6843a28992
?

well I don't actually know how you plan to organize your project; but as Firebase/Crashlytics allow CocoaPods; it is normal for a pod or a framework (if your feature modules are those types) depends on another pod

@jamesyorke
Copy link

jamesyorke commented Apr 8, 2020

Hi @quangDecember, thanks for the gist! o/
https://gist.github.com/quangDecember/27de893de13fb967dfb2975973d78bab#google-firebase
Do you know how to deal with Firebase Analytics and Crashlytics installation and its use on features modules on a modular project like this:
https://edit.theappbusiness.com/modular-ios-strangling-the-monolith-4a6843a28992
?

Hi, I'm also wondering about this now. It seems like I need to import firebase in each Modules in the Podfile.

e.g.

target 'Application' do
    project './Application.xcodeproj'
   pod 'Firebase/Core'
end

target 'FirebaseModule' do
  inherit! :search_paths
  project './Utilities/FirebaseModule/FirebaseModule.xcodeproj'
  pod 'Firebase/Core'
end

target 'FeatureModule' do
  inherit! :search_paths
  project './Features/FeatureModule/FeatureModule.xcodeproj'
  pod 'Firebase/Core'
end

Then, when I start it up I get the following crash in the Firebase Pod. In the file FIRIInstallations.m

The default FirebaseApp instance must be configured before the defaultFirebaseApp instance can be initialized. One way to ensure that is to call [FIRApp configure]; (FirebaseApp.configure() in Swift) in the App Delegate's application:didFinishLaunchingWithOptions: (application(_:didFinishLaunchingWithOptions:) in Swift)."

I am called FirebaseApp.configure() in App Delegateapplication:didFinishLaunchingWithOptions: as instructed.

I just can't see how to get this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment