1

I'm trying to add mupdf framework to a swift project. I created a new project and copied the mupdfdk.framework to my project and referenced it in the frameworks section. Following is a screenshot of the documentation.

enter image description here

Now my project looks like this.

enter image description here

Then when I try to import it in viewcontroller, I get Could not build Objective-C module 'mupdfdk' error. Are there any other steps I'm missing? Please help.

Lak
  • 381
  • 1
  • 5
  • 23
  • Perhaps something is wrong with the mupdfdk.framework you have - where did you get it from? Can you build the mupdfdk example app okay? – JosephH Nov 09 '20 at 11:41
  • Yes, the example app builds and runs fine. I copied the mupdfdk.framework from the example app. – Lak Nov 09 '20 at 11:53

1 Answers1

2

You need to add this bridging header:

MuPDF-Bridging-Header.h

#ifndef MuPDF_Bridging_Header_h
#define MuPDF_Bridging_Header_h
#import "mupdfdk.framework/Headers/mupdfdk.h"
#endif /* MuPDF_Bridging_Header_h */

and declare it within the Swift Compiler section of the Build Settings:

enter image description here

Paul Gardiner
  • 468
  • 2
  • 7
  • Actually, that step should be unnecessary, and what the OP was doing should have worked without it. There's a fault in this version of mupdfdk.framework. If you edit the contained file mupdfdk.modulemap and correct "sodk.h" to "mupdfdk.h" that will fix the problem. Thank you to [JosephH] for pointing this out through other channels. – Paul Gardiner Nov 12 '20 at 12:23