multipeer connectivity test on iphone and a simulator simultaneously - ios

Hello I was searching in all topics of the forum about how can i test an app which uses multipeer connectivity framework. Can someone tell me how can i test an app by using an iPhone device and a simulator simultaneously, player one for device and player two on the simulator and vice versa. I already test the app by using two simulators one per mac - user on a mac and its working but it is not convenient to continuously switch users to test an app.
I tried all the alternatives, running once in simulator and one on device at the same time,make second target, nothing happened.
Thanks in advance

If you put your iPhone and your Mac on the same WiFi network they should able to discover each other without any problem.

Yes you can test your app on Device an Simulator simultaneously.
I'm developing an app with Multipeer Connectivity right now and communication between
Iphone and Simulator works fine.
I'm running it on a MacBook Air.
All you have to do is to make sure, that Bluetooth is enabled on your Mac.
You can do this in System Preferences -> Bluetooth.

In addition to testing on WiFi, you can also test your app based on "Multipeer Connectivity framework" on simulator and any IOS device using Bluetooth, As long as simulator and devices are connected in same Personal area network.
For example, on Iphone you can turn on Personal Hotspot (in your phone General settings) to connect your phone with your mac in same personal area network via bluetooth or WiFi and then try testing your app sharing messages between simulator and Iphone using any personal network based on Bluetooth or WiFi.
All the combination will work as long as app using "Mutlipeer connectivity framework" are on same personal area network.

Related

Connect Iphone using Wireless not working

I recently updated to IOS 11 and Xcode 9. Am trying to explore the option of connecting my phone over wifi with xcode for development. My mac and IPhone are both connected to same wifi (corporate network). I have selected the option for connecting my iphone over a network but as mentioned in the WWDC talk, https://developer.apple.com/videos/play/wwdc2017/404, there is not globe icon showing next to my device and consequently if i disconnect my iphone from usb it gives me lost connection error.
Few of device details:
Mac OS : 10.12.6 (16G29)
IPhone : 6S running IOS (1115A372)
XCode : Version 9.0 (9A235)
Am i missing some step or is there a gap in implementation here ?
Posted same question on Apple Developer forum at https://forums.developer.apple.com/message/261911
You have to connect your iPhone via USB for the first time once to Xcode wait till Xcode finishes processing. Now you can click on your device name at the top
it will open the a list of simulators and your currently connected devices
Select the add additional simulators
Make sure that you have selected the Devices tab not Simulator also if you have multiple devices connected to your Xcode at the same time make sure to select the device you want to be connected view network in the left pan first.
Also you have to make sure that both your Computer and iPhone are both connected to the same network.
Now check the check mark for the Connect via Network
Close the current window and remove the USB cable click on build it should build your project through network.
Note: Building through network very slow.
update:
Please see the glob icon your looking for in the image below
So i guess i figured this out. This feature works from my home wifi but not if both of my devices are on my corporate network. Also, as khalid mentioned the installing of app when connected via wifi, is painfully slow compared to USB option. Maybe could use usb to transfer the application and then move to wifi to debug.

Xcode 9 Wireless debugging not working

For some reason the wireless debugging does not work here. Here is what I've done:
Using newest Xcode 9
Using newest iOS 11 on my iPhone 7+
Both devices are in the same network
Connected the iPhone via Lightning, selected "Connect via Network" in the Devices & Simulator menu
Run an app on the iPhone while still connected via Lightning - everything works
But as soon as I unplug the phone, Xcode is no longer able to connect with the phone. I can ping the phone with the Mac, but even the "connect via ip" option in Xcode does not work.
Anybody got tips on how to get this working?
I had the same issue, but it was intermittent - i.e. sometimes the globe would not appear next to the phone name in Xcode Devices and Simulators window and when the phone was disconnected from the lighting cable, I could not debug to it from Xcode. My fix was much simpler, though - I just turned WiFi on and off both on the Mac and on the phone. After the devices reconnected to the network wireless debugging was available again. This seems to be an issue with the network communication (regardless whether the device can be pinged or not).
Make sure System Preferences->Internet Sharing is enabled using USB ports:
I was able to find a solution to this on another stack overflow question:
How do you perform wireless debugging in Xcode 9 with iOS 11, Apple TV 4K, etc?.
You can also check this answer: "Connect via network" wireless debugging not working Xcode 9
Near the bottom, from "IOS DEV". Briefly, the solution ended up to be to unpair my phone, disconnect and re-pair. After that Xcode automatically added it with the globe. As an FYI, I was able to ping my iPhone using the network utility prior to the un-paring but was still unable to get the phone to connect. good luck.
Restarting xcode is the only thing that fixed this intermittent connectivity problem for me.
I realized this can also happen if my Mac is connected to a VPN. I had to:
Kill the VPN connection
Turn the computer's wifi off and back on
Open Devices and Simulators
Plug the device in and the globe icon should appear.
Unplug the device and make sure the globe icon is still there.
Run the app via network!
Wireless debugging mysteriously stopped working for me until I turned off my VPN client. I now believe that I had the VPN turned off when I was trying it out the first time, but then the VPN auto-connected after my computer restarted sometime later.

how to transfer files via iPhone personal hotspot between devices?

Is it possible to transfer files via iPhone hotspot i.e, iphone connected to a cellular network creates a wi-fi hotspot and one of the device is connected to that wi-fi and data transfer between these two devices over hotspot?
The iPhone has an app listening to some port or some medium through which the other device can send files to that iPhone app and record/save the files sent from the other device.
Any links or any information would be good if anyone of you can provide.
Thanks.
So this finally worked pretty easily using Apple's Multipeer Connectivity Framework.
Thanks to AppCoda's tutorial, here is the link:
http://www.appcoda.com/intro-ios-multipeer-connectivity-programming/
This tutorial doesn't talk about Hotspot usage, but I figured out a way to use the same to transfer files using personal hotspot on iPhone.
Steps to reproduce:
Install the final product of the AppCoda's on two devices. (This
might not work on Simulator for hotspot check, since no bluetooth via simulator)
Create hotspot on iPhone and connect the other device through the wi-fi created from iPhone.
Switch off bluetooth in one device and proceed with the app, browse for other device to connect.
Try to transfer files from one device to another through the hotspot connection.
Guess what? It worked for me. :) Go ahead. Try it out.

How to Run iOS application to device from Xcode Version 6.2 (6C131e) withough cable(Via WIFI - Bluetooth)?

I m goggling the things from few days about the debugging the iPhone application from Xcode(Version 6.2 (6C131e)) without using cable.
i have heard that OS X Yosemite of MAC have feature that can connect iPhone to Mac without cable.if is it so,than is anybody have any idea that how to build project into device from XCode without cable (Wi-Fi / Bluetooth)?.
is there any way to workaround to build or debug project in to device without using cable?
Apple has not specified how to build an Application on a device which is not connected through cable. If they do so in future, external ascessory, Multipeer connectivity framework (for WiFi) and CoreBluetooth Peripheral Manager (for bluetooth) will certainly come into account but before that, will Bluetooth or WiFi streaming withstand the code transfer load from Xcode to a device? And what if you device is already connected to some other WiFi or Bluetooth network?
This is now a reality! With Xcode 9 and iOS 11 you can now perform wireless builds to a device.

Can multiple iOS simulators communicate with each other over wifi?

I'm working on Ray Wenderlich's "How to make a Simple Playing Card Game with Multiplayer and Bluetooth."
That game can use Wifi when Bluetooth is unavailable.
If I open an iOS simulator on a computer and another iOS simulator on a different computer, will the iOS simulators be able to communicate over wifi?
I believe the answer is yes, since each iOS simulator can send/receive data over wifi. However, I wanted to check before I find another computer and install XCode on it.

Resources