简体   繁体   English

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

[英]How do I compile PCH with a different module cache path on Xcode

The initial error from Xcode was this before I changed the home folder's name: 在更改主文件夹的名称之前,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

I changed the name of the home folder of my mac after knowing through some research that Xcode does not accept nonalphanumeric characters on folder names (see: Mage's_Machine) 在通过一些研究得知Xcode不接受文件夹名称上的非字母数字字符后,我更改了我的mac的主文件夹的名称(请参阅:Mage's_Machine)

After doing that, I got this error: 这样做之后,我收到了这个错误:

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'

Is it correct that I changed the name of the home folder? 我更改了主文件夹的名称是否正确? If yes, how do I compile PCH with a different module cache path to fix this error? 如果是,如何使用不同的模块缓存路径编译PCH来修复此错误?

I'm using Cocoapods (Alamofire, SVProgressHUD, SwiftyJSON), after changing the home folder name, I got more errors. 我正在使用Cocoapods(Alamofire,SVProgressHUD,SwiftyJSON),在更改主文件夹名称后,我收到了更多错误。 One example of these errors: 这些错误的一个例子:

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>
 ~~~~~~~^

I experienced this error after moving my DerivedData location, but it equally makes sense that it would happen when changing the name of a parent folder. 我在移动DerivedData位置后遇到此错误,但同样有意义的是,更改父文件夹的名称时会发生这种情况。

  • Find your DerivedData location (listed in Preferences > Locations , as pictured below), and visit it in Finder by pressing SHIFT + + G . 找到您的DerivedData位置(在Preferences > Locations列出,如下图所示),然后按Shift + + G在Finder中访问它。

  • Delete the ModuleCache folder and rebuild your target; 删除ModuleCache文件夹并重建目标; if it still fails, you may also need to delete the ModuleCache.noindex folder, too. 如果仍然失败,您可能还需要删除ModuleCache.noindex文件夹。

As far as I understand, this process rebuilds the module cache for all built modules. 据我所知,此过程为所有构建的模块重建模块高速缓存。 There's likely no need to clean all of DerivedData ; 可能不需要清除所有DerivedData ; just these particular files. 只是这些特定的文件。

DerivedData位置

After researching more, I found the fixes for all the errors, though there are still some warnings. 在研究了更多之后,我找到了所有错误的修复程序,尽管仍有一些警告。

Alyoshak's answer on the question on this link ( How to fix PCH error? ) fixed all the errors on my code. Alyoshak对此链接问题的回答( 如何修复PCH错误? )修复了我的代码上的所有错误。

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

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