Xcode SDL资源文件夹 [英] Xcode SDL resources folder

查看:133
本文介绍了Xcode SDL资源文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Xcode中创建一个SDL项目,并且有一个名为resources的文件夹,用于存储我的图像.为了使我的SDL应用程序能够使用SDL_LoadBMP访问这些图像,资源文件夹必须与可执行文件位于同一文件夹中.每次我想运行应用程序(我不需要不知道为什么所有随机字符都在文件夹链接中).我一直在关注Lazy Foo的第一个SDL教程: http://lazyfoo.net/SDL_tutorials/lesson01/index2 .php ,我正在尝试在屏幕上显示图像.我不需要在这里显示我的代码,因为它与我链接到的教程完全相同,除了不是SDL_LoadBMP("hello.bmp"),而是SDL_LoadBMP("resources/images/hello.bmp").一旦将资源文件夹复制到产品目录中,该应用程序便开始工作.我打算显示该文件夹的图像,依此类推,但没有足够的信誉".

I am making a SDL project in Xcode and I have a folder called resources where my images are stored. For my SDL application to access these images with SDL_LoadBMP the resources folder needs to be in the same folder as the executable file. I don't want to have to copy and paste my resources into the "/Users/admin/Library/Developer/Xcode/DerivedData/SDL_app-awvygturnguyeqgwpjowmouadbjf/Build/Products/Debug" folder every time I want to run an application (I don't know why all the random characters are in the folder link). I have been following Lazy Foo's first SDL tutorial: http://lazyfoo.net/SDL_tutorials/lesson01/index2.php and I am trying to display an image on the screen. I don't need to show my code in here because it is the exact same as the tutorial I linked to except instead of SDL_LoadBMP("hello.bmp") it is SDL_LoadBMP("resources/images/hello.bmp"). The application works as soon as I copy the resources folder into the product directory. I was going to show an image of the folder and so on but I didn't have enough 'reputation'.

推荐答案

为了确保文件夹被复制,您需要将文件夹添加到Xcode项目中,然后在构建阶段中创建复制"步骤.默认情况下,对于被系统标识为资源"的项目(.strings文件,.xib文件等),存在一个复制阶段".但是,对于其他文件,则需要专门创建一个复制阶段".

In order to make sure the folder gets copied, you need to add the folder to your Xcode project and then create a Copy step in your Build Phases. By default, there is a Copy Phase for items that are identified as Resources by the system (.strings files, .xib files, etc.) However, for additional files, you'll need to create a Copy Phase specifically.

要这样做:

  1. 在Xcode中,选择您的项目和目标,然后选择Build Phases标签
  2. 单击Add Build Phase按钮,然后选择Add Copy Files
  3. 选择副本的Destination位置(这是层次结构的顶部",您也可以使用Subpath字段指定子目录)
  4. 现在将文件夹或文件从项目导航器拖到新的复制阶段
  1. In Xcode, select your project and Target and choose the Build Phases tab
  2. Click on the Add Build Phase button and choose Add Copy Files
  3. Select the Destination location for the copy (this is the "top" of the hierarchy, you can also specify sub-directories using the Subpath field)
  4. Now drag the folders or files from the Project Navigator into the new Copy Phase

构建可执行文件时,将在您定向文件时对其进行复制.

When you build your executable, the files will be copied as you direct them.

如果在Xcode之外修改了SDL文件,则可能要将该文件夹作为文件夹引用而不是作为单个文件导入.这可能有点棘手,但它会使Xcode复制文件夹的当前内容,而不是仅复制已添加到项目中的项目.否则,只需将SDL文件直接导入Xcode项目并分别进行管理即可.

If your SDL files are being modified outside of Xcode, you may want to import the folder as a Folder Reference instead of as individual files. This can be a little tricky, but it causes Xcode to copy the current contents of the folder, as opposed to just the items that you've added to the Project. Otherwise, just import the SDL files directly into the Xcode project and manage them individually.

这篇关于Xcode SDL资源文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆