how write iphone apps using objective-c from terminal - iphone

i would like to know how to develop iphone apps for terminal just like we do for android
by using the
android --target 1 --name someApp --package --com.someApp --activity main
command
how to do this for iphone apps
it should be like
iphone // then some options
or what is xcode or someother ide doing behind the scene ..??

If your question is "How do I develop from the terminal?", then, please, don't go there, but if you do:
The xcode project files are xml, they contain all information about your project, compile instructions, source files, resources, etc. You could create and manipulate these and use xcodebuild to compile your project.
If your question is 'How do I compile apps from the terminal?', then there are some valid reasons for doing so, automations, testing, etc. When you have installed Xcode, there are also some command line tools available, like xcodebuild. You can use these tools to build from the command line:
xcodebuild command line
Take a look at the xcoder ruby gem:
https://github.com/rayh/xcoder

Related

Socket Rocket Test/Tutorial

I'm new to socketrocket and to iOS development. I'm trying to follow along at https://github.com/square/SocketRocket#readme and implement the basic test chat app but am having trouble making things work.
Beginning with "go into the SocketRocket root directory and type: make test" i need some help.
Using the mac terminal, 'make' isn't a recognized command. Do i need to have python enabled on my mac for this to work at all? Trying to run the testapp in xcode before the server is started does nothing.
A more bare bones explanation would be most appreciated
You need to install command line tools. make is for compiling c code (among other things) command line tools can be downloaded with xcode through the app store.

How to run the PJSIP in xcode?

I'm new with XCode and still trying to understand objective-C. I'm using xcode 4.3.2, and I have to create an app that integrates with PJSIP.
I found this link. I am still confused about that link, because the article said that we must have installed the command line tool. But the command line tool is already installed in my XCode. How can i use it?
Do I need to create a view base application? how can I run the command line tool like the link says?
The command line tools allow you to compile "traditional UNIX programs" from source, generally using make. If you are using Xcode to create your projects then you don't even need them installed.
EDIT OK you have edited your question, stating the real issue you are facing; You don't know how to use the PJSIP package you have installed. The link you reference is about building PJSIP, not using it, so you can still forget about the command line and concentrate on how to configure your Xcode project to use PJSIP. This will require setting the header search paths and library search paths to find the header files and library file, in order to compile and link against it. Hopefully it's a static library as that will be easier to use; if it's a dynamic library or framework then you have your work cut-out as that's much harder to use.
In newer XCode (4.3 or above) you might have to install command line tools since it has been made optional. Open XCode and go to XCode->Preferences
Open the Downloads panel and click on "Components". If Command Line Tools are not installed already, you will get an option to install them from here.
Do so and you are set.
I done with it by myself. if you face the same problem, you can refer to this link, I already tried and run it. It works both on simulator and device. thanks.

ARM disassembler/cross-compiler for examining iOS compilation

Can anyone recommend either:
an ARM disassembler that runs in either Windows or MacOS and which can ideally understand the executable format used by iOS
within MacOS, a way to call the cross-compiling GCC installed by XCode directly from the command line (so that I can run it on a small test file and ask for assembly output).
Basically, I'm interested in seeing how certain things get compiled for ARM/iOS by XCode/gcc to help me with optimisation. As you can see, although I have both a Windows and Linux background, I'm not fundamentally a Mac specialist so I'm not too familiar with e.g. where XCode intsalls all its gubbinry or the ins and outs of whatever binary format iOS uses.
I don't particularly care whether I have to do the "disassembly" under Mac OS or Windows, but what I was trying to avoid is installing a brand new copy of GCC configured to cross-compile to ARM, as XCode presumably has a perfectly good installation already sitting there somewhere... Any help appreciated.
You can always use otool disassembler. It's rather basic but does the job.
IDA Pro can disassemble ARM Mach-O files used in iOS. Using it is (in my biased opinion) much better experience that looking at the dead listing. You can check how it works with the demo version.
Disclaimer: I work for Hex-Rays.
an ARM disassembler that runs in either Windows or MacOS and which can ideally understand the executable format used by iOS
I can suggest you a LLVM. If it is built with default options, llvm-objdump will disassemble ARM.
Also, looks like http://developer.apple.com/technologies/tools/whats-new.html Apple is using LLVM toolchain in iOS SDK.
There is already an ARM cross compile toolchain built into Xcode. You can debug your iOS applications at the source and ASM level with the gdb debugger support already built into Xcode. For example, open your iOS app and select Device and Debug. Then set a breakpoint at a source line and run your program until the breakpoint is hit. Now select "Run -> Debugger" from the menu. When the debugger is showing, select "Run -> Debugger Display -> Source and Disassembly" and you will see a window on the right side that shows the ARM asm code that was generated from your source code. You can step through the code a source line at a time using the buttons. If you want to step one ARM asm instruction at a time, open up the gdb console and use the "stepi" instruction (type it once, then just hit enter to repeat).
Take a look at Hopper. It's darn cheap compared to IDA (though not as powerful) and the recent versions can handle ARM.
Within MacOS, a way to call the cross-compiling GCC installed by XCode directly from the command line (so that I can run it on a small test file and ask for assembly output).
Use this script for a gcc that compiles for iphone:
#!/bin/bash
# Note: The "/Applications/Xcode.app/Contents" prefix is only required on 10.7.2 and
# later (where Xcode is installed through app store rather than as a package).
# If running 10.6 or earlier, cut out that prefix.
PLATFORM=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
# Change this to the iOS version you want to compile for (you must have the platform
# SDK installed in Xcode)
VER=6.1
$PLATFORM/Developer/usr/bin/gcc -arch armv7 -framework IOKit -framework CoreFoundation -F $PLATFORM/Developer/SDKs/ iPhoneOS$VER.sdk/System/Library/Frameworks -I $PLATFORM/DeviceSupport/Latest/Symbols/usr/include -L $PLATFORM/Developer/SDKs/iPhoneOS$VER.sdk/usr/lib -L $PLATFORM/Developer/SDKs/iPhoneOS$VER.sdk/usr/lib/system $*
Source: newosxbook.com
Take a look at Radare2 it is an open Source tool that is rising it's Feature-Set constantly and already supports ARM disassembling.

Debugging with Clang

I'd like to use clang on my Xcode iPhone project. However this is the getting started guide:
http://clang.llvm.org/get_started.html
I've been working with Xcode for a year but this is far far far from being understandable to me! Can anyone explain in plain english how to install and use Clang with my existing iPhone project? I am not familiar with loading things from the console.
Thanks!
Dan
Nikita Zhuk has wrapped Clang in a GUI and made it available at http://www.karppinen.fi/analysistool/. Very useful.
Download and extract the clang distribution to some directory. Optionally add this directory to your path, or you can just prepend it's location to the command line later on.
cd to your top level project directory (probably something like cd ~/Documents/yourprojectdirectory)
Tell the clang utility to do a build of your project using your xcode project settings by typing in the following command line: pathtoclangdirectory/scan-build -o ./clang_out xcodebuild
The utilty should give you a message after it has run successfully to run the scan_view utility.
Run the command that was output at the end of the build. This will start a temporary web server on your machine and then open up Safari and show you the code analysis. You may need to prepend the path to your clang directory again, like so: pathtoclangdirectory/scan_view ...
I didn't see this question until after I had done something similar to make Clang more useful inside XCode:
Using Clang Static Analyzer from within XCode

Is there a quick way to build & install to iPhone (from Xcode) without starting the app?

In Xcode, I can use CMD-R to run (or CMD-Y to debug), and my app will compile, install on the phone & start-up. (I've already prepped my phone & Xcode so this part works as expected.)
What I'd LIKE to do is type CMD-<something else> and have my program compile & install on the phone, but NOT start-up.
I realize that I can just CMD-B to build, then go through some rigamarole to deploy, but I'm hoping one of you smart-folk can tell me the lazy-man's shortcut for all of this.
Hey Olie, I haven't tried this because I don't have an iPhone to deploy to at the moment, but this /should/ work:
You can create a script which runs xcodebuild in your current project directory and give it the install target. Assuming you're going to want to debug at sometime, use the Debug configuration, otherwise use release. Then bind the script to some command key in the Xcode preferences and you should be on your way. To launch xcodebuild with debug you would do something like:
xcodebuild install -configuration Debug
If you have more than one target in your project you will have to specify that to xcodebuild as well:
xcodebuild install -target iPhoneApp -configuration Debug
You could also create a configuration specific to this scenario in your projects and pass that to xcodebuild and you should be able to script this in your favorite supported language (i.e., AppleScript, python, ruby, etc.).
HTH
I had the same question.
I ended up using the XCode Organizer. Select your current device. Summary Tab. "+" Applications..then select the one you just built (under /build/[debug|release]-iphoneos/.app
This does the install very easily.
Have you looked into using Automator? Here's a good write up on how to automate XCode to build and what not.
To build (exact flags documented under "man xcodebuild", install xcode's command line tools): xcodebuild build -sdk iphoneos6.0 workspace/project, targets, configs and/or scheme flags
To install (grab from github here then simply make and run): path/to/fruitstrap --id device-uuid-to-install-on --bundle path/to/ios.app