简体   繁体   English

如何将具有自定义扩展名的文件添加到 XCode 中的 bundle/resource 文件夹?

[英]How to add file with custom extension to bundle/resource folder in XCode?

I have a problem.我有个问题。 I have been made a file with custom extension like.xyz in resource folder.我已经在资源文件夹中创建了一个自定义扩展名的文件,例如 .xyz。 But when I running the application, the file wasn't in resource folder.但是当我运行应用程序时,该文件不在资源文件夹中。 How can I add the file with custom extension?如何添加具有自定义扩展名的文件? Anybody can help me?任何人都可以帮助我吗?

Thanks before.之前谢谢。 Regards.问候。

You need to make sure that this.xyz file is in the Copy Resources phase of your application's target.您需要确保 this.xyz 文件位于应用程序目标的 Copy Resources 阶段。

simple drag n drop to your resources folder and check copy items to resources folder option.简单地拖放到您的资源文件夹并选中将项目复制到资源文件夹选项。 That's it.而已。

what do you mean with "the file wasn't in resource folder"? “文件不在资源文件夹中”是什么意思? do you want to move it into Documents directory?你想把它移到Documents目录吗? if yes, you just can move your file from resource into Documents , i was do something like that with this code:如果是的话,你可以将你的文件从resource移动到Documents ,我用这段代码做了类似的事情:

[[NSFileManager defaultManager] moveItemAtPath:resourcePath toPath:documentsPath error:NULL];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM