Watch 2 missing UIDevice, CFNetwork, Reachability, and more

We're porting to Watch OS 2 and finding many, many calls not present. Some of the most notable for now include UIDevice. Important APIs like [[UIDevice currentDevice] name] and [[UIDevice currentDevice] identifierForVendor]. I suppose I can get by without [[UIDevice currentDevice] model] because there's more or less only one model.


Also not present is the SCNetworkReachability framework. I can probably ignore/workaround that. Not having anything to call the device I'm on will look sketchy. Not having identifierForVendor will decrease the user experience on reinstall.


SSL support seems to be missing from CFNetwork. Critical APIs like kCFStreamPropertySSLSettings and kCFStreamSSLCertificates are just missing. These would be total showstoppers, might as well just disable the target until these reappear. We need strict control over every aspect of SSL, so working around this could require totally rewriting away from CFNetwork which it's safe to say wouldn't be happening soon.


Similarly, CFHTTPMessageRef and related calls like CFHTTPMessageCreateRequest are missing. (NSURLSession is way too high level for our needs and the problem it's trying to solve [large data transfer in the presence of frequent backgrounding] is not one that we have.)


Too many errors, had to stop there. Is there any hope for this version of WatchOS or should we realistically keep the Watch OS 1 app current until these things are fixed in a future release? I didn't understand from WWDC that the frequent mentions of NSURLSession meant "and we basically haven't finished porting CFNetwork APIs so we're saying this because you may find it is your only option." If there is hope for the Fall, we'll need to know pretty soon as this was going to be a major effort this Summer.

Answered by RLKingSoftware in 85874022

Unfortunately, as of xCode 7, all of the above are gone. Ran into similar issues with my app

which used UIDevice in Watch 1.0 and 1.1 unfortunately, under xCode 7 there is no option to

use the older forms despite Watchkit 1 still being an available target.

BUMP. I put in a bug report 21545594 for CFSocketSetAddress giving me a bind failure and never heard back from anyone. I also need to be able to send and receive simple UDP messages and while I have it working on Watch OS 1.0, I am unable to find a way to get it to work on 2.0

I tried using OS 2.0 Beta 4 and still have the same issue. I also tried using a different low level method


this still fails saying "operation not permitted"


can I please have some guidance whether there is or will there be support for receiving UDP packets on Watch OS 2.0?


int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);

struct sockaddr_in sa;

char buffer[1024];

size_t fromlen, recsize;


memset(&sa, 0, sizeof(sa));

sa.sin_family = AF_INET;

sa.sin_addr.s_addr = INADDR_ANY;

sa.sin_port = htons(14510);


// bind the socket to our address

if (-1 == bind(sock,(struct sockaddr *)&sa, sizeof(struct sockaddr)))

{

perror("error bind failed");

close(sock);

exit(EXIT_FAILURE);

}

else{

NSLog(@"ok");

}

Any updates on this? I would like to use UIDevice and Reachability on the WatchOS2.0.

I would assume that this is because UIKit and CFNetwork are not available in Watch OS 2. Only NSURLSession and WatchKit.

Accepted Answer

Unfortunately, as of xCode 7, all of the above are gone. Ran into similar issues with my app

which used UIDevice in Watch 1.0 and 1.1 unfortunately, under xCode 7 there is no option to

use the older forms despite Watchkit 1 still being an available target.

Safe to say I gave up a long time ago on that path. By force, I had to adopt WatchConnectivity. In retrospect, I should have stayed on WatchOS 1 and not ported to WatchOS 2 but now it is nearly impossible to go backwards. So here we wait hoping for WatchConnectivity to work well. Still serious issues with sendMessage: there covered in other threads.

Watch 2 missing UIDevice, CFNetwork, Reachability, and more
 
 
Q