Thanks! Looking forward to reading about your findings. I spent most of last week trying to do just that without any luck so far
The thing that bothers me most is the presence in the MAS of apps that implement shutdown option.
Ok, got that all wrong. The MAS developers probably donāt use NSTask to do their bidding, they use instead the scripting bridge to send Apple Events to System Events. I tested that and it works alright inside a sandbox. You only need to use that temporary entitlement thing to get things done.
I love the tutorial, and it is great you rewrote a version in Swift, but is there are reason the original Obj-C example is not available? I have projects where I do not want to mix idioms, no matter what Apple says, and re-transliterating back to Obj-C seems like a wasteful and potentially buggy process.
Why not keep a copy of Andy Pereiraās code too? I know people want to evangelize and āmove with the timesā , and I even like Swift, but really this is counter productive. If you Swiftify, great, but donāt delete the old code at the same time, diversity is good!
I wonder it the way back machine will work on this oneā¦
Edit:
And it does, so all good, I have the Obj C version, cheers
I enjoyed the tutorial. Helped me create an app that uses a expect script to SSH to a wireless LAN controller and get the configuration. However; Iām having an issue with the output hanging the app. I assume that the Pipe() object is buffering the data being ported over to the TextView. My captureStandardOutputAndRouteToTextView method is verbatim to your code. Any thoughts on how to handle large amounts of data being piped from stdout to the text view?
Just as a sidenote regarding SUDO. I was building an app (for internal use in my workplace) and I really really needed to run a couple of commands with SUDO privileges.
What I found out is that I could run them as an AppleScript which in turn calls the shell script with sudo commands. It works, and the AppleScript call (using executeAndReturnError) takes care of the authorization process.
Now, the downside with this is that the execution of this AppleScript takes place on a different thread and I cannot stop it with the Stop button since I donāt have a reference to it. Am I right?
For anyone asking about using NSTask to run other command line operations, I followed this tutorial and then adapted the code to run arbitrary PHP code with very minimal changes.
Change launchPath to your PHP binaryās path (e.g. let path:String = ā/usr/bin/phpā). This can be any binary that accepts command line arguments.
Add flags to arguments array:
arguments.append(ā-rā)
Add values to arguments array:
arguments.append(inputText.string!)
Are there any plans to update this valuable tutorial now that the build script no longer works in the absence of PackageApplication in xcode? I have tried to work around the problem with xcodebuild, but I am not sure I have been successful because I eventually get hung with the following error message:
Check dependencies
No profiles for ācom.razeware.SuperDuperAppā were found: Xcode couldnāt find a provisioning profile matching ācom.razeware.SuperDuperAppā.
Code signing is required for product type āApplicationā in SDK āiOS 10.3ā
It appears that SuperDuperCode needs a teamID, but the options None and MyName(Personal Team) donāt work with com.razeware.SuperDuperApp. Is this also a problem introduced by the newer version of xcode?
Thank you for replying. Unfortunately, I am a newbie and the signing problem remains, even though I have changed bundle identifier and specified my personal team, both for TasksProject and SuperDuperApp. TasksProject seems perfectly happy. The problem seems to lie with SuperDuperApp. As downloaded, SuperDuperApp shows an iPhone 7 Plus as a target device. Xcode then wants a signing certificate for āiOS Developer.ā But the tutorial is a purely macOS project and Xcode canāt find a match for a provisioning profile because I am identified (rather loosely, I admit) as a macOS Developer. I tried to work around that problem, but never found a solution that worked. If I tried to redefine SuperDuperApp as a macOS/Cocoa app, I could get the pre-compile warning about the lack of signing certificate to go away, only at the expense of generating a āAssets.xcassets does not existā error (???). I havenāt found a solution, but I pass this along for anyone who might stumble on this thread.
You donāt need to sign Tasks Project but you need to sign SuperDuperApp as a iOS developer with your own bundle ID.
You can create a iOS developer account on the Apple portal if you donāt have one already.
SuperDuperApp is nothing special. Its just the template Xcode iOS single view app with a name and bundleID supplied.
The tutorial is really meant to cover how to use NSTask and connect Pipes so by getting to this stage you have probably picked up the essentials. Maybe you could try something else in the script and UI thats more specific to mac activity. If you know any scripting languages you could think something up.
This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]