Xcode 4 and SDL Templates

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Armyof1
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 11
Joined: Sun Sep 05, 2010 12:03 am
Programming Language of Choice: C++
Location: Nebraska
Contact:

Xcode 4 and SDL Templates

Post by Armyof1 »

I was able to get SDL working on Xcode 3.2 quite easily but I just upgraded to Xcode 4 (which I like much more) but am having trouble using the Xcode template and even just getting the SDL framework to work in general.

I'm sorry is this is a retarded question, I was just wondering if anyone else has had issues with this...
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Xcode 4 and SDL Templates

Post by Falco Girgis »

Fuck the templates. I actually had a bunch of trouble with the templates in 3.*, since my own projects required a custom setup.

1) Start a new COCOA project.
2) Steal the Objective-C main and add to your project
3) Add the Framework/Dylib to your project
4) Add the header files

Done. That's literally all the template did.
starpause
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 3
Joined: Thu Jul 14, 2011 4:28 pm

Re: Xcode 4 and SDL Templates

Post by starpause »

:worship: GyroVorbis

After trying a few other things (like loading an old Xcode3 template in that IDE, saving the project and trying to build in Xcode4) I think you've got the right idea. However, I'm too new to know what to do at each step you describe. Here's how I've broken it down so far ...

0) install SDL framework
a) download runtime libraries from http://www.libsdl.org/download-1.2.php
b) install by reading the readme files on the DMG

1) Start a new COCOA project.
a) File -> New -> New Project
b) iOS -> Application -> Window-based Application
c) Product Name: FuckTheTemplate, Device Family: iPad, Next

2) Steal the Objective-C main and add to your project
-) where am i stealing from? what file exactly? i guessed and grabbed SDLMain.m and SDLMain.h from a template.

3) Add the Framework/Dylib to your project
a) highlight SpoutNoTemplate in the Project Navigator (left hand pane of Xcode4) -> Build Phases -> Link Binary With Libraries -> + Button -> find or browse for SDL.framework -> OK
b) optional: drag SDL.framework into the Frameworks folder in Project Navigator

4) Add the header files
-) same question as step two, where are these from and how do i do it?

Thanks so much for your help on this! I see no point in templates ... teach a man to fish!
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Xcode 4 and SDL Templates

Post by avansc »

programmers are note suppose to fish, we are lazy, we dont reinvent the wheel... use the template. if its broken fix it, but reuse as much as you can. If you need a special setup like falco, then alter it.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Xcode 4 and SDL Templates

Post by Falco Girgis »

The setup that I just described is exactly what the template is... except that it actually worked.
starpause wrote:-) where am i stealing from? what file exactly? i guessed and grabbed SDLMain.m and SDLMain.h from a template.
Yeah, that's right.
starpause wrote:-) same question as step two, where are these from and how do i do it?
Every library is distributed as some form of a binary with header files. These are what you downloaded from the SDL website. SDL.h is one of the files.

In the same project properties dialog as when you added the framework, there should be an option for adding additional include paths. Just specify the folder that your SDL headers are in.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Xcode 4 and SDL Templates

Post by avansc »

I just tried the templates with Xcode4 for shits and giggles, and yeah they are broken, but you only have to change like 2 things. I never liked how SDL works in OSX.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
starpause
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 3
Joined: Thu Jul 14, 2011 4:28 pm

Re: Xcode 4 and SDL Templates

Post by starpause »

Guys, thanks for the fast response!
avansc wrote:I just tried the templates with Xcode4 for shits and giggles, and yeah they are broken, but you only have to change like 2 things.
Could you point the things out or share your fixed templates? It's not obvious to me what needs to be changed but I'm glad you were able to iron out the issues.

I'm aware of the minimal template borealkiss made but when I load it up I don't see any references to SDL in the application (no SDL.framework included etc). Am I missing something obvious?

My issue with templates isn't with when they just work, but when they are broken it's more effort to fix them. If there was a clear step-by-step for doing a project then it's easier to identify which steps are broken. Hard to say which method boils down to less work in the big picture.

Back to FTT w/ GyroVorbis, I copied the Headers folder from the SDL runtime DMG into my project and linked to the SDL.h file, that got rid of many errors. I then changed #import <Cocoa/Cocoa.h> in SDLMain.h to <Foundation/Foundation.h> (based on http://stackoverflow.com/questions/7455 ... oa-cocoa-h). Down to 12 issues in just the SDLMain.m file ... first one is SDLMain.m:17: error: cannot find interface declaration for 'NSApplication'

Is this because I copied the SDLMain.m file for a desktop application into an iPhone project? Ideas on work arounds?
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Xcode 4 and SDL Templates

Post by avansc »

starpause wrote:Guys, thanks for the fast response!
avansc wrote:I just tried the templates with Xcode4 for shits and giggles, and yeah they are broken, but you only have to change like 2 things.
Could you point the things out or share your fixed templates? It's not obvious to me what needs to be changed but I'm glad you were able to iron out the issues.

I'm aware of the minimal template borealkiss made but when I load it up I don't see any references to SDL in the application (no SDL.framework included etc). Am I missing something obvious?

My issue with templates isn't with when they just work, but when they are broken it's more effort to fix them. If there was a clear step-by-step for doing a project then it's easier to identify which steps are broken. Hard to say which method boils down to less work in the big picture.

Back to FTT w/ GyroVorbis, I copied the Headers folder from the SDL runtime DMG into my project and linked to the SDL.h file, that got rid of many errors. I then changed #import <Cocoa/Cocoa.h> in SDLMain.h to <Foundation/Foundation.h> (based on http://stackoverflow.com/questions/7455 ... oa-cocoa-h). Down to 12 issues in just the SDLMain.m file ... first one is SDLMain.m:17: error: cannot find interface declaration for 'NSApplication'

Is this because I copied the SDLMain.m file for a desktop application into an iPhone project? Ideas on work arounds?
here this is not a template, but should get you up and running. there is really nonthing fancy about it, just read the xcode documentation on the apple developer site.

just note that this project is setup to look for SDL.framework in /Library/Frameworks, but you can change it to look where ever you want.

http://s000.tinyupload.com/index.php?fi ... &gk=laptop
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Xcode 4 and SDL Templates

Post by Falco Girgis »

OH SHIT! I just realized this is an iOS project! Is SDL even supported on iOS? I have no idea in that case...

I'm fairly certain that .dmg that you downloaded is just for OSX?
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Xcode 4 and SDL Templates

Post by avansc »

I'll make a genuine xcode4 SDL template for you tomorrow.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
starpause
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 3
Joined: Thu Jul 14, 2011 4:28 pm

Re: Xcode 4 and SDL Templates

Post by starpause »

@avansc ... your example project has me off the ground, thanks much :cheers:

@GyroVorbis people have developed iOS apps with SDL, yes. 1.3 comes with some example projects for iPhone. between those and avansc's example project i feel i'm close.
Post Reply