Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

ios

swift

pch

The initial error from Xcode was this before I changed the home folder's name:

<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)

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?

I'm using Cocoapods (Alamofire, SVProgressHUD, SwiftyJSON), after changing the home folder name, I got more errors. 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>
 ~~~~~~~^
like image 665
Mary Grace Ona Avatar asked Dec 13 '17 01:12

Mary Grace Ona


1 Answers

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.

  • Find your DerivedData location (listed in Preferences > Locations, as pictured below), and visit it in Finder by pressing SHIFT + + G.

  • Delete the ModuleCache folder and rebuild your target; if it still fails, you may also need to delete the ModuleCache.noindex folder, too.

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; just these particular files.

DerivedData location

like image 132
Jamie Birch Avatar answered Oct 24 '22 00:10

Jamie Birch