ios - 如何在 Xcode 上使用不同的模块缓存路径编译 PCH

标签 ios swift xcode pch

在我更改主文件夹的名称之前,Xcode 的初始错误是这样的:

<unknown>:0: error: invalid virtual filesystem overlay file '/Users/Mage's_Machine/Library/Developer/Xcode/DerivedData/Clima-flpmhdjedajchpfzcevzpufjznko/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/SwiftyJSON.build/unextended-module-overlay.yaml'

<unknown>:0: error: clang importer creation failed

通过一些研究得知 Xcode 不接受文件夹名称中的非字母数字字符后,我更改了 mac 主文件夹的名称(参见:Mage's_Machine)

这样做之后,我得到了这个错误:

error: PCH was compiled with module cache path '/Users/Mage's_Machine/Library/Developer/Xcode/DerivedData/ModuleCache/2RH9SWJYJWLH7', but the path is currently '/Users/Mage/Library/Developer/Xcode/DerivedData/ModuleCache/2RH9SWJYJWLH7'

我更改主文件夹的名称是否正确?如果是,我如何使用不同的模块缓存路径编译 PCH 以修复此错误?

我正在使用 Cocoapods(Alamofire、SVProgressHUD、SwiftyJSON),更改主文件夹名称后,出现更多错误。这些错误的一个例子:

While building module 'UIKit' imported from /Users/Mage/Desktop/Clima-iOS11-master2/Pods/Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch:2:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKitDefines.h:8:9: fatal error: could not build module 'Darwin'
#import <Availability.h>
 ~~~~~~~^

最佳答案

我在移动 DerivedData 位置后遇到了这个错误,但在更改父文件夹的名称时同样会发生这种错误。

  • 找到您的 DerivedData 位置(在 Preferences > Locations 中列出,如下图所示),然后按 SHIFT + + G

  • 删除 ModuleCache 文件夹并重建目标;如果仍然失败,您可能还需要删除 ModuleCache.noindex 文件夹。

据我了解,此过程会为所有构建的模块重建模块缓存。可能不需要清除所有 DerivedData;只是这些特定的文件。

DerivedData location

关于ios - 如何在 Xcode 上使用不同的模块缓存路径编译 PCH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47784349/

相关文章:

ios - 显示整个 UIPickerView,然后在选择后隐藏 UIPickerView

ios - 电话号码的 Swift 2 国家代码

ios - 如何根据多边形要素的属性值设置填充颜色?

Xcode 4 目标build设置 "Skip install"。它是什么?

ios - 为什么我所有提交到 Bitbucket 的 Xcode 在 Bitbucket 上显示其他用户 'Author Name'?

Objective-C:索引越界

ios - Xcode 8.1 显示 'try signing in again or contact apple support to resolve account access issue' 我该怎么办?

iphone - 如何使用 Quartz 绘制钢笔笔画?

ios - Objective-C -NSMutablearray 特定索引存储在另一个数组中

c++ - Objective-C++ 中的复杂类层次结构