4

I am currently developing a tvOS/iPhone app. The goal is to browse my local network and find different devices that publish AFP and SMB shares, and read files from them.

So far I have managed to find and list the different devices in my network (like my time capsule) using NSNetServiceBrowser.

My issue is: How can I access and read the information (e.g. directories or files) of the AFP or SMB shares I found?

I have tried NSFileManager, but from what I found, it is not suitable at all for this task… Any idea on how to achieve this, using an iOS framework or third party library?

Dov
  • 15,530
  • 13
  • 76
  • 177
Ayrton Werck
  • 334
  • 4
  • 15
  • I was about to post a similar question. Have you gotten anything working yet? – Dov Dec 03 '15 at 19:42
  • Rather than starting my own question, I'm upvoting this one. There are apps that do this - how? – VTPete Aug 12 '19 at 20:10

1 Answers1

4

I was not able to find an Objective-C or Swift example, but this one is in C.

Tango library in C

This seems to be able with NSURLRequest with a smb:// URL, but that might be limited to OS X according to Apple's documentation.

jbehrens94
  • 2,356
  • 6
  • 31
  • 59
  • Yes I have seen it, but it was old (5years ago..).There might be something, on the new apple TV there is different app that propose that kind of service. – Ayrton Werck Nov 20 '15 at 17:04
  • Try to use NSURLRequest with a smb:// url and let me know what happens. – jbehrens94 Nov 20 '15 at 17:13
  • There it never pass in the completion block...`let url = NSURL(string: "smb://xxx:xxx@192.168.0.12") let request: NSURLRequest = NSURLRequest(URL: url!) let session = NSURLSession.sharedSession() session.dataTaskWithRequest(request) { (data, response, error) -> Void in print("Response") let reply = NSString(data: data!, encoding: NSUTF8StringEncoding) print(reply) }` – Ayrton Werck Nov 20 '15 at 17:55
  • No it does nothing, I put a breakpoint but it never goes in the completion block... – Ayrton Werck Nov 20 '15 at 18:01
  • What does the breakpoint tell you? That you unwrapped an optional nil value, or something else? – jbehrens94 Nov 20 '15 at 18:09