Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

I can't get SDL 1.2 to run in Xcode 5

Up until recently, I've been using an eight year old iMac running OS X 10.6, but I just bought a brand new six core Mac Pro with OS X 10.10, and I've been trying to get my old SDL 1.2 programs to run.


I installed Xcode 5 on my new computer (I had read several bad reviews about Xcode 6). I tried opening my old Xcode docs and they wouldn't compile, which I figured might happen, so I went back to the same tutorial video that I used to set up SDL 1.2 on my old computer: http://youtu.be/d3TPsUAO3L4


And I tried to create a test project just to see if I could get the SDL window to open, but it still wouldn't compile. I got this long list of errors. These are a few of them:


/SDL1-2_SetUp/SDLMain.m:50:12: Cast of C pointer type 'CFDictionaryRef' (aka 'const struct __CFDictionary *') to Objective-C pointer type 'const NSDictionary *' requires a bridged cast

/SDL1-2_SetUp/SDLMain.m:166:16: 'release' is unavailable: not available in automatic reference counting mode

/SDL1-2_SetUp/SDLMain.m:166:16: ARC forbids explicit message send of 'release'

/SDL1-2_SetUp/SDLMain.m:167:15: 'release' is unavailable: not available in automatic reference counting mode

/SDL1-2_SetUp/SDLMain.m:167:15: ARC forbids explicit message send of 'release'

/SDL1-2_SetUp/SDLMain.m:182:15: 'release' is unavailable: not available in automatic reference counting mode

/SDL1-2_SetUp/SDLMain.m:182:15: ARC forbids explicit message send of 'release'


Anyway, I don't really understand what this all means, but I didn't get these errors with my SDL projects on my old computer, so I'm wondering if this is because SDL 1.2 is so old it won't run on a current OS? I spent so much time on these programs and I'd really like to be able to run them again, but I don't have the knowhow to update all my code for SDL 2.0. If anyone has any ideas on how to get SDL 1.2 to run in Xcode 5, I'd be so grateful! And keep in mind that I'm still fairly new to coding (as you've probably guessed), so please try to give me the preschool version! Thank you.

Mac Pro, OS X Yosemite (10.10.2), Late 2013, 3.5 GHz 6-Core

Posted on Mar 5, 2015 7:20 PM

Reply
7 replies

Mar 5, 2015 7:47 PM in response to Explodey

There's nothing seriously wrong with Xcode 6.

Use the latest development tools so you can get the best support here and elsewhere.

The messages with ARC (Automatic Reference Counting) mean you code contains references to methods that are no longer valid.

With ARC, it's no longer necessary nor allowed to use 'release' or 'dealloc', etc.

Get rid of Xcode 5, download Xcode 6 from the Mac App Store and look at the Xcode documentation for more information about ARC.

Mar 5, 2015 9:40 PM in response to Explodey

New projects created in Xcode 5 and 6 have automatic reference counting (ARC) enabled. SDL 1.2 does not support ARC, which is why you are getting the compiler errors.


To fix this, you must turn off ARC for your project. Set the Objective-C Automatic Reference Counting build setting to NO. You can access your project's build settings by selecting the project from the project navigator on the left side of the project window.

Mar 6, 2015 6:58 PM in response to Mark Szymczyk

Hey can someone tell me where in my Xcode project's folder hierarchy I should put documents like images and stuff so SDL can find them? I thought I could just drag images files into the project, but every time I run it, it can't find my image. So then I put a copy of my image into every folder and subfolder in my project, but it still can't find it.


When I had this problem on my old computer, I would just put a copy of the document into the build/debug folder in my project, but Xcode 5 doesn't seem to create any such folder.

Mar 6, 2015 9:56 PM in response to Explodey

The problem is not with the Xcode project folder hierarchy. Your problem is a flaw in the Mac version of SDL 1.2. When you add image files to an Xcode project, Xcode places them in the Resources folder of your application bundle. But the Mac version of SDL 1.2 sets the working directory to the directory containing the application bundle so your game can't find the image files.


There are two ways to solve the problem. The manual way is to go into your game's app bundle and move the image files from the Resources folder to the directory containing the app bundle. Select your app, right-click, and choose Show Package Contents to access your game's app bundle. The better way is to change the working directory to the app bundle's Resources folder. To change the working directory, open the SDLMain.m file and modify the setupWorkingDirectory: method. The following code sets the working directory to the app bundle's Resources folder:


NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
[[NSFileManager defaultManager] changeCurrentDirectoryPath:resourcePath];


SDL 2 fixes a lot of annoyances with setting up SDL on OS X. You should look into it.

Mar 6, 2015 10:05 PM in response to Mark Szymczyk

Thanks for your advice Mark, but I actually managed to get it working on my own. I don't know if what I did is any better or worse than what you suggested, but here's what I did: After I posted that last message, I realized that all the build folders in all my old Xcode projects had disappeared in the process of migrating to my new computer. I still don't really understand why. I had to go back to my old computer and recopy all my old project folders, and then I had to enable legacy target settings in the Xcode project settings. Then I was finally able to get my old programs to run.

I'm so glad I hadn't yet gotten rid of my computer, or this would have been a huge disaster!

I can't get SDL 1.2 to run in Xcode 5

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.