Search code examples
iosxcodeduplicatestargetpch

XCode cannot find auto-generated swift header moduleName-Swift.h in pch file in duplicate target


I duplicated a target and get the following build error:

Resource/Prefix.pch:16:13: '<moduleName>-Swift.h' file not found

I can't see any difference between the two targets that would cause this problem.

Any ideas why this is happening?


Solution

  • The problem is that the duplicate target has a different moduleName.

    I had to add a C-flag in the duplicate target and use this in Prefix.pch. (A User-Defined Setting doesn't get seen when parsing the pch file.)

    enter image description here

    #ifdef DEVLOPMENT_SERVER
        #import "<duplicateModuleName>-Swift.h"
    #else
        #import "<moduleName>-Swift.h"
    #endif