objective-c - Xcode 4(和依赖项)的编译、构建或存档问题

这个问题在过去几周内已经演变为涵盖 xcode4 的更一般问题。 (以及从旧的 xcode s 升级项目)。

但是,许多问题可以通过遵循相同的说明来解决。

如果您有以下任何问题,请尝试接受答案中的方法:

  • Xcode 4 无法归档应用
  • Xcode 4 创建了一个无法使用的存档
  • Xcode 4 不会创建 .ipa
  • 由于预处理器错误,Xcode 4 无法编译
  • Xcode 4 找不到 header
  • Xcode 4 的代码完成不工作
  • 无法编译项目依赖项
  • 添加依赖项会导致上述任何问题

原始问题

标题:Xcode 4 中的“词法或预处理器问题文件未找到”

我在 Xcode 4 中有一个项目,可以正常构建并在设备和模拟器上运行,但是在查找与静态库关联的头文件时尝试存档时出错:

In file included from /Volumes/Development/Path/LBProject/LBProject/LBProject-Prefix.pch:15:
In file included from /Volumes/Development/Path/LBProject/LBFDefines.h:23:
In file included from /Volumes/Development/Path/LBProject/Classes/LBProjectAppDelegate.h:11:
In file included from /Volumes/Development/Path/LBProject/LBProject/../FKNDirectory/FKNDirectoryManager.h:10:
/Volumes/Development/Path/LBProject/LBProject/../FKNDirectory/FKNDataModel.h:11:9: fatal error: 'Merchant.h' file not found [1]
 #import "Merchant.h"
         ^
1 error generated. 

Xcode 报错

lexical or preprocessor issue file not found 

Much 谷歌搜索显示很多人都遇到了这个问题,但没有解决方案。任何人都得到了修复甚至线索。

更新:user header 搜索路径在所有配置中都设置为 ${BUILT_PRODUCTS_DIR}。除了存档时,它使用任何配置都可以很好地构建。

更新 2: Merchant.h 是一个自动生成的核心数据类,因此在 .xcdatamodeld 包中,但是标题建库时都复制到public headers目录中。

最佳答案

NB: The steps below will solve 90% of your Xcode archive issues however, from the comments it is suggested you try quitting Xcode first. This may save you hours of setting tweaking.

  1. 检查“用户 header 路径”是否正确(在您的项目和依赖项中将“”添加到空格的路径)
  2. 将“始终搜索用户路径”设置为"is"
  3. 在您的项目中创建一个名为“索引标题”的组并将标题拖到该组,不要在出现提示时添加到任何目标。这包括 .xcdatamodeld 中的所有标题,您需要右键单击并查看包内容才能找到它们。
  4. 对于所有依赖项,将 “跳过安装” build设置设置为 "is"
  5. 将构建阶段中的任何“公共(public)”标题移动到“项目”
  6. 将目标上的build设置 “安装目录” 设置为 $(LOCAL_APPS_DIR)
  7. 将目标build设置“扫描所有源文件以查找包含”更改为"is"。 ( link )
  8. 对于较新版本的 Xcode (> 4.2),您可能希望 read this question与工作空间相关。
  9. 手动 delete the project.xcworkspace files形成所有引用的项目

https://stackoverflow.com/questions/5584317/

相关文章:

objective-c - 按名称创建objective-c类实例?

objective-c - Swift 变量是原子的吗?

iphone - 如何拦截点击 UITextView 中的链接?

objective-c - 如何在 Xcode 中定义预处理器符号

objective-c - 在Objective-C中将一个类的实例转换为@protocol

objective-c - ViewController 响应选择器 : message sent

ios - 获取当前页面

objective-c - 如何使用 performSelector :withObject:aft

objective-c - 无法使用 nil 模型创建 NSPersistentStoreCoord

objective-c - 数字后的 "f"