FirebaseUI crashes when attempting to show auth picker - ios

I'm using Firebase and FirebaseUI in my project, and on a regular basis I'm presented with the same crash when trying to log in. The user taps the Log in button and then the authentication picker is supposed to be shown, from where the user can log in with either Facebook/Google or email/password. What happens, though, is that it crashes with no error message whatsoever except for marking the following line:
struct FIRAuthLogin {
private let authUI = FUIAuth.defaultAuthUI()
private var viewController: UIViewController!
init(delegate: FIRCustomAuthDelegate, viewController: UIViewController) {
self.viewController = viewController
authUI?.delegate = delegate
authUI?.providers = [FUIGoogleAuth(), FUIFacebookAuth()]
}
func present(completion: #escaping () -> Void) {
// Exception on the line below!
let authViewController = authUI?.authViewController()
self.viewController.present(authViewController!, animated: true, completion: completion)
}
}
Even though there is an exception in the line let authViewController = authUI?.authViewController(), authViewController is not nil.
Below is an image from the stack trace (in the issue navigator):
The problem is that I'm only overriding the FUIPasswordSignUpViewController, so I'm a bit confused.
Whenever this happens, I usually just remove CocoaPods from my project and integrates it again. Then it would work correctly, but as I've done this multiple times now, and the error persist, there must an underlying error. Unfortunately, I haven't been able to reproduce the error with the FirebaseUI GitHub code, so I'm guessing the error is on my end. That's why I'm asking here instead of in the FirebaseUI-iOS GitHub repository.

It's finally fixed. I opened an issue in the FirebaseUI iOS repository, and after sending my project to one of the Google engineers, he solved it:
Looks like you're running into CocoaPods/CocoaPods#6936. Setting the build system to use the standard (not the new build system preview), deleting DerivedData, and rebuilding fixes the issue.
For the time being you'll have to not use the new build system.

Related

Xcode: Is there a difference between a framework and a pod in the project?

I'm just getting started with Xcode and iOS development. I am supposed to reproduce an iOS project on a tvOS.
One of the frameworks is JSQCoreDataKit
In the original iOS project, this framework exists in two places:
PODS:.
FRAMEWORKS.
I installed the framework following the manual instructions in this link.
So in the new project, it is installed as a normal framework:
.
The problem I have faced is : Some of the code that works in the original project, relies on a code that is defined in the PODS folder:
EXAMPLE:
func saveChanges() {
stack.mainContext.performAndWait {
saveContext(self.stack.mainContext)
}
}
saveContext function exists in:
And this is its definition(just in case):
public func saveContext(_ context: NSManagedObjectContext, wait: Bool = true, completion: ((SaveResult) -> Void)? = nil) {
let block = {
guard context.hasChanges else { return }
do {
try context.save()
completion?(.success)
}
catch {
completion?(.failure(error as NSError))
}
}
wait ? context.performAndWait(block) : context.perform(block)
}
So while in the original project where Pods exists, this works fine.
In the new project, where it doesn't exist, and the framework is installed manually, I get this error:
Use of unresolved identifier 'saveContext'
But, the framework gets imported successfully with no errors :
import JSQCoreDataKit
One last thing, adding the framework with the manual method described in this link doesn't make it appear in here:
Hii i also had the same issue which i solved !!
So Framework and pod is different.
Pod = Library
When to use them ??
1.Framework - Use it When you want to Hide the logic in the Code.
Mostly used in Banking Frameworks.
In framework no files and folders are visible everything is hidden.
2.Pod - Mostly used so that you can share your code and people can also see it and edit it.Files and Folder Structure is also visible.
Just go to youtube and search for
How to create framework.
How to create Library.
Youwill get it.
Hope you get it!

Flutter iOS module can't access new Swift file and print not working

I am working in a Flutter app and need to call native iOS code from it. I added a new Swift file to the iOS module in the app but it can't access it from AppDelegate. I also tried to print some log statements, but print is not working.
Every time I try to access the new file from AppDelegate, it gives me this error:
use of unresolved identifier 'NewFile'
The AppDelegate didFinishLaunchingWithOptions method looks like this:
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
let testChannel = FlutterMethodChannel(name: "com.test.example/example",
binaryMessenger: controller.binaryMessenger)
testChannel.setMethodCallHandler({
[weak self] (call: FlutterMethodCall, result: #escaping FlutterResult) -> Void in
guard call.method == "testExample" else {
print("can't call testExample method")
result(FlutterMethodNotImplemented)
return
}
print("can call testExample method")
NewFile() //This is the new file I am trying to access
result(10) //10 is just for testing
})
Why it doesn't access the NewFile.swift created in the same directory as the AppDelegate? Also why the print statement doesn't log anything to the console?
I am using Visual Studio Code.
Should I add configuration or linking to allow Visual studio code to access me file and also log my print statements?
It seems that adding new files to the iOS module should be done from Xcode not from Visual Studio Code. When I added new files from Xcode it could access it easily.
It also seems that log statements in iOS works only on Xcode.

Accidentally overriding getter with swift extension - Only during runtime when app enters foreground again

The last 2 days i brooded over a strange behavior i found in my iOS app. It was one of these moments when you start to have doubts about everything. I found the problem and fixed it. But i want to write this here to search for answers and gain knowledge about the system behind.
I am the developer of "Controller for HomeKit", an app to control HomeKit devices. In HomeKit you have HMActionSets to execute many changes at once. E.g. Turn on all lights.
Executing HMActionSet is a basic functionality and worked always. Here with a swipe of UITableViewCell.
let performAction = UIContextualAction(style: .normal, title: AppStrings.Actions.perform, handler: { (ac: UIContextualAction, view: UIView, success: #escaping (Bool) -> Void) in
self.home?.executeActionSet(selectedActionSet, completionHandler: { (error: Error?) in
if let err = error {
UIApplication.printToConsole(text: err)
success(false)
return
}
success(true)
})
})
BUT suddenly it stopped working flawlessly with a new development version. It took me a while to reproduce the situation, when it wasn't executing the action set.
Every time i start the app from scratch, everything works.
If i execute the HMActionSet right after navigating from the previous UIViewController, everything works. (Most common use case)
It stops working when being in the view, press the home button, reentering the app. After that all executions won't work, until going one view backwards and forward again.
Console logs this error:
Error Domain=HMErrorDomain Code=2 "Object not found." UserInfo={NSLocalizedDescription=Object not found.}
I walked backwards every commit until the problem was solved. After digging in the dark in a too big commit, i found the root cause.
But why am i not getting compile errors? Why does going to the home screen breaks it?
For a new feature i needed a new way to identify a HomeKit object on multiple devices, because the .uniqueIdentifier parameter is salted on every device.
import Foundation
import HomeKit
protocol Identifyable {
func getUniqueIdentifier() -> String?
}
extension HMActionSet: Identifyable {
func getUniqueIdentifier() -> String? {
return self.name.toBase64()
}
}
I created a swift protocol and made an extension to HMActionSet. Of course now that i found the error it looks stupid, to name the method like a getter. But this should not be the discussion now. It seems like this methods overrides the attribute of HMActionSet. When executing the actionSet internal functions accidentally use the wrong uniqueIdentifier, therefore the error is correct. (No object found).
/*!
* #brief A unique identifier for the action set.
*/
#available(iOS 9.0, *)
open var uniqueIdentifier: UUID { get }
If i name the method func uniqueIdentifier() -> String? Xcode immediately shows me a warning.
Method 'uniqueIdentifier()' with Objective-C selector 'uniqueIdentifier' conflicts with getter for 'uniqueIdentifier' with the same Objective-C selector
As i know HomeKit is written in Objective-C. I am using swift 4.
My questions to you:
Why are there no compiler errors (getUniqueIdentifier())?
If its a runtime problem mixing a swift extension into a objective-c framework, why does it only occur when reentering the app and not at the first start or later?
Looking forward to read your explanations about the problem that stole my sleep. :)

Swift 4 Error Running Code in Extension

I'm trying to upgrade my iMessage App to Swift 4. This section of example code worked perfectly in Swift 3 but gives errors when trying to move to Swift 4. The code below is in a class where the file is part of the main app target as well as the iMessage app.
#if IN_EXTENSION
// Do nothing since it's running in iMessage Extension
print("In extension")
#else
let helper = Helper()
helper.test()
UIApplication.shared.shortcutItems = []
let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)
let testViewController : UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "Test") as UIViewController
UIApplication.shared.keyWindow?.rootViewController = testViewController
#endif
It gives errors such as shared is unavailable. Which makes total sense since it's not available in iMessage Apps.
How this worked previously is in Other Swift Flags I added -DIN_EXTENSION to the iMessage app extension but not the main app.
There are a lot of similarities between my iMessage App and main app. So I want to keep my code clean and not repeat code. So this should be possible.
I'm not sure why after converting to Swift 4 all the sudden it's throwing errors.
Any ideas on how to fix?
For some reason after rebuilding my app just now this error went away and it gave me completely different errors. After solving those this error completely went away. Seems like a bug with Xcode or something.

error when using parse functions outside of the app delegate

Using Xcode 6 beta 6 to set up my app with parse.com. I followed the instructions listed here and got the framework imported into my app and added the bridged header etc. I then added my app keys into my app delegate
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
// Override point for customization after application launch.
Parse.setApplicationId("app key here", clientKey: "client key here")
var testObject = PFObject(className: "test")
testObject["foo"] = "bar"
testObject.saveInBackground()
return true
}
and that worked fine. I verified the test object was created in the data browser and thought I was set. then I started working on implementing logon into my app. in my first view controller I create a current user variable and my app crashes with the following error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You have to call setApplicationId:clientKey: on Parse to configure Parse.'
Well I did set it, and it works in my app delegate, but for some reason, any parse code outside the app delegate causes this crash. I even pasted the test code again in my view controller and it doesnt even autocomplete anything after the first line of parse related code
class HomeViewController: UITableViewController {
var testObject = PFObject(className: "test")
//this line after the first has a "expected expression error" and no parse methods get autocompleted
testObject["foo"] = "bar"
testObject.saveInBackground()
has anyone else had this problem? is it a problem with xcode 6?
While working on another app I realized what I had done when I had this problem. I was trying to initialize a property to store the current user, but I was doing it outside of view did load so it must have been getting called before the app delegate call to configure parse even ran. After initializing it inside of viewDidLoad instead of when declaring the property it worked fine.

Resources