4

I'm getting an error when I try to build my MacOS app in Xcode.

Command MergeSwiftModule failed with a nonzero exit code.

error: umbrella for module 'PDFKit' already covers this directory
        umbrella header "PDFKit.h"
                        ^
error: inferred submodules require a module with an umbrella
        module * { export * }

Most of my Swift files have:

import Cocoa
import Quartz

I'm using PDFKit a lot, so I'm guessing it's something to do with importing and referencing the headers. The error occurs on Xcode 11.1 and 11.2.

I have tried a Clean Build, without success. There are other threads about this, such as this one, which seem to suggest that it's a non-specific, intermittent problem.

benwiggy
  • 1,440
  • 17
  • 35
  • Do you #import in code? You got this error because the Quartz framework umbrella header already has PDFKIt import. – Parag Bafna Apr 01 '20 at 10:28
  • I'm using Swift, so I just used the import Quartz statements as above. Note that after removing the import commands and then restoring them exactly as before, the problem fixed itself. – benwiggy Apr 01 '20 at 10:32
  • I am able to fix this by replacing PDFKit import by Quartz and deleted PDFKit.framework from the build phase. – Parag Bafna Apr 01 '20 at 10:34

2 Answers2

3

In my case, the compilation error was due to the import of a custom framework that in turns imported PDFKit. I changed the import PDFKit in the framework code with import Quartz, and that workaround solved the problem in Xcode 11.6.

Xcode 12 beta 3 seems to work better and does not require any workaround to build the existing code.

mbt
  • 155
  • 10
1

Because of the nature of the error messages, I deleted all the import Quartz statements from all the files, then tried to Build. Obviously, it then failed because of unknown objects.

Then, I restored the import Quartz lines, and the problem was fixed.

This does seem to be a bug in Xcode.

benwiggy
  • 1,440
  • 17
  • 35
  • If you are using interoperability in your swift project, ensure you replace any `#import ` with the appropriate replacement `#import `. – Chris Zielinski Jun 14 '21 at 19:15
  • I think we're all already Quartz over PDFKit that, aren't we? But I'm not sure I know what 'using interoperability' is. – benwiggy Jun 15 '21 at 07:01