简体   繁体   English

在测试xcode应用程序时,如何让我的iphone连接到我的Mac上的本地Xampp服务器

[英]How do I get my iphone to connect to local Xampp server on my mac while testing an xcode app

I am doing a Ray Wenderlich tutorial how to make an app like "Instagram". 我正在做Ray Wenderlich教程如何制作像“Instagram”这样的应用程序。 It's my first time setting up a database. 这是我第一次建立数据库。 I am using Xampp and hosting on my mac. 我在我的Mac上使用Xampp并托管。

I CAN get the app to run with the xcode simulator and I can log in and it works with the server. 我可以让应用程序与xcode模拟器一起运行,我可以登录,它可以与服务器一起使用。 However when I run my iphone device it runs the app but when I go to login through the app it says "Could not connect to server". 但是,当我运行我的iphone设备时,它会运行应用程序,但是当我通过应用程序登录时,它会显示“无法连接到服务器”。

What am I missing? 我错过了什么? I think all my permissions are set to anybody etc... But again I'm totally new to using a database. 我认为我的所有权限都设置给任何人等等......但是我再次使用数据库是全新的。 It seems though that if the simulator can do it the phone should be able to. 似乎如果模拟器可以做到这一点,电话应该能够。 Also it's not a provisioning problem, that profile is valid and it wouldn't run on my app if it wasn't. 此外,它不是配置问题,该配置文件是有效的,如果不是,它将无法在我的应用程序上运行。 I just cant get to the database from the device. 我只是无法从设备进入数据库。

Any help would be awesome! 任何帮助都是极好的!

If the app isn't able to connect to the server, there might be an issue with the server address. 如果应用程序无法连接到服务器,则服务器地址可能存在问题。

When running on the simulator, you're still on your mac, so something like http://localhost/DATABASE_ALIAS is enough. 在模拟器上运行时,你仍然在你的mac上,所以像http://localhost/DATABASE_ALIAS就足够了。 But when running on a different device, that is no longer true. 但是当在不同的设备上运行时,这已不再适用。

To keep things simple, you should make sure the iPhone is connected to same network as your Mac and then replace localhost with either the Mac local IP or its Bonjour address, for instance: http://YOUR_MAC_NAME.local/DATABASE_ALIAS. 为简单起见,您应确保iPhone连接到与Mac相同的网络,然后将localhost替换为Mac本地IP或其Bonjour地址,例如: http://YOUR_MAC_NAME.local/DATABASE_ALIAS.

To find out the Bonjour address, open System Settings and find the machine name under Sharing. 要查找Bonjour地址,请打开“系统设置”,然后在“共享”下找到计算机名称。 As an example, if it is called "Herbie MacBook", the address would be "Herbie-MacBook.local". 例如,如果它被称为“Herbie MacBook”,地址将是“Herbie-MacBook.local”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在无法连接到Mac的iPhone上启动ios应用 - How to launch an ios app on an iphone that I cannot connect to my mac 如何将 iphone 连接到在 mac 上运行的本地服务器? - How to connect iphone to a local server running on mac? 将iPhone连接到本地服务器以在XCode上进行测试? —不使用WiFi - Connect iPhone to local server for testing on XCode? — without using WiFi 如何在iPhone上获取ios浏览器以查看本地服务器上的网页以进行测试? - how to get ios browser on iphone to view web pages on my local server for testing? 如何使用本地WIFI连接将iPhone应用程序(其余)连接到XAMPP? - How to connect an iPhone app (rest) to XAMPP using a local WIFI connection? 如何让我的iPhone应用程序以横向模式启动? - How do I get my iPhone app to start in Landscape mode? 如何在Mac OS上从iPhone连接到本地主机 - how to connect from my iphone to my localhost on my mac os 当我为我的iPhone应用程序寻找特定的iPhone功能时,如何知道在Xcode文档中寻找什么类或框架? - When I'm looking for a particular iPhone feature for my iPhone app, how do I know what class or framework to look for in Xcode documentation? 为什么我的物理iPhone没有在xcode中显示以测试应用程序? - Why my physical iPhone not showing in xcode for testing an app? 如何让我的 AVPlayer 在应用程序处于后台时播放? - How do I get my AVPlayer to play while app is in background?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM