Quick Tips And Tricks - What to do when you accidentally edit a precompiled header file in Xcode ?

         This is quite an irritating problem which I have been facing very often and had to google out for the solution everytime and try out all the possibilities mentioned/listed there and hoping fortunately something works. So basically lets understand what is the root cause of this problem ?
        Its normal for iOS programmers to check the precompiled header files of any framework to see the methods that class provides and to understand its internal details like protocols if any available and some cool enums and structs that might exist. Assume that to check some functionality you happen to see the UITableView.h file. Unfortunately by mistake if you happen to perform some edits then thereon you get stuck with an error saying "A precompiled header was changed at *Path(of your simulator path)*". On building the project you get to see a linker error as below

Apple LLVM 5.1 Error

fatal error: file '/Applications/Xcode 2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/*****.h' has been modified since the precompiled header '/Users/user/Library/Developer/Xcode/DerivedData/ModuleCache/xxxxxxxxxxx/UIKit.pcm' was built

     Now there are multiple suggestions and solutions provided when you google out the problem. Some of them might be
--> product + Clean
--> Deep Clean (Option+Command+Shift+K)

   But rather than struggling with these the solutions lies at your hands. Xcode is pretty intelligent in suggesting you do something which really works with much of head breaking on trying options which does help the least. If you can give a deeper look at you problem, just below the error Xcode even suggests the possible solution for the same which is as below

note: after modifying system headers, please delete the module cache at '/Users/user/Library/Developer/Xcode/DerivedData/ModuleCache/*******'.

If you can just do this and then clean and build the project, it starts working charm again. Save your time than googling and trying multiple options for much better things :)

1 comment: