Search code examples
iosfacebookfacebook-sdk-3.0

Failed to get remote view controller with error: Error: domain=_UIViewServiceInterfaceErrorDomain, code=2


I have a really frustrating error. I'm 3 months into iOS development. I've been logging into facebook and then connecting up to Firebase. I implemented that right at the start. It works perfectly, todays the day I wake up to put the app on the store... and the Facebook login doesn't work.

Absolutely nothing has changed in my code for logging into Facebook(I'm almost certain but I've checked everything!) What happens is you will click the facebook login button and it will be nothing but white (where normally there would be an internet browser). The error I get is:

[ViewService] Failed to get remote view controller with error: Error: domain=_UIViewServiceInterfaceErrorDomain, code=2

I have changed absolutely non of the code. My bundleID and appID are the same as in the facebook developer.

I have absolutely no idea what it is and the very few people that have a similar problem don't seem to either. I'd like to understand but just being able to work around it and it not occur in the future would be really great! I am coding in swift but i'm not using the swiftSDK like in the Facebook docs, instead i'm using the FBSDKLoginButton.

Also I have tried this on a simulator and it doesn't happen. It only happens on my phone.

I'm really not sure what is helpful information so I'm sorry if I include something not relevant.

I'm using facebook sdk 4.20.2

This is my info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>CeleBreak</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb1253394891414659</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>FacebookAppID</key>
    <string>1253394891414659</string>
    <key>FacebookDisplayName</key>
    <string>CelebreakApp</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbauth2</string>
    </array>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict/>
    </dict>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
</dict>
</plist>

This is my login VC:

class LoginVC: UIViewController: FBSDKLoginButtonDelegate {
@IBOutlet weak var loginButton: FBSDKLoginButton!

public var originVC: UIViewController = TabBarController()

override func viewDidLoad(){
    phoneNumberTextField.delegate = self
    loginButton.delegate = self
    phoneNumberTextField.keyboardType = UIKeyboardType.numberPad
}
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error?) {

}
func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
    fatalError("Logging out in Login View shouldn't happen")
}
}

Then the login button is just a FBSDKLoginButton. When I look through the Facebook docs it doesn't explain doing it this way, instead it explains doing it with a swift SDK but I followed a guide setting up Facebook this way and didn't really understand it.


Solution

  • Solution: clear data and history from Safari settings on your phone.

    Credit: https://stackoverflow.com/a/44457044/7442549

    I was have the same issue when thoroughly testing my login flow - logging in/out repeatedly, using the FB native app instead of Safari login, etc.

    I guess this is a weakness in the interactions between FB login / Safari.