Page 1 of 1

Xcode 4 and SDL Templates

Posted: Sat Mar 19, 2011 8:22 pm
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...

Re: Xcode 4 and SDL Templates

Posted: Sun Mar 20, 2011 1:32 am
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.

Re: Xcode 4 and SDL Templates

Posted: Thu Jul 14, 2011 4:44 pm
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!

Re: Xcode 4 and SDL Templates

Posted: Thu Jul 14, 2011 5:57 pm
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.

Re: Xcode 4 and SDL Templates

Posted: Thu Jul 14, 2011 6:05 pm
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.

Re: Xcode 4 and SDL Templates

Posted: Thu Jul 14, 2011 6:09 pm
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.

Re: Xcode 4 and SDL Templates

Posted: Thu Jul 14, 2011 6:50 pm
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?

Re: Xcode 4 and SDL Templates

Posted: Thu Jul 14, 2011 7:47 pm
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

Re: Xcode 4 and SDL Templates

Posted: Thu Jul 14, 2011 8:16 pm
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?

Re: Xcode 4 and SDL Templates

Posted: Thu Jul 14, 2011 9:58 pm
by avansc
I'll make a genuine xcode4 SDL template for you tomorrow.

Re: Xcode 4 and SDL Templates

Posted: Sat Jul 16, 2011 1:30 pm
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.