Using Xcode for OSDev

Programming, for all ages and all languages.
User avatar
nerdguy
Member
Member
Posts: 70
Joined: Wed Oct 30, 2013 8:11 am

Re: Using Xcode for OSDev

Post by nerdguy »

Alright let me explain :
I have 4 computers at my house, A Lenovo, A Dell Inspiron, A Macbook, and a old DOS 386 PC which doesn't really work.
I installed XCode on it and tried to set up the IDE to be suitable for OS Development, (for a test).
The problem with XCode is the documentation and it's sticky behavior, I believe XCode is made for iPhone Application Development + OS X Application Development. As the XCode page says it's made for making apps on iPad/iPhone/OSX etc.
Without any documentation I couldn't really set-up the IDE for OS Development.
Right now I am turning my Mac on, and try again to set it up for OSDeving,
When you say, "I wrote a program that crashed Windows," people just stare at you blankly and say, "Hey, I got those with the system, for free." - Linus Torvalds
64 bit Kernel in early development
http://github.com/nerdguy12/core64
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Using Xcode for OSDev

Post by Combuster »

So, Visual Studio is the prime example of an IDE with OS development tutorials...

What IDE do Linux users use? Find me a tutorial for just that, will you? Doesn't that implying that windows is the best platform according to your own argument?
Does it make any platform worse because linux is best built under itself, just as windows and mac os gets built under their own platforms but nobody does that because you don't have the source code?
The only reason windows is worse is that many of the tools that are the most suitable for the task only support platforms other than Linux as an architectural afterthought. Mac OS actually has less natural deficiencies because it is officially unix-certified.

Using XCode for development might be as simple as adding a custom make to the compile commands up to fixing the entire project template so that it uses your compiler and flags of choice and leave the stuff where you think it's most appropriate. XCode isn't quite the braindead software, the defaults just happen to say "Mac OS" and "Cocoa" all over. Heck, if you want to write a kernel in objective-C rather than regular C, it might actually be the best IDE you can possibly get. It just takes some effort to wipe it clean of assumptions.

And if you have some decent experience with that IDE, you'll already know where to look for the settings in question.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Using Xcode for OSDev

Post by iansjack »

nerdguy wrote:The problem with XCode is the documentation and it's sticky behavior, I believe XCode is made for iPhone Application Development + OS X Application Development.
Well, I think you are wrong about the documentation. XCode is one of the best documented development environments around, both the Apple documentation and the third-party books available. And I think you are confusing the fact that it makes development of apps for OS X and iOS easier with "sticky behaviour". It's pretty easy to set it up like (say) Eclipse as an IDE for a straightforward makefile project.

As for the Mac itself, well it's just a Unix machine and is as good for OS development as any other Unix or Unix-like computer. However, it would probably be more work to get your own OS to actually run on a Mac than on a conventional PC. But I think most people tend to target VMs to start with, so that's not a big problem.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Using Xcode for OSDev

Post by Love4Boobies »

The cop out answer is to give up on Xcode and install a GCC cross-compiler under OS X---you wouldn't be the first one to do it. Since the documentation is richest for Linux and GCC, the community developed a similar answer for Windows users: a GCC cross-compiler running under Cygwin, which also offers almost all of the standard UNIX API and utilities, together with Linux-specific extensions.

I have no experience with OS X or Xcode so I never studied their documentation. However, I believe Xcode uses LLVM as a back end, which has certain advantages---it makes it a lot easier to experiment with language/VM-based designs. People often use LLVM, and often clang, on Linux and Windows as well.

UPDATE: Some larger-scale projects, use more complex build systems (usually based on SCons, CMake, GNU Autotools, etc.) which make it possible for developers coming from different environments to keep using their favourite tools. ReactOS, for instance, can be built with Visual Studio, GCC, or clang.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
AbstractYouShudNow
Member
Member
Posts: 92
Joined: Tue Aug 14, 2012 8:51 am

Re: Using Xcode for OSDev

Post by AbstractYouShudNow »

I think you are misunderstanding the problem. The OP's problem is not in the setup of the IDE for building, just that it is not very good at handling (non Objective-) C programs. Unfortunately, I think there is no real way to get XCode adapted to OSDev. This is due to Apple having a perfectionnist's philosophy; I mean, they like to make their software dedicated to a specific purpose (for instance, developing OSX/iOS apps) and make it near-perfect for it, at the cost of genericity. This is opposed to Microsoft's philosophy of making general-purpose programs (though they recently changed radically in favor of specific-purpose software, by the time of Windows 8, proving that they finally started thinking again, after 25 years time spent selling the almost-same kernel, introducing Mac-stolen changes (the GUI being the most famous one), a move that was probably a consequence of Job's death (no more ideas to steal), or maybe not (sorry for the long parenthesis)). This makes XCode bad for OS Development.

Personnally, I would recommend Linux since it often comes with GRUB bootloader, which is able to launch Multiboot kernels, which comes in handy if you are writing one. However, I think (but it's just my POV) that a programmer should remember his program's function names, and in fact, I design my programs to make that task easier (using modularization so that I am always working on a small part of the project, and hence have few names to remember). To solve your problem, I'd recommend using Code::Blocks which happens to be compatible with Windows, Linux and Mac because it is specifically designed to handle C++ code (and hence works well with C), and it is very easy to set it to build a Makefile.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: Using Xcode for OSDev

Post by zhiayang »

AbstractYouShudNow wrote:I think you are misunderstanding the problem. The OP's problem is not in the setup of the IDE for building, just that it is not very good at handling (non Objective-) C programs. Unfortunately, I think there is no real way to get XCode adapted to OSDev. This is due to Apple having a perfectionnist's philosophy; I mean, they like to make their software dedicated to a specific purpose (for instance, developing OSX/iOS apps) and make it near-perfect for it, at the cost of genericity. This is opposed to Microsoft's philosophy of making general-purpose programs (though they recently changed radically in favor of specific-purpose software, by the time of Windows 8, proving that they finally started thinking again, after 25 years time spent selling the almost-same kernel, introducing Mac-stolen changes (the GUI being the most famous one), a move that was probably a consequence of Job's death (no more ideas to steal), or maybe not (sorry for the long parenthesis)). This makes XCode bad for OS Development.

Personnally, I would recommend Linux since it often comes with GRUB bootloader, which is able to launch Multiboot kernels, which comes in handy if you are writing one. However, I think (but it's just my POV) that a programmer should remember his program's function names, and in fact, I design my programs to make that task easier (using modularization so that I am always working on a small part of the project, and hence have few names to remember). To solve your problem, I'd recommend using Code::Blocks which happens to be compatible with Windows, Linux and Mac because it is specifically designed to handle C++ code (and hence works well with C), and it is very easy to set it to build a Makefile.

Yes thank you! You pretty much encapsulated my thoughts exactly.

A couple of points:

1. Indeed most apple software is designed only with a handful of specific usage cases. Very unfortunate, given most (most only haha not all) of their software is streamlined and looks decent.

2. I don't get your argument - if you recommend Linux because it comes with grub, do you mean the bootloader on disk itself, or the grub-* commands? Because for the former, it wouldn't work on a mac (I'm sure you'd know) and for the latter, nothing a small Linux VM can't handle.

3. I really don't want to go through the hassle of rEFIt and such things, given apple could release an EFI update any day which would break it entirely.

4. Developing in a VM is painfully agonising, especially on my hardware.

5. I actually have Sublime Text 3, but the main reason that I'd rather use Xcode is that I do a little bit of app programming as well, and it's a little confusing. Besides, having software that doesn't cost a bomb or doesn't bug you with a message every so often is a bonus (:

6. How do you set up your 'modular' things? I'm in the process of rewriting my OS now (it got too messy). I'd like the idea of such a thing. Multiple projects or something?

7. I've looked at Code::Blocks before, and I'm sorry to say it's disgustingly messy and will probably run like an Eclipse (which btw is a synonym for slow and cluttered). It also looks terrible. No offence to anyone out there.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Using Xcode for OSDev

Post by iansjack »

The OP's problem is not in the setup of the IDE for building, just that it is not very good at handling (non Objective-) C programs
That might be interesting if it were true. But it isn't. XCode is perfectly adept at handling straightforward C and/or assembler code.
thomasloven
Member
Member
Posts: 89
Joined: Tue Feb 26, 2008 10:47 am
Location: Sweden

Re: Using Xcode for OSDev

Post by thomasloven »

So how did you solve the problems OP describes?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Using Xcode for OSDev

Post by Combuster »

I don't think there is a problem.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Using Xcode for OSDev

Post by iansjack »

thomasloven wrote:So how did you solve the problems OP describes?
http://hiltmon.com/blog/2013/07/07/xcod ... -projects/
Post Reply