Does anyone have any idea how to access files in the mac from a device when the device is connected to the computer via USB?
This is the scenario so far.
We need to run some acceptance tests on device, and to save time, the tests are going to be run using mocktail. And since we have a couple thousand tail files, we can't bundle them and copy it out to the device (it's not practical, and probably bad practise anyways), so, we store the mocktail file in the project directory and not include them in the app.
This works great from simulator, given that the simulator is run on the mac, and it can access the files properly. However, when we tried to run the same tests in the device, it crapped out because it can not find the appropriate tail file (which makes sense). So far, I couldn't find anything to do this programmatically from Xcode.
Is there any way that one can access files in the computer from a device connected to it via USB programmatically in Objective-C?
Thank you very much in advance.
iOS devices do not have the proper drivers to pose as a USB host. You will have to bundle your files as resources in your app, or download them over the air.
AirDrop lets you share photos, documents, URLs, and other types of data with nearby devices. AirDrop takes advantage of peer-to-peer networking to find nearby devices and connect to them:
- Sending Files and Data to Another App.
- Receiving Files and Data Sent to Your App.
Related
In an automated test environment, I have to use 7.5GB of test data, that consists of 170k+ files. Simply copying it with the bundle is too slow (40+ minutes), thus I would like to incrementally sync the contents of the test data folder between the iOS device and the mac. Eg. using the iOS device as a USB drive, and use rsync to sync the contents, but any ideas are welcome. No, I can't jailbreak the device. Basically I want to keep two folders synchronized between an iOS test suite and a mac. Any ideas?
There is a way to do that using USB without jailbreaking your iOS device. The whole setup works via a UNIX socket called usbmuxd that Apple uses to communicate between a USB iOS device and e.g. Xcode or iTunes on a Mac. The iOS device basically opens a TCP server and the OSX app connects to the UNIX socket from which it can obtain a TCP connection to server on the iOS device. After that you can just write and read data over USB using streams at 480MBits.
There are some frameworks under MIT license with example apps for OSX and iOS that allow you to use this mechanism in your own apps:
https://github.com/jensmeder/DarkLightning
https://github.com/rsms/peertalk
This mechanism is App Store compliant in case u need to publish your app later. One popular example is an app called Duet Display that allows you to use your iPad as a second screen via USB.
Hope that helps.
I think it's unlikely, but does anyone know a way to access the OSX file system from an iOS app, connected by USB? Specifically I'd like to access iTunes backup files from iOS.
An iOS app is sandboxed. It can't see outside the sandbox. And it is either running on a device or on the simulator, and either way it is unaware that your OS X computer even exists.
I'm planning to use tcpdump for development of an iPhone app.
But i'm not sure will Apple allow it or not with iOS 8.0 onwards to be used in iPhone app development.
Please provide your comments on this
Thanks
You won't be able to open a BPF device on iOS - by default, XNU creates BPF devices with permissions rw-------, owned by root, so even if a process running in a sandbox (which all non-Apple iOS applications - and probably most Apple iOS applications - on a non-jailbroken iOS machine are) is allowed to open files in /dev, your program won't be able to capture network traffic.
I also think sandboxed applications may not be allowed to fork and exec or posix_spawn() arbitrary programs, so your application probably wouldn't be able to run tcpdump as a program - assuming it's even shipped with iOS, which it might not be.
You might be able to incorporate tcpdump code in your application, but without being able to capture traffic, all it will be able to do is to read existing captures, and that's probably easier to do on your Mac.
So this is probably a project of interest only on a jailbroken machine.
Does anybody have an idea how I can programmatically extract iOS txt messages without locally backing it up with iTunes? It would actually be nice if I could simply run a command line tool like idevice or some framework/API.
iMazing seems to be doing just that - without jailbreaking the phone. But how does this tool work? Are they simply running a unencrypted backup task and then read the backup-files? Or is there an even more elegant way to access the text messages on an iOS device? (when plugged in via USB-cable)
Another idea could be that iMazing reverse-engineered Apples APIs, but this would be highly unlikely unless they hired some Apple engineers.
When running an app on an iPhone/iPad via Xcode, is there anyway to open files for writing on the Mac?
I have an app which requires the device to run, so using the simulator isn't an option. I do however need to analyze some of the app's output. Currently I have to write to files on the device, and then manually sync them to the Mac. I'm looking for a way to write my files to the Mac directly.
I recommend using NSLogger to stream your log data via Bonjour to the Mac. It has a Mac application that allows you view the data as it is coming in.
For more advanced logging you can also combine NSLogger with the CocoaLumberJack framework using this connector project.
Probably the best possible solution for your situation probably rests with leveraging the console and NSLog to redirect output to a file - that's an open channel between the device and the Mac you can leverage as long as your running the app from Xcode.
There are a number of questions and answers relating to how to do this - here's one:
Log XCode gdb output to file with .gdbinit
This solution assumes that you only need to be doing this when running the app through Xcode, which your question implies. If you need to write to the Mac when running the app directly on the device (not debugging) you would need to use some type of network file transfer, such as FTP or HTTP. You could probably whip up a simple HTTP-based logging app that would run on the Mac using:
https://github.com/robbiehanson/CocoaHTTPServer
Then you would just send the content line-by-line to the server. Many other possible approaches along those lines, and probably an existing Mac-based solution you could leverage.