Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to run Terminal commands in Xcode?

Anyone knows how to include Terminal commands ( like sudo) in Xcode? for example in a line of my program I need to run this:

sudo open/Library/Preferences/com.apple.sharing.firewall.plist


I searched the library but found no class or routine for that.

Posted on Aug 25, 2012 8:26 AM

Reply
Question marked as Best reply

Posted on Aug 25, 2012 9:24 AM

Normally you can use NSTask to run shell scripts, but to run one with root privileges you will need to use Authorization Services.

4 replies

Aug 25, 2012 11:20 AM in response to red_menace

Wow !!! really got impressed dear "red_menace".... Never thought I can get my answer here.

Thanks , I really mean it, ...really !.


I learned programming in Windows environment ( C++/CLR , Win API , C ) and thought I am a professional, but now I realized I know nothing at all !!! .. nothing !


Never thoght UNIX can have such a powerful environment.

I think I need to start learning UNIX coding from begining.


May I ask you to complete your favor and tell me where should I start ?( any books , links , web ,....)


Aug 26, 2012 12:14 PM in response to Augend

Well, I am not a professional programmer, but one of the things I continue to learn is how to wade through all of the Cocoa documentation (and it does get deep in spots). Chances are though, no matter what you are trying to do, Apple or some third party has created a class to make it easier - you just have to find it. My Xcode documentation bookmarks continue to grow, but you might start with some of Apple's documentation, such as


Cocoa Fundamentals Guide

Foundation Framework Reference

Application Kit Framework Reference

How to run Terminal commands in Xcode?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.