gpt4 book ai didi

ios - Cocoapod "error: could not build module ' UIKit'"

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:42:46 26 4
gpt4 key购买 nike

我正在尝试将 MuPDF 放入 podspec 中。但这并没有我想要的那么好...

error: could not build module 'UIKit'

这是我每次尝试 pod lib lint 时遇到的错误。不过,我有两种版本,具体取决于 podspec 的具体内容。但在此之前,请了解一些背景信息!

tl;dr:我的大脑无法处理 MuPDF 及其静态库依赖项,无法从中制作出漂亮的 podspec。你能帮忙吗?


文件布局

所以库是 MuPDF ( http://mupdf.com );我克隆了他们的 git 仓库。它带有一堆 .m 文件,但主要库是用 C 编写的,并且有几个依赖项。所以我们最终得到了一些静态库(.a 文件)。文件布局看起来像这样:

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

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

include 文件夹包含 platform/ios/thirdparty 中的库所需的 header 。这些 header 包含在 platform/ios/common.h 中。

播客规范

我的 podspec 看起来像这样:

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

基于此(以及 podspec 的变体),我得到了两个不同的错误。

符号重定义错误

使用这个精确的 podspec 配置,我得到以下错误:

- 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'

循环依赖错误

如果我注释掉 s.public_header_files 行,我最终会遇到循环依赖错误。太奇怪了!

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

结论

脑袋疼,求助!

最佳答案

抱歉,我不太确定您的 PodSpec 发生了什么。这可能与您如何解决 math.h 头文件冲突有关 - 在 pod 规范中正确解决这个问题非常棘手。

我刚刚创建了一个 CocoaPod for MuPDF ,并创建了一个 example application based on that pod ,一切似乎都正常。

此处供引用的是我的 pod 规范(请注意,它现在已过时;请参阅 published mupdf pod spec 以获得与最新版本的 mupdf 和最新 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

关于ios - Cocoapod "error: could not build module ' UIKit'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30637231/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com