I am making use of the awesome ios-sim found on github.
It allows you to run the simulator via the command line and it also allows you to select which simulator (iphone or iPad) to use.
I am able to run my application flawlessly with it. However, I am unsure how to use the arguments passed to my application via the command line.
Has anyone done this or knows how to do this?
./ios-sim launch iTest.app --family ipad --args argument1 argument2
How do I access argument1 and argument2 in the iPhone application?
in the main.m File you can print the arguments with:
int main(int argc, char *argv[])
{
int i;
for (i = 0; i < argc; i++) {
NSLog(@"%s", argv[i]);
}
@autoreleasepool {
...
...
}
}
You can use this to get the arguments:
[[NSProcessInfo processInfo] arguments];
I know this is an old question, but I thought I'd post it for future reference.
iOS doesn't support command-line access.
This is from Apple's Cocoa Fundamentals Guide, Page 17
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW27
Generally, the system libraries and frameworks of iOS that ultimately
support UIKit are a subset of the libraries and frameworks in Mac OS
X. For example, there is no Carbon application environment in iOS,
there is no command-line access (the BSD environment in Darwin), there
are no printing frameworks and services, and QuickTime is absent from
the platform. However, because of the nature of the devices supported
by iOS, there are some frameworks, both public and private, that are
specific to iOS.