Control mac with http - ios

I would like to be able to control my mac over http post commands.. (Launching apps for example)
I have this jailbreak tweak (activate command) on my iphone that can send shell commands and http post requests (using curl)
But the problem is that i don't know how to prepare my mac for receiving and processing these requests.. Should I use python or php scripts (any tutorials on receiving post requests?) or are there any easy-to-setup restful api's to setup on my mac?
Thanks guys

What you're talking about already exists, in mutltiple forms actually.
RDP: You're probably already aware of Remote Desktop Clients which should be sufficient enough. If you're really inclined on launching apps via command line, you can just open up terminal and do it remotely.
SSH: You can set up a secure shell server on both devices and launch a connection over the LAN. There are multiple clients that I know of on dos systems such as PuTTY or WinSCP. On UNIX systems, there is an SSH shell which you can use for remote connections on either ends. However everything you do will be command-line so you should already have a knowledge of the file system structure and how to navigate it and actually use it.
If you are looking for a script on iOS, I've had very little experience with developing in Python and I don't even know if it can pull off what you are asking. iOS 7.X >= compiles in Objective-C, iOS 8.X compiles in Swift, and the upcoming iOS 9 will be compiling in Swift 2.

Related

automate mobile device apps by direct communication to the phone via REST api

I'm currently working on a project that relies heavily on appium / selenium for automation. These frameworks are great for starting out, but the robustness isn't quite there, and requires a lot of extra hardware / software to run the automation. Such as macOS, xcode, adb, appium, selenium, usb connection or connected through WIFI ( what we currently have to use ). There is just a lot of dependencies in this automation stack, and it would be nice to have a cleaner, more reliable, and scalable solution.
So I'm wondering. Does any one know a way to run automation for iOS and Android via REST api using a server that lives directly on the device allowing us to communicate to the device like curl -POST <device_ip>:<port>/session/{sessionId}/openApp.
Think of the WebDriverAgent that Facebook built, but instead of being built with xcodebuild, that Agent just lives on the device. Essentially when you build this framework it starts up that server I'm describing, but its reliant on xcode, and i ultimately would like to remove xcode from having to be in the picture. I know that there are so many issues today I see with people having issues with both the WDA server and xcode. Specially with new versions, and how the WebDriverAgent is now archived by facebook.
Can't we just create an app that can act as the WebDriverServer running at all time, and will just use the same logic as today.. via start session, find elements by Id, click on them, and move on. This would also remove the need to running Appium on your computer, and rely on it to proxy your commands to that WDA server with iOS.
I know android is a much simpler picture, and I'm currently a little more focused on how to solve this with iOS at the moment.
I would appreciate any insight into this issue / question, and if anyone has suggestions on Appium, iOS automation, android automation, or other points that can be made please send me your feedback.
We do run our automation using real devices!
I have use Appium / Selenium to access from Rest API . In my opinion it is easier than building your own.
One of the solution was is we are currently working in a project using Flutter - that still need your Xcode to sign in the dependencies. You will also need to make sure libimobiledevice and ideviceinstaller are installed, and lastly modify Flutter. And we call the real device from rest api . We are currently scaling and monitoring the performance.
Another viable alternative which I can think of, doing it through XCTest will be easier than Appium . Just provide the end point in your app and create a wrapper in XCTest. Call the rest api and run the test in XCTest. It is more stable and faster in long run.
But for bulk of projects , I am still using Appium to test for iOS while we are evaluating this solution.
If you're open to using commercial tools, you can consider using xcuitrunner. It installs a recent version of Appium's fork of WebDriverAgent on your iOS device, launches it (and keeps it alive), and returns you a HTTP endpoint which you can use to interact directly with the WebDriverAgent.
It helps remove a couple of dependencies (such as Xcode), which may be difficult to manage. You'll still need a code signing certificate and provisiong profile from Apple, though.

What shell commands can you access on iOS via the "system" command in Objective-C?

I know that both Mac OS and iOS are based on Darwin OS. Does this mean all the OS X commands available in Terminal are available on iOS using the "system" command in Objective-C? If not, which ones are?
No, there is no shell available on an un-jailbroken iOS, and hence system() doesn't do anything useful. Adding a shell is apparently a common thing to do on jailbroken devices.
Most of the user-mode C/C++ run-time library is available in modern versions of iOS (I haven't worked with versions older than 9) so quite a lot of classical UNIX code can work. Writing an app with a shell user interface should be possible, but it isn't very useful without jailbreaking, for at least two reasons:
An app only has access to its own directory hierarchy, and thus can't see other apps' files.
iOS apps are not designed to be administered via a command-line interface.
I suspect Apple would also reject any submission of a command-line app to the App Store.

Is it possible to connect to mysql server directly from an iOS app?

I was just wondering if we can connect to a mySql server directly from an iPhone app directly,i.e., without using any PHP or java scripts as intermediates. If Yes, then what will be the challenges? I understand that there might be a chance of hacking.
EDIT: What if I am in a VPN, is this still a threat?

Ios filesharing without iTunes or an internet connection

I am working on developing an enterprise application for ios 7 that needs to work offline and then sync with a desktop client (that I also need to write) for data transfer.
My company does not allow wireless or cell data in this area, and would strongly prefer to not use iTunes either.
The question is, how do you transfer data from an iPad over the usb cable to a custom windows program, without iTunes.
The simplest answer would be: iExplorer (http://www.macroplant.com/iexplorer/) plus some kind of a script to automate the data sync.
Otherwise, you can use the ExternalAccessory framework to communicate with the desktop via a USB tether. This would necessitate a desktop client running simultaneously to communicate with the device.
peertalk (https://github.com/rsms/peertalk) does what you want, however the computer side library is only for mac os. Maybe you can port the protocol to windows by looking at that (the license is BSD)
Edit: this guy managed to have it run under linux. It sits on usbmuxd, which also has a windows port, so it shouldn't be impossible.

Writing to files on Mac when running on iOS device attached to Xcode

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.

Resources