Cocoapod ": Failed to create module" UIKit "

I am trying to displace MuPDF into a jog. It's not as good as I want it to, though ...

error: could not build module 'UIKit'

      

This is the error I get every time I try pod lib lint

. I get this in two flavors, though, depending on the exact content of the podspec. But before that, some context!

tl; dr : My brain can't handle MuPDF and its static dependencies in the library to make a good podspec out of it. You can help?


File layout

So the library is MuPDF ( http://mupdf.com ); I cloned their git repository. It comes with a bunch of files .m

, but the core library is written in C and has a few dependencies. Thus, we get several static libraries ( .a

files). The file layout looks something like this:

mupdf/
  # objc files
  platform/ios/common.{h,m}
  platform/ios/Classes/*.{h,m}

  # headers and static libraries
  include/**/*.h
  platform/ios/thirdparty/*.a

      

The folder include

contains the headers required by the libraries in the platform/ios/thirdparty

. These headers are included platform/ios/common.h

.

Podspec

And my podspec looks something like this:

Pod::Spec.new do |s|
  # <enter usual podspec yada yada here>

  s.source_files  = "platform/ios/Classes/**/*.{h,m}", "platform/ios/common.{h,m}", "include/**/*.h"
  s.public_header_files = "platform/ios/Classes/**/*.h"
  s.header_mappings_dir = "include"

  s.libraries = "z"
  s.vendored_libraries = "platform/ios/thirdparty/*"
end

      


Based on this (and the podspec variation), I am getting two different errors.

Symbol override error

With this exact podspec configuration, I am getting the following errors:

- ERROR |  /<path>/mupdf/include/mupdf/fitz/math.h:97:8:
           error: redefinition of 'fz_point_s'
- NOTE  |  /<path>/mupdf/include/mupdf/fitz/math.h:97:8:
           note: previous definition is here
- ERROR |  /<path>/mupdf/include/mupdf/fitz/math.h:121:8:
            error: redefinition of 'fz_rect_s'
- NOTE  |  /<path>/mupdf/include/mupdf/fitz/math.h:121:8:
           note: previous definition is here

# etc. etc.

- NOTE  |  Target Support Files/Pods-mupdf/Pods-mupdf-prefix.pch:2:9:
           fatal error: could not build module 'UIKit'

      

Circular dependency error

If I comment out the line s.public_header_files

, I get a circular dependency error. So weird!

- NOTE  |  /privateTarget Support Files/Pods-mupdf/Pods-mupdf-umbrella.h:1:9:
           fatal error: cyclic dependency in module 'UIKit':
           UIKit -> Foundation -> CoreFoundation -> MuPDF -> UIKit

      


Conclusion

My brain hurts, please help!

+3


source to share


2 answers


I'm not really sure what's going on with your PodSpec, sorry. It probably has something to do with the way you resolved the conflicting math.h header file - it's a shame to get that right in the pod spec.

I just created a CocoaPod for MuPDF and created a sample app based on this module and everything seems to be working fine.



For reference, here's my pod spec (note that this is now deprecated, refer to the published mupdf pod spec for one compatible with latest mupdf and latest CocoaPods):

# podspec for MuPDF
#
# Copyright (C) 2015 Joseph Heenan <joseph@heenan.me.uk>

Pod::Spec.new do |s|
  s.name             = "MuPDF"
  s.version          = "1.7"
  s.summary          = "A lightweight PDF and XPS viewer."
  s.description      = <<-DESC
                       MuPDF is a small, fast, and yet complete PDF viewer. 
                       It supports PDF 1.7 with transparency, encryption, 
                       hyperlinks, annotations, searching and more. It also
                       reads XPS and OpenXPS documents.
                       DESC
  s.homepage         = "http://www.mupdf.com/"
  s.license          = { :type => "Affero GNU GPL v3", :file => 'COPYING' }
  s.author           = "Artifex Software Inc"
  s.source           = { :git => "https://github.com/ArtifexSoftware/mupdf.git", :tag => s.version.to_s }

  s.platform     = :ios, '6.1'
  s.requires_arc = false

  s.source_files = 'platform/ios/Classes/**/*.[mh]', 'platform/ios/common.[mh]'
  s.resources = 'platform/ios/*.png', 'platform/android/res/drawable-ldpi/*.png'

  s.public_header_files = "platform/ios/Classes/**/*.h", "platform/ios/common.h"

  # See https://github.com/CocoaPods/CocoaPods/issues/1437
  s.preserve_paths = "include/*", "include/**/*"

  s.prepare_command = <<-CMD
      # I tried --depth 1 here but it failed with git error "fatal: reference is not a tree:"
      git submodule update --init
      cd platform/ios

      # build the various .a files
      # release armv7 + arm64
      xcodebuild -scheme MuPDF -configuration Release CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
      # release i386 + x86_64
      xcodebuild -scheme MuPDF -configuration Release -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

      # combine into fat libraries
      cd ../../build/
      for i in curl freetype jbig2dec jpeg mujs mupdf openjpeg z; do
          LIB=lib${i}.a
          lipo -create -output $LIB release-ios-i386-x86_64/$LIB release-ios-armv7-arm64/$LIB
      done
CMD

  s.vendored_libraries = "build/*.a"

  s.xcconfig = {
    # we have a math.h which conflicts with the system math.h unless
    # we disable header maps
    'USE_HEADERMAP' => 'NO',
    'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Target Support Files/Pods"',

    'USER_HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/MuPDF/include"',

    'ALWAYS_SEARCH_USER_PATHS' => 'NO'
  }

end

      

+4


source


I solved the problem by removing and adding UIKit.framework to Build Phases -> Link Binary With Libraries and setting the minimum version to iOS 6.0.



0


source







All Articles