Is Multipeer Connectivity still working in xCode 7 Simulator?

I just upgraded an app written in Swift 1.2 with xCode 6.4 to Swift 2 with xCode 7.0.1.


The upgraded app builds and runs fine, but multipeer can not establish a connection between a phone and simulator once invitations are issued. It was working fine before the upgrade, and I was forced to make a few changes to the multipeer code during the upgrade.


There were lots of methods that needed their signatures changed: (This is one of many methods that wanted the exclamation removed)


-    func advertiser(advertiser: MCNearbyServiceAdvertiser!, didReceiveInvitationFromPeer peerID: MCPeerID!, withContext context: NSData!, invitationHandler: ((Bool, MCSession!) -> Void)!) {
+    func advertiser(advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: NSData?, invitationHandler: ((Bool, MCSession) -> Void)) {


Then, nil could no longer be passed when rejecting an invitation:


-            invitationHandler(false, nil)
+            invitationHandler(false, self.session)


I've been reading about recent changes in encryption preferences. I've been using the minimal constructor without encryption declaration for the session:


self.session = MCSession(peer: peerId)


I've unsuccessfully tested an iphone 6 with iOS 9.0.2 and a simulator run by xCode 7.0.1 on both yosemite and el capitan connected to the same wifi network with bluetooth enabled and disabled. The browser that issued the invitation recieves a NotConnected and LostPeer quickly and the advertiser becomes aware as expected. This is similar behavior to what I saw before when the devices were not on the same network.


Is there anything I have overlooked in the upgrade? I can't find any similar issues in the forum or stackoverflow.


Any assistance is appreciated.

Accepted Reply

It turns out the application's target was still 8.4, and changing it to 9.0 allowed the invitation to be accepted again.

I can only guess the differences in the encryption defaults make it not backwards compatible.

Replies

I've tried both the iOS 9.0 and 8.4 simulators from xcode7 with same issues now. Peers are found, invited, state modified (Connecting & NotConnected), and lost. The state just never reaches Connected.


I'm planning to test with 2 actual devices soon. I'm hoping the simulator is just misbehaving.


Any ideas?

It turns out the application's target was still 8.4, and changing it to 9.0 allowed the invitation to be accepted again.

I can only guess the differences in the encryption defaults make it not backwards compatible.

Hello Wes.Williams


i am trying on 2 actual devices and facing the same issues


any ideas

I can connect iOS simulator 8.4 to iPhone 6S with iOS 9.3 no problem, using XCode 7.3.