Swift 2.0 and Google Analytics: Use of unresolved identifier "GAI" - ios

I tried with CocoaPods and wound up with this issue after trying for hours and figured it was CocoaPods. Uninstalled CocoaPods and installed the SDK manually and wound up with the same issue.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
GAI.sharedInstance().trackerWithTrackingId("UA-XXXX-Y");
return true
}
This results in the error Use of unresolved identifier "GAI". I have a bridging header that imports the appropriate header files and all the required libraries included in my Build Phases. Please help!

Apparently I just needed to clear my derived data and restart Xcode. Xcode sucks sometimes. Ha. Thank you Björn Ro.

Related

FirebaseApp.configuration() unresolved identifier

I'm creating a social app (out of personal interest) using Xcode on my macOS Catalina 10.15.6 and facing tons of config issues before really doing something.
I'm stuck in this swift compiler error for 2 days already: Use of unresolved identifier 'FirebaseApp'
I've updated Ruby successfully.
I followed the instructions on the firebase official website
import UIKit
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
}
I've met bumps all along after executing "pod init" in Terminal. This was solved after I updated Ruby. I've got some help from Stack Overflow posts but couldn't find the one that solve my problem.
I have found the official documentation regarding the setup misleading. Therefore I use import FirebaseCore when implementing FirebaseApp.configure() and not as suggested import Firebase.

NSException when using Firebase

I followed all the steps correctly to install Firebase to my iOS App and it still doesn't work. In the application method, I added FIRApp.configure() like so:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
return true
}
And I keep receiving NSException errors. Firebase seems to work on my Android Project, what's the deal with iOS?
I believe this is some sort of Swift 3 issue, because I encountered a similar problem. After looking over the internet, I believe that Firebase 3 hasn't updated to recent Swift Syntax located in Swift 3. Many other developers are having trouble with it as well. As an alternative, you could switch back from Xcode 8 and into 7, which would allow you to create your application which will work with current IOS, and when Firebase updates, it will be easy for you to migrate to Swift 3.
Hope this helps,
Morgan Gallant

App Crashes on AppDelegate Class Declaration with EXC_BAD_ACCESS CODE 1 on iOS 9.1/9.2

I installed XCode 7.1 and 7.2 to update my app for iOS 9.1 and 9.2 respectively, but each time I run the app on simulators or devices the app crashes on the AppDelegate's class declaration as shown below. However, I have also XCode 7.0 and when I run my app on iOS 9.0 it works fine without any issue !.
The problem even if I compile the app for iOS 9.0 it would crashes on any device running iOS 9.1 or 9.2, I tried to change the initial view controller to be a simple plain one but it seems that it never reaches the point of loading view controllers and never reaches the beginning of func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool.
It seems that Apple did something with iOS 9.1 & 9.2. The app is written in swift, I enabled NSZombie and breakpoints to catch exceptions but I get no clue from the logs.
Debug Navigator:-
AppDelegate Class Declaration
That happens to me almost every time in new versions of Xcode/Swift/iOS. When I have had this problem I have erased that line and written it again.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
This happens when you have not set you variable types correctly. Check how you declare them. In my case i was trying to access a Bool as UIColor.
I've generally had this happen when there is a storyboard problem. For example, an error in:
storyboard.instantiateController(withIdentifier: "FooView")
Try putting breakpoints around controllers that are being loaded around where you are crashing to see if that's the problem.

App crashes ONLY when connected to XCode

My Swift app only seems to crash with EXC_BAD_ACCESS when my app is connected to XCode and I'm debugging. If I unplug my device and then run the app, it works flawlessly.
The app crashes at:
class AppDelegate: UIResponder, UIApplicationDelegate {
I'm pulling my hair out trying to solve this.
It's probably not a crash. More likely you have an Exception breakpoint and you're hitting it.
Try to replace your function with below one:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {}
or
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]!) -> Bool {}
That could be a pointer deallocating issue in the memory. That would be great if you can post more details about the error/crash info that you got, so that we can help you better. There are some solutions that you can try from this existing post, which was the similar problem(EXC_BAD_ACCESS) as you have: http://loufranco.com/blog/understanding-exc_bad_access
After a fiddling with the initial view controller I found that it only happened on the controller where my GMSMapView was. As it turns out, another user was having a similar problem here.
It turns out upgrading to iOS 8.4 solved the issue immediately. While I didn't use Dave's brilliant work around, I still give all the props and kudos to him!
Thank you everyone for sticking with me during this dark time in my life.

how to integrate flurry in ios using swift language

I want to integrate flurry in ios using swift language.
I added the flurry sdk's two files : flurrylib.a and flurry.h and then entered my api key in project TestProject4-Bridging-Header.h
#import "Flurry.h"
I had the same issue and adding a bridging header worked for me. Here are the steps I followed.
Note: If you already have a bridging file, skip the steps 2 to 4
I dragged the Flurry folder to my Swift iOS project in XCode.
I created a bridging header file by creating a new Objective-C header file (in XCode menu it's File/New/File/iOS/Source/Header File)
I called the file name "PROJECTNAME-Bridging-Header.h" (replace PROJECTNAME with your XCode project name)
In Project Build Settings, I searched for "Swift Compile - Code Generation" and there in "Objective-C Bridging Header" I entered the name of my new bridging file (PROJECTNAME-Bridging-Header.h) for debug and release values.
Now, back in my bridging header file, I referenced the Flurry header file.
#import "Flurry.h"
In my AppDelegate.swift file, I could then call the Flurry methods using Swift:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// setup Flurry
Flurry.startSession(flurryKey) // replace flurryKey with your own key
Flurry.setCrashReportingEnabled(true) // records app crashing in Flurry
Flurry.logEvent("Start Application") // Example of even logging
Hope it helps someone.
Flurry Integration using Pods in Swift
You need to import Flurry SDK as Follows
import Flurry_iOS_SDK
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Flurry.startSession("YOUR_API_KEY")
Flurry.logEvent("Started Application")
}
If you are attempting to log events in the 'didFinishLaunchingWithOptions' using Flurry SDK 6.0.0, this is not possible due to a bug in that version of the SDK. It is possible to start a session from this function however. I was told this information by a Flurry support rep, and confirmed it in my own testing.
You need to add a bridging header to your project. In that bridging header you import what you need in Swift and then you don't need to import it anywhere else.
The iBook on using Swift and Obj-C alongside has a very good explanation on this.
Actually, there is an explanation on Apple's Swift blog that says:
To be safe, all components of your app should be built with the same version of Xcode and the Swift compiler to ensure that they work together.
You can find more information here.

Resources