gpt4 book ai didi

iphone - 如何将现有源代码文件正确添加到我的 Xcode 项目中?

转载 作者:行者123 更新时间:2023-12-03 18:44:50 31 4
gpt4 key购买 nike

我是 iPhone 开发新手,并且仍在熟悉 Mac 开发环境,包括 Xcode。我想向我的 iPhone 项目添加一些第 3 方代码,但是当我将“现有文件”添加到我的 Xcode 项目时,我会看到一个对话框,其中包含太多我不理解的选项,如下所示这样,我的项目就不起作用了。当我#import headerfilename.h时,我收到一个构建错误,内容为headerfilename.h:没有这样的文件或目录

alt text http://joecrotchett.com/images/misc/fileadd.jpg

  1. 任何人都可以向我解释所有这些选项的含义,或者给我一些文档的链接吗?我很难在 Apple 文档中找到任何内容。
  2. 我要选择哪些选项来将现有源代码文件添加到我的 Xcode 项目中?我应该注意,我尝试添加的源代码文件位于我的project/Classes/frameworkname/目录中。
  3. 添加后,我是否需要在项目设置中的任何位置引用这个新的代码目录(即某种头文件目录变量)?

非常感谢!

更新:我在苹果开发者论坛上找到了以下非常有用的答案/响应,帮助我解决了我的问题...

To make it simple : - if you do not check the copy option, the file stay where it is. - if you check it, it is copied in your project folders In the first case (what it seems you are doing) you need to tell the compiler that the header files are in another directory : - project info -> build -> search paths -> User Header Search Path : add the directory from where you took the header file Hope this will help

<小时/>

You have discovered the most confusing dialog box that ever came out of Cupertino. Six years of Xcode, and this thing still is partly a mystery to me. To even get that far, I had to make many test projects to try and reverse-engineer what this thing does. The "Copy" box means that it will copy the files as they are right now, into the project. If this box is not checked, then it just references those files during a build and copies them as they are at THAT time. For source code, you want the Copy box checked.
The "relative to" is a total mystery to me and I can't help you with that. I usually leave it however it is already set. Does it mean relative to where they are on disk, or the arrangement in Xcode, or in the bundle? Who knows. The last 2 radio buttons SEEM to mean that it will either re-create the folder structure of the folder you are adding, or just put "fake" folders in Xcode that point to the real folders. This is probably your problem - you are adding source code that is not all at the top level, and when it goes to find it, it does not re-create the hierarchy. Others can supply a better way, hopefully, but what I would do is put all of the source in one folder and add that, using the Copy box. Then in Xcode you can make whatever bogus folders you want and put the source file names in those fake folders.

最佳答案

这来自 Xcode 用户指南:

"The project navigator shows projects, groups, folders, and files:

The project or projects in your workspace window are the highest level of the hierarchy in the project navigator. Open the project’s disclosure triangle to see the groups, folders, and files in the project. Select the project to display the project editor, where you can view and edit project and target settings.

A group appears in the project navigator as a yellow folder icon. The group does not represent a folder on disk. Although you can organize your project in Xcode to reflect the organization of files on disk, moving files into and out of groups does not affect the content of the folders on disk, and moving files on disk into and out of folders does not affect the content of the groups in the project navigator.

A folder is a reference to a folder on disk and appears in the project navigator as a blue folder icon. The contents of the folder in the project navigator reflect the contents of the folder on disk. It’s important to note, however, that the files that appear in a folder icon in the project navigator are not part of your project unless you have added them to the project explicitly (in which case they appear directly under the project or in a group, as well as in the folder). You can view and edit the files in a folder, but to move files in and out of the folder you must use the Finder.

A file in the project navigator is a reference to a file on disk."

关于iphone - 如何将现有源代码文件正确添加到我的 Xcode 项目中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2883506/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com