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

2

5

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>
 ~~~~~~~^
Pilchard answered 13/12, 2017 at 1:51 Comment(0)
S
12

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

Selectivity answered 18/11, 2018 at 15:51 Comment(0)
P
0

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.

Pilchard answered 13/12, 2017 at 2:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.