Command-Line Apps in FW v2.1

Discussion in 'iOS Development' started by DawnOfTheDead, Oct 5, 2008.

  1. DawnOfTheDead

    DawnOfTheDead New Member

    Joined:
    Oct 5, 2008
    Messages:
    2
    Likes Received:
    0
    I am trying to develop some command-line utilities for iphone FW version 2.1.

    Anytime I run an app which uses the UIApplicationMain function and a UIApplication Subclass from the command line, I see an error in the Syslog:

    "An application that SpringBoard is not tracking just launched with identifier XXXX and will be killed."

    The application is then killed. This happens on applications that run fine when launched from SpringBoard. I've seen many examples in books and on this site showing apps that can be launched from SpringBoard and the command line, including the NavBar app from SkylarEC's Tutorial thread, but I assume those were earlier firmware versions.

    I'm guessing that there's just some little trick to keep SpringBoard from killing the app, but I cannot find it.

    Any help is greatly appreciated.
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Command-line applications will NOT use UIApplication or hardly any UIKit objects for that matter. They will just be C, and UIApplications are not allowed to run from the line anymore. Here is an example of an application that would do a language respring when executed with the argument --set-language.

    Code:
    #include <notify.h>
    #include <stdio.h>
    
    int main(int argc, char* argv[]) {
            if(argc>1 && argv[1] != NULL) {
                    if([[NSString stringWithCString:argv[1]] isEqualToString:@"--set-language"]) {
                            notify_post("com.apple.language.changed");
                    }
            }
            return 0;
    }
    that may be a tad wrong thats just off the top of my head
  3. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
  4. DawnOfTheDead

    DawnOfTheDead New Member

    Joined:
    Oct 5, 2008
    Messages:
    2
    Likes Received:
    0
    Thanks for your replies. I was mistakenly under the impression that you had to use the UIApplication interface to be able to access the other objective C APIs. From your examples I see that I can just instantiate the objects directly from my main routine.

    Thanks again, and I appreciate the examples!
  5. God__

    God__ New Member

    Joined:
    Dec 23, 2007
    Messages:
    69
    Likes Received:
    0
    All the "standard" main files do is use UIkit to create an object. In the "typical" case, that is an application. Technically, you can do whatever you want from within a program's main function. It is the entry point to any program.

    So yeah, feel free to roll you own windows. It's good practice, and will almost always do a body good. Like milk. In fact, making a good application is a lot like milking a cow. First, you need to get get her trust with compliments and flowers, shaped like candy. Then, you gently crawl beneath her and massage the udder until the milk releases into the bucket. finally, you must drink a bottle of Jack Daniels and forget that you ever talked to the cow. I mean, come on. No one will believe you that the cow was talking. Why are you talking to cows anyway?

    To sum up, Yeah.

Share This Page