Failed importing Facebook SDK in Swift 4.x - ios

I've tried to import Facebook SDK for App Events and tracking of App Installs through Facebook ADS and it's being impossible to do it.
I've done it with CocoaPods using:
pod 'FacebookCore'
as the Facebook official tutorial says.
After that, Facebook Analytics has detected me as a New unique user, so that is great šŸ‘.
The problem is when I try to add an APP Event like so:
AppEventsLogger.log("Opened App Main VC");
And then this ERROR šŸ”“ appears:
Use of unresolved identifier 'AppEventsLogger'
Apart from this, also it's not detecting AppEventsLogger in the AppDelegate with the same error:
AppEventsLogger.activate(application)
I've imported in the VC and in the AppDelegate this modules/libraries:
import FacebookCore //in theory is just this one
import FBSDKCoreKit
So any tip or help is very welcomed! šŸ˜Š

Two Imports
import FacebookCore
import FBSDKCoreKit
In AppDelegate
func applicationDidBecomeActive(_ application: UIApplication) {
AppEvents.activateApp()
}
When you want to log an event:
AppEvents.logEvent(AppEvents.Name.init(rawValue: "Opened App Main VC"))
For another type of AppEvents, you can refer to this

The problem is AppEventsLogger is changed to AppEvents. So change the name of AppEventsLogger and it will work fine. This is a new update in Facebook sdk.

Related

Adobe and Firebase Not working in AppDelegate at the same time

I implemented Adobe Lifecycle events and Firebase messaging feature in AppDelegate in two different projects.
But when I try to add adobe lifecycle code with firebase code and import the pods for Adobe Analytics (AEPCore ,AEPAnalytics ,AEPUserProfile, AEPIdentity, AEPLifecycle, AEPSignal,AEPServices ,ACPCore) then I get this error:
Cannot assign value of type 'AppDelegate' to type 'MessagingDelegate?'
Please help if someone faced this issue.
It worked when you write " extension AppDelegate: FirebaseMessaging.MessagingDelegate " instead of "extension AppDelegate: MessagingDelegate"

Implementing Firebase Analytics in a swift framework

i'm trying to configure Firebase Analytics with cocoapods in our app.
The app has an architecture like this:
App <- App-Framework
The app is basically just the AppDelegate importing App-Framework - which is the whole app.
Then to the problem, i'm doing this in AppDelegate:
FirebaseApp.configure()
After this i try to log an event to Analytics in the App-Framework with:
Analytics.logEvent("testEvent", parameters: [
"name": "Krister" as NSObject,
"full_text": "Krister tester" as NSObject
])
And the debugger then says:
Event not logged. Call +[FIRApp configure]: share_image
The framework and the app imports Firebase trough cocoapods and the general Firebase Analytics setup is not missing anything, like the GoogleServices.plist and imports.
I tried to implement this in an app with no framework and the events get logged to the Firebase Console and DebugView.
The weirdest thing is that the default screen tracking is getting
logged, but none of the logEvents().
What to do next?
Solution 1:
I ran the FirebaseApp.configure() inside App-Framework,
trough a method inside of AppDelegate.

Pinterest SDK: "PDKClient not found", what's wrong?

I'm trying to implement Pinterest SDK into my Swift project. I've followed this install guide: https://developers.pinterest.com/docs/sdks/ios/
I just can't get this line working:
PDKClient.configureSharedInstanceWithAppId("0000")
It keeps on resulting to Use of unresolved identifier PDKClient
What should I do?
You need to import the PinterestSDK in the class (I guess AppDelegate, right?).
So, at the top of AppDelegate, add
import PinterestSDK
Then it should find the PDKClient object.

Getting test valentin screen on app launch

I am getting a black test valentine screen on app launch.
I am using following libraries:
Google/SignIn
FBSDKLoginKit
FBSDKCoreKit
FBSDKShareKit
FBSDKMessengerShareKit
iOS-WebP
FLAnimatedImage
NMRangeSlider
LumberjackLauncher
GoogleAppIndexing
CSStickyHeaderFlowLayout
Fabric
Crashlytics
Google/Analytics
AdobeMobileSDK
MPCoachMarks
iCarousel
You Tube
Please tell me due to which library I am getting this issue
This screen is appear due to analytic SDK adobe omniture library.
In JSon configuration file, following JSon urls are written:
"remotes": {
"analytics.poi": "https://assets.adobedtm.com/b213090c5204bf94318f4ef0539a38b487d10368/scripts/satellite-568f7b6764746d25a900cb96.json",
"messages": "https://assets.adobedtm.com/b213090c5204bf94318f4ef0539a38b487d10368/scripts/satellite-568f7b6564746d5bd3006fc0.json"
}
In response of message url we are getting HTML text in payload module.
Just remove these URLs.

How do I force a crash in Swift iOS app with Fabric SDK?

All I can find is Is there a quick way to force a crash? which says to:
[[Crashlytics sharedInstance] crash];
which I think in Swift would be
Crashlytics.sharedInstance.crash()
but this does not seem to exist. (perhaps the docs are out of date and no longer apply since Fabric gobbled up Crashlytics?)
I see that there is a Crashlytics.crash(self:Crashlytics) ...nevermind, friggin XCode's completion is always broken for me. See answer below.
If you are using the new Firebase Crashlytics SDK note that import Crashlytics has been replaced by import FirebaseCrashlytics. The crash() method is no longer available in the new SDK. As recommended by Firebase, simply use:
Swift:
fatalError()
Obj C:
assert(NO);
(if it's in a file other than your AppDelegate, you will need to import Crashlytics, then just do Crashlytics.sharedInstance().crash()
Create a Project and App in firebase
Add a new iOS app in the firebase console if you have existing firebase project or create firebase project and create new app in the firebase console.
Add Firebase to iOS App
Firstly in step 1, register your app by adding the bundle identifier while creating iOS app to firebase. In step 2, Download config file GoogleService-Info.plist add it to your workspace like in the image shown below.
Add Crashlytics SDK via CocoaPods
To get started, add the Crashlytics SDK framework files to your project. For most projects, the easiest way to do that is by adding the Crashlytics CocoaPods.
pod 'Firebase/Core'
pod 'Fabric', '~> 1.7.2'
pod 'Crashlytics', '~> 3.9.3'
Test your implementation
Enable Crashlytics debug mode: In order to enable crashlytics in debug mode we need to set Fabric.sharedSDK().debug mode to true in AppDelegate.swift.
import UIKit
import Firebase
import Crashlytics
import Fabric
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Fabric.sharedSDK().debug = true
return true
}
Force crash to test implementation: While writing this article, I have one view controller with one button named (Click to crash app) in the middle of the viewController. For the testing purpose, when user click the button app crashed.
And View controller this below code and run once in simulator or device and check in Firebase dashboard .You find all crashes report.
import UIKit
import Crashlytics
class ViewController: UIViewController {
var name:String!
var number:Int!
override func viewDidLoad() {
super.viewDidLoad()
name = "12"
}
#IBAction func crashBtnAction(_ sender: Any) {
//creshreportMethod()
print("name of the value",name)
var myDict = [String:Any]()
myDict = ["name":number!]
print("my dict value",myDict)
}
}
Crashlytics canā€™t capture crashes if your build attaches a debugger at launch. Adjust your build settings to change the projectā€™s debug information format:
With your project still selected in the Xcode Navigator, open the Build Settings tab.
Click All at the top of the tab to display all build settings.
Search for ā€œdebug information formatā€.
Set the Debug Information Format setting to DWARF with dSYM File.

Resources