我使用的是Swift 4.0和Xcode 11.1而且我得到了一个" Safari无法打开该页面,因为它无法与服务器建立安全连接。一旦我点击了我在文档的帮助下创建的Facebook登录按钮。我通过在PodFile中添加以下内容从Facebook导入Swift SDK:
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'
在我完成pod install
和pod update
之后,我只能使用框架警告进行编译,例如语义问题,而这些问题我并不感到与此问题相关。我得到的一个警告是告诉我:Warning: The Copy Bundle Resources build phase contains this target's Info.plist file 'Project_Name_Here/Info.plist'.
虽然我不确定它是否与问题有关。
这是我的AppDelegate.swift
:
import FacebookLogin
import FacebookCore
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
// Override point for customization after application launch.
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return SDKApplicationDelegate.shared.application(app, open: url, options: options)
}
...
这是我的ViewController.swift
文件:
import FacebookCore
import FacebookLogin
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let loginButton = LoginButton(readPermissions: [.email])
loginButton.center = view.center
view.addSubview(loginButton)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
以下是我在点击按钮之前在控制台中收到的消息(以及应用程序运行后没有任何错误):
2017-11-12 01:45:32.501025-0600 Project_Name_Here[50388:41598259] Falling back to loading access token from NSUserDefaults because of simulator bug
2017-11-12 01:45:32.501301-0600 Project_Name_Here[50388:41598259] Falling back to storing access token in NSUserDefaults because of simulator bug
2017-11-12 01:45:32.501791-0600 Project_Name_Here[50388:41598259] Falling back to loading access token from NSUserDefaults because of simulator bug
2017-11-12 01:45:32.502636-0600 Project_Name_Here[50388:41598259] Falling back to storing access token in NSUserDefaults because of simulator bug
2017-11-12 01:45:32.504182-0600 Project_Name_Here[50388:41598259] Falling back to loading access token from NSUserDefaults because of simulator bug
2017-11-12 01:45:32.504688-0600 Project_Name_Here[50388:41598259] Falling back to storing access token in NSUserDefaults because of simulator bug
2017-11-12 01:45:32.740935-0600 Project_Name_Here[50388:41598259] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/np/Library/Developer/CoreSimulator/Devices/DBE38B81-E28F-485E-B967-A76E1D2B019C/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-11-12 01:45:32.743511-0600 Project_Name_Here[50388:41598259] [MC] Reading from private effective user settings.
2017-11-12 01:45:32.751346-0600 Project_Name_Here[50388:41598259] Could not successfully update network info during initialization.
2017-11-12 01:45:33.146213-0600 Project_Name_Here[50388:41598380] TIC Read Status [1:0x0]: 1:57
2017-11-12 01:45:33.146353-0600 Project_Name_Here[50388:41598380] TIC Read Status [1:0x0]: 1:57
我在更新到Xcode 9.1后得到了模拟器错误,因为我认为这可能会解决问题,但它只是让它变得更糟。单击“登录到Facebook”按钮后出现的错误是:
2017-11-12 01:45:43.550223-0600 Project_Name_Here[50388:41598259] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
2017-11-12 01:45:43.551413-0600 Project_Name_Here[50388:41598259] Falling back to storing access token in NSUserDefaults because of simulator bug
2017-11-12 01:45:43.553518-0600 Project_Name_Here[50388:41598259] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
2017-11-12 01:45:45.850963-0600 Project_Name_Here[50388:41598259] [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction
2017-11-12 01:45:45.942460-0600 Project_Name_Here[50388:41598369] TIC Read Status [2:0x0]: 1:57
2017-11-12 01:45:45.944297-0600 Project_Name_Here[50388:41598369] TIC Read Status [2:0x0]: 1:57
我已尝试使用Google搜索各个错误,但所有人都说要在info.plist文件中输入正确的凭据,但我已经完成了这个并且它没有修复任何内容。 TIC消息与TCP / IP连接有关,但我还没有搞乱任何选项,因为我只是按照关于获得Facebook SDK设置和工作的基本教程。
感谢任何帮助,谢谢。
答案 0 :(得分:0)
您是否在info.plist中添加了此内容
<key>FacebookAppID</key>
<string>FB_APP_ID</string>
<key>FacebookDisplayName</key>
<string>APPLICATION_NAME</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
答案 1 :(得分:0)
这是一个愚蠢但令人不安的问题,我有一周的同样问题。终于找到了来自不同论坛的解决方案:
“我发现Avast的”网络屏蔽“导致问题。要禁用它,请打开Avast,然后打开首选项&gt;网络屏蔽&gt;禁用。当您不使用模拟器时,您可以再次启用它。我有不知道它是如何随机开启的,因为这个问题刚刚开始无处不在。“
)