Help an XCode newbie!

Discussion in 'Mac Programming' started by designbot, Aug 3, 2007.

  1. designbot macrumors newbie

    Aug 3, 2007
    I'm learning to program using Stephen G. Kochan's book, Programming in Objective-C. I don't like terminal-based text editors like vi, so I'm using XCode to write & compile my programs. So far so good.

    As I go through the book, I will be writing many very small programs. Do I need to create a whole new project in XCode for each one, with a separate folder and everything? Does each code file need to be named "main.m"? I'm sure there's a better way. I'd like to have a folder on my hard drive for each chapter, with a separate file saved for each exercise, something like "exercise2.1.m". Is this possible?

    I also have TextMate, so if there's a simple way to accomplish the same thing with that, and easily compile the programs using gcc or something, that would be fine too.

    If this is a stupid question, go easy on me; I'm new to this Objective-C stuff. :)
  2. mduser63 macrumors 68040


    Nov 9, 2004
    Salt Lake City, UT
    Too tired to post a detailed reply right now, but here are the basics. You don't strictly need to create a new project for each program, but it's easier that way, trust me. Even when not using XCode, I always have a separate folder for each project/program I'm writing. For the simple programs in Kochan's book (single source files IIRC) XCode is probably overkill anyway. TextMate does have the ability to compile source code you're editing, but I've not used that feature much, so all I can say is you need to read the help and figure it out. When you move on to Cocoa, you'll have many source files in the same project/program and XCode's project management features become very helpful, so learning XCode now is probably not a bad idea.

    Good luck, and enjoy learning to write software on the Mac. I've been learning for about 2 years now, and while I have an app that's out there with lots of people using it, I still enjoy learning new Cocoa stuff all the time.
  3. Littleodie914 macrumors 68000


    Jun 9, 2004
    Rochester, NY
    I would create separate projects, if I were you.

    That's the easiest way to do it, for example, create a folder called "My Cocoa Programs," and save all of your projects in that folder. For example:

    My Cocoa Programs -> Exercise 2.1 -> Exercise21.xcodeproj

    My Cocoa Programs -> Exercise 3.6 -> Exercise36.xcodeproj

    And yes, for many terminally-ran tools, you will begin by executing code in the main.m file. Think of it as the "index.html" of code files. When you get into developing GUI apps, you don't modify the main.m, since it will just start your other code files running. :)
  4. designbot thread starter macrumors newbie

    Aug 3, 2007
    OK, guess I'll just make new projects for each one then.

    I tried compiling from TextMate, but it just uses XCode to compile, so it works basically the same.

    Thanks, everybody!
  5. DHagan4755 macrumors 6502a


    Jul 18, 2002
    Just out of curiosity, what types of applications are you guys interested in writing (you don't have to give away ideas, just in general)?
  6. mduser63 macrumors 68040


    Nov 9, 2004
    Salt Lake City, UT
    I like to wrrite stuff that I see a use for myself. If it's helpful to other people, fine, but I think it's best to write something that you'll actually use. And you should certainly use anything you write.
  7. Soulstorm macrumors 68000


    Feb 1, 2005
    Anything that would prove useful for my programming experience. I recently made a Launcher for FS2_Open, which ended up being noticed by the developers of the port. But I have made many things, that although they may never see the light of day, they were absolutely necessary to make, since I have learnt a lot of things by making them.

    Example: I have made a framework, which grew big over the time, and became a library which is used by my colleagues and friends of mine (and me, of course) to make programs easier to make. This library includes basic parsers, string actions, templates for maps for game creation, and much more. I am now trying to make a very basic chat application. The internet is filled with applications of this kind, but the knowledge I will gain in the process will be invaluable.

    I recommend you do something similar. In order to become a good programmer, you need knowledge that will be gained by making useless programs. In order to become great programmer... well, you need to become a good programmer first. :)
  8. janey macrumors 603


    Dec 20, 2002
    sunny los angeles
    Like the people above me, stuff I need/want. Usually as a replacement for some awful software or something where there exists no application to do it.

    Right now I'm working on a menubar item that keeps track of a certain something for me...the original app is awful and unusable for long periods of time (which is what it's supposed to do...), and I don't use Dashboard, which would have been the easier way out. I'm having an insane amount of trouble though, because there are a TON of ways to manage the item in question and I can't account for all of them, nor can I think of a good way to do so :(

Share This Page