1

I started learning Xcode and Swift just several days ago, and today I wanted to create a Facebook Login for a new app.

So I followed this video guide on youtube: https://www.youtube.com/watch?v=MNfrBdyEvmY

and everything worked fine, except at the last step when I click the login button on simulator nothing shows up.

[login page screenshot][1]

Then I went back to Xcode and found these two errors:

  1. (before I click the button)

2016-12-02 16:12:54.008 f2f_sample[1805:113503] Falling back to loading access token from NSUserDefaults because of simulator bug 2016-12-02 16:12:54.008 f2f_sample[1805:113503] Falling back to storing access token in NSUserDefaults because of simulator bug 2016-12-02 16:12:54.009 f2f_sample[1805:113503] Falling back to loading access token from NSUserDefaults because of simulator bug 2016-12-02 16:12:54.009 f2f_sample[1805:113503] Falling back to storing access token in NSUserDefaults because of simulator bug 2016-12-02 16:12:54.009 f2f_sample[1805:113503] Falling back to loading access token from NSUserDefaults because of simulator bug 2016-12-02 16:12:54.010 f2f_sample[1805:113503] Falling back to storing access token in NSUserDefaults because of simulator bug 2016-12-02 16:12:54.011065 f2f_sample[1805:113559] [] nw_host_stats_add_src recv too small, received 24, expected 28 2016-12-02 16:12:54.016238 f2f_sample[1805:113559] [] ____nwlog_simulate_crash_inner_block_invoke dlopen CrashReporterSupport failed 2016-12-02 16:12:54.016593 f2f_sample[1805:113559] [] __nwlog_err_simulate_crash simulate crash failed "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available" 2016-12-02 16:12:54.017905 f2f_sample[1805:113559] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace: [x86_64] libnetcore-856.20.4 0 libsystem_network.dylib 0x000000010998f682 __nw_create_backtrace_string + 123 1 libnetwork.dylib 0x0000000109c6c932 nw_socket_add_input_handler + 3100 2 libnetwork.dylib 0x0000000109c4a4f4 nw_endpoint_flow_attach_protocols + 3768 3 libnetwork.dylib 0x0000000109c49511 nw_endpoint_flow_setup_socket + 563 4 libnetwork.dylib 0x0000000109c48270 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612 5 libnetwork.dylib 0x0000000109c6344d nw_endpoint_handler_path_change + 1261 6 libnetwork.dylib 0x0000000109c62e7c nw_endpoint_handler_start + 570 7 libnetwork.dylib 0x0000000109c7aae5 nw_endpoint_resolver_start_next_child + 2240 8 libdispatch.dylib 0x000000010970c980 _dispatch_call_block_and_release + 12 9 libdispatch.dylib 0x00000001097360cd _dispatch_client_callout + 8 10 libdispatch.dylib 0x0000000109713e6b _dispatch_queue_serial_drain + 236 11 libdispatch.dylib 0x0000000109714b9f _dispatch_queue_invoke + 1073 12 libdispatch.dylib 0x00000001097173b7 _dispatch_root_queue_drain + 720 13 libdispatch.dylib 0x000000010971708b _dispatch_worker_thread3 + 123 14 libsystem_pthread.dylib 0x0000000109adf4de _pthread_wqthread + 1129 15 libsystem_pthread.dylib 0x0000000109add341 start_wqthread + 13

  1. (after I click the button)

2016-12-02 16:13:59.084 f2f_sample[1805:113503] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" 2016-12-02 16:13:59.085 f2f_sample[1805:113503] Falling back to storing access token in NSUserDefaults because of simulator bug 2016-12-02 16:13:59.089 f2f_sample[1805:113503] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

I looked at other threads too but none of them seems to match my situation. I have no idea what I did wrong and I'm simply stuck here..

Below are my codes: 1. AppDelegate.swift:

//
//  AppDelegate.swift
//  f2f_sample
//
//  Created by victor on 12/2/16.
//  Copyright © 2016 F2F. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {


    var window: UIWindow?



    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.


        FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
        return true
    }
    func application(_ application:UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance().application(application, open: url as URL!, sourceApplication: sourceApplication, annotation: annotation)
    }


    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {


   // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

}

  1. import UIKit

    class ViewController: UIViewController {

    let loginButton: FBSDKLoginButton = {
        let button = FBSDKLoginButton()
        button.readPermissions = ["email"]
        return button
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
    
        view.addSubview(loginButton)
        loginButton.center = view.center
    
    
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

}

  1. info.plist:

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb{131875597297624}</string>
            </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>{131875597297624}</string>
    <key>FacebookDisplayName</key>
    <string>{f2f_sample}</string>
    
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
    </array>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>{human-readable reason for photo access}</string>
    <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>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    

Any help is appreciated!

Vic
  • 55
  • 7

0 Answers0