无法连接到服务器 – 迁移分析服务器iOS

我正在学习以下教程: https ://www.raywenderlich.com/128313/parse-server-tutorial,我已经成功完成了将数据迁移到mLab以及设置分析服务器的步骤。

我运行这个curl命令

$ curl -X GET \ -H "X-Parse-Application-Id: <myAppId>" \ -H "Content-Type: application/json" \ -d '{}' \ http://localhost:1337/parse/classes/_User 

它返回我的所有用户的JSON。 这一步之后,教程说运行应用程序并发布一些数据。 但是,这是我卡住,我试图login时,得到以下错误代码, [Error]: Could not connect to the server. (Code: 100, Version: 1.12.0) [Error]: Could not connect to the server. (Code: 100, Version: 1.12.0) 。 我按照教程中的指示configuration了我的应用程序密钥和服务器url。

  let configuration = ParseClientConfiguration { $0.applicationId = "YOUR_APP_ID" $0.clientKey = "" $0.server = "http://localhost:1337/parse" } Parse.initializeWithConfiguration(configuration) 

在启动你的分析服务器之前设置env var VERBOSE = 1,看看你的curl请求和ios sdk有什么不同。

一旦请求收到,parse-server将显示请求的日志。 如果您在ios-app发送请求后没有看到任何日志。 检查你的ios应用程序serverUrl是否正确。

你的ios应用程序的serverUrl不应该是本地主机。 本地主机是指你的设备,而不是主机分析服务器。 您应该将其更改为IP(127.0.0.1除外)或承载分析服务器的域名。 如果您的手机和服务器连接到相同的WiFi,则可以使用192.168.xx(ifconfig)进行连接。