安装任何新的 Cocoapod 都会导致构建失败

Posted

技术标签:

【中文标题】安装任何新的 Cocoapod 都会导致构建失败【英文标题】:Installation of any new Cocoapod is causing build failure 【发布时间】:2019-10-15 00:00:54 【问题描述】:

我有一个简单的 Xcode 项目,其中已经安装了一些 Pod(与 Google Firebase 相关)。与这些一起工作的一切都很好。但是,任何安装 任何 个额外 Pod 的尝试都会导致 Xcode 项目无法编译。我在下面提供了两个例子。请注意,下面的两个 pod 都失败并出现相同的错误

LBTA 组件

我正在尝试安装 LBTAComponents 吊舱。

我将 pod "LBTAComponents" 添加到 Podfile 并运行 Pod install。然后我构建项目,构建失败并出现错误 /Users/admin/testApp/Pods/leveldb-library/port/port_posix.h:77:35: Use of undeclared identifier '__BYTE_ORDER'

我已经尝试了标准的故障排除步骤,例如清理构建数据和删除 Derived Data 文件夹。问题依旧

AFNetworking

我在使用 AFNetwoking pod 时遇到了类似的问题。

我将 pod 'AFNetworking', '~> 3.0'" 添加到 Podfile 并运行 Pod install。然后我构建项目,再次构建失败并出现错误 /Users/admin/testApp/Pods/leveldb-library/port/port_posix.h:77:35: Use of undeclared identifier '__BYTE_ORDER'这与上一个示例的错误相同。

同样,我之前提到的标准故障排除步骤并没有解决问题。

我将再次强调,Google 的 Firebase pod 的安装运行良好。但是,后续的 pod 安装会产生我上面描述的错误。

知道如何纠正这个问题吗?干杯!

LBTA 组件

好的,因此尝试安装与 Firebase 相关的任何其他 Pod 也会导致与上述相同的构建失败。所以似乎我无法安装任何新的 Pod。

作为参考,这是我的 Podfile:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'App' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for App
  pod 'Firebase'
  pod 'Firebase/Analytics'
  pod 'Firebase/Auth'
  pod 'Firebase/Storage'
  pod 'Firebase/Firestore'
  pod 'Firebase/Database'

  target 'AppTests' do
    inherit! :search_paths
    # Pods for testing
    pod 'Firebase'
    pod 'Firebase/Analytics'
    pod 'Firebase/Auth'
    pod 'Firebase/Storage'
    pod 'Firebase/Firestore'
    pod 'Firebase/Database'
  end

  target 'AppUITests' do
    inherit! :search_paths
    # Pods for testing
    pod 'Firebase'
    pod 'Firebase/Analytics'
    pod 'Firebase/Auth'
    pod 'Firebase/Storage'
    pod 'Firebase/Firestore'
    pod 'Firebase/Database'
  end

end

还有我的 Podfile.lock:

PODS:
  - BoringSSL-GRPC (0.0.3):
    - BoringSSL-GRPC/Implementation (= 0.0.3)
    - BoringSSL-GRPC/Interface (= 0.0.3)
  - BoringSSL-GRPC/Implementation (0.0.3):
    - BoringSSL-GRPC/Interface (= 0.0.3)
  - BoringSSL-GRPC/Interface (0.0.3)
  - Firebase (6.9.0):
    - Firebase/Core (= 6.9.0)
  - Firebase/Analytics (6.9.0):
    - Firebase/Core
  - Firebase/Auth (6.9.0):
    - Firebase/CoreOnly
    - FirebaseAuth (~> 6.2.3)
  - Firebase/Core (6.9.0):
    - Firebase/CoreOnly
    - FirebaseAnalytics (= 6.1.2)
  - Firebase/CoreOnly (6.9.0):
    - FirebaseCore (= 6.3.0)
  - Firebase/Database (6.9.0):
    - Firebase/CoreOnly
    - FirebaseDatabase (~> 6.1.0)
  - Firebase/Firestore (6.9.0):
    - Firebase/CoreOnly
    - FirebaseFirestore (~> 1.5.1)
  - Firebase/Storage (6.9.0):
    - Firebase/CoreOnly
    - FirebaseStorage (~> 3.4.1)
  - FirebaseAnalytics (6.1.2):
    - FirebaseCore (~> 6.3)
    - FirebaseInstanceID (~> 4.2)
    - GoogleAppMeasurement (= 6.1.2)
    - GoogleUtilities/AppDelegateSwizzler (~> 6.0)
    - GoogleUtilities/MethodSwizzler (~> 6.0)
    - GoogleUtilities/Network (~> 6.0)
    - "GoogleUtilities/NSData+zlib (~> 6.0)"
    - nanopb (~> 0.3)
  - FirebaseAuth (6.2.3):
    - FirebaseAuthInterop (~> 1.0)
    - FirebaseCore (~> 6.2)
    - GoogleUtilities/AppDelegateSwizzler (~> 6.2)
    - GoogleUtilities/Environment (~> 6.2)
    - GTMSessionFetcher/Core (~> 1.1)
  - FirebaseAuthInterop (1.0.0)
  - FirebaseCore (6.3.0):
    - FirebaseCoreDiagnostics (~> 1.0)
    - FirebaseCoreDiagnosticsInterop (~> 1.0)
    - GoogleUtilities/Environment (~> 6.2)
    - GoogleUtilities/Logger (~> 6.2)
  - FirebaseCoreDiagnostics (1.1.0):
    - FirebaseCoreDiagnosticsInterop (~> 1.0)
    - GoogleDataTransportCCTSupport (~> 1.0)
    - GoogleUtilities/Environment (~> 6.2)
    - GoogleUtilities/Logger (~> 6.2)
  - FirebaseCoreDiagnosticsInterop (1.0.0)
  - FirebaseDatabase (6.1.0):
    - FirebaseAuthInterop (~> 1.0)
    - FirebaseCore (~> 6.0)
    - leveldb-library (~> 1.18)
  - FirebaseFirestore (1.5.1):
    - FirebaseAuthInterop (~> 1.0)
    - FirebaseCore (~> 6.2)
    - FirebaseFirestore/abseil-cpp (= 1.5.1)
    - "gRPC-C++ (= 0.0.9)"
    - leveldb-library (~> 1.22)
    - nanopb (~> 0.3.901)
    - Protobuf (~> 3.1)
  - FirebaseFirestore/abseil-cpp (1.5.1):
    - FirebaseAuthInterop (~> 1.0)
    - FirebaseCore (~> 6.2)
    - "gRPC-C++ (= 0.0.9)"
    - leveldb-library (~> 1.22)
    - nanopb (~> 0.3.901)
    - Protobuf (~> 3.1)
  - FirebaseInstanceID (4.2.5):
    - FirebaseCore (~> 6.0)
    - GoogleUtilities/Environment (~> 6.0)
    - GoogleUtilities/UserDefaults (~> 6.0)
  - FirebaseStorage (3.4.1):
    - FirebaseAuthInterop (~> 1.0)
    - FirebaseCore (~> 6.0)
    - GTMSessionFetcher/Core (~> 1.1)
  - GoogleAppMeasurement (6.1.2):
    - GoogleUtilities/AppDelegateSwizzler (~> 6.0)
    - GoogleUtilities/MethodSwizzler (~> 6.0)
    - GoogleUtilities/Network (~> 6.0)
    - "GoogleUtilities/NSData+zlib (~> 6.0)"
    - nanopb (~> 0.3)
  - GoogleDataTransport (2.0.0)
  - GoogleDataTransportCCTSupport (1.1.0):
    - GoogleDataTransport (~> 2.0)
    - nanopb
  - GoogleUtilities/AppDelegateSwizzler (6.3.1):
    - GoogleUtilities/Environment
    - GoogleUtilities/Logger
    - GoogleUtilities/Network
  - GoogleUtilities/Environment (6.3.1)
  - GoogleUtilities/Logger (6.3.1):
    - GoogleUtilities/Environment
  - GoogleUtilities/MethodSwizzler (6.3.1):
    - GoogleUtilities/Logger
  - GoogleUtilities/Network (6.3.1):
    - GoogleUtilities/Logger
    - "GoogleUtilities/NSData+zlib"
    - GoogleUtilities/Reachability
  - "GoogleUtilities/NSData+zlib (6.3.1)"
  - GoogleUtilities/Reachability (6.3.1):
    - GoogleUtilities/Logger
  - GoogleUtilities/UserDefaults (6.3.1):
    - GoogleUtilities/Logger
  - "gRPC-C++ (0.0.9)":
    - "gRPC-C++/Implementation (= 0.0.9)"
    - "gRPC-C++/Interface (= 0.0.9)"
  - "gRPC-C++/Implementation (0.0.9)":
    - "gRPC-C++/Interface (= 0.0.9)"
    - gRPC-Core (= 1.21.0)
    - nanopb (~> 0.3)
  - "gRPC-C++/Interface (0.0.9)"
  - gRPC-Core (1.21.0):
    - gRPC-Core/Implementation (= 1.21.0)
    - gRPC-Core/Interface (= 1.21.0)
  - gRPC-Core/Implementation (1.21.0):
    - BoringSSL-GRPC (= 0.0.3)
    - gRPC-Core/Interface (= 1.21.0)
    - nanopb (~> 0.3)
  - gRPC-Core/Interface (1.21.0)
  - GTMSessionFetcher/Core (1.2.2)
  - leveldb-library (1.22)
  - nanopb (0.3.901):
    - nanopb/decode (= 0.3.901)
    - nanopb/encode (= 0.3.901)
  - nanopb/decode (0.3.901)
  - nanopb/encode (0.3.901)
  - Protobuf (3.10.0)

DEPENDENCIES:
  - Firebase
  - Firebase/Analytics
  - Firebase/Auth
  - Firebase/Database
  - Firebase/Firestore
  - Firebase/Storage

SPEC REPOS:
  https://github.com/cocoapods/specs.git:
    - BoringSSL-GRPC
    - Firebase
    - FirebaseAnalytics
    - FirebaseAuth
    - FirebaseAuthInterop
    - FirebaseCore
    - FirebaseCoreDiagnostics
    - FirebaseCoreDiagnosticsInterop
    - FirebaseDatabase
    - FirebaseFirestore
    - FirebaseInstanceID
    - FirebaseStorage
    - GoogleAppMeasurement
    - GoogleDataTransport
    - GoogleDataTransportCCTSupport
    - GoogleUtilities
    - "gRPC-C++"
    - gRPC-Core
    - GTMSessionFetcher
    - leveldb-library
    - nanopb
    - Protobuf

SPEC CHECKSUMS:
  BoringSSL-GRPC: db8764df3204ccea016e1c8dd15d9a9ad63ff318
  Firebase: 2d750c54cda57d5a6ae31212cfe5cc813c6be7e4
  FirebaseAnalytics: 5d9ccbf46ed25d3ec9304d263f85bddf1e93e2d2
  FirebaseAuth: e7f86c2dfc57281cd01f7da5e4b40e01e4510a4a
  FirebaseAuthInterop: 0ffa57668be100582bb7643d4fcb7615496c41fc
  FirebaseCore: 8b2765c445d40db7137989b7146a3aa3f91b5529
  FirebaseCoreDiagnostics: be4f7a09d02ab305f18de59a470412caddb64c2a
  FirebaseCoreDiagnosticsInterop: 6829da2b8d1fc795ff1bd99df751d3788035d2cb
  FirebaseDatabase: 518cd94286de2ee999e19383a2a6ae04c81ce993
  FirebaseFirestore: 5ee8bdb959541f0d55352f2d681efb03b9742a43
  FirebaseInstanceID: 550df9be1f99f751d8fcde3ac342a1e21a0e6c42
  FirebaseStorage: b7c6d00997bc21d4465453bdcc5cc65513110fed
  GoogleAppMeasurement: 0ae90be1cc4dad40f4a27fc767ef59fa032ec87b
  GoogleDataTransport: c8617c00e4f3eb9418e42ac0e8ac5241a9d555dd
  GoogleDataTransportCCTSupport: 9f352523e8785a71f6754f51eeff09f49ec19268
  GoogleUtilities: f895fde57977df4e0233edda0dbeac490e3703b6
  "gRPC-C++": 9dfe7b44821e7b3e44aacad2af29d2c21f7cde83
  gRPC-Core: c9aef9a261a1247e881b18059b84d597293c9947
  GTMSessionFetcher: 61bb0f61a4cb560030f1222021178008a5727a23
  leveldb-library: 55d93ee664b4007aac644a782d11da33fba316f7
  nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
  Protobuf: a4dc852ad69c027ca2166ed287b856697814375b

PODFILE CHECKSUM: a068de7f759e79161ece809834082ef4236e1f53

COCOAPODS: 1.7.5

【问题讨论】:

【参考方案1】:

构建失败并出现错误 /Users/admin/testApp/Pods/leveldb-library/port/port_posix.h:77:35: Use of undeclared identifier '__BYTE_ORDER'这与上一个示例的错误相同。

如果您阅读错误,您会看到有问题的 pod 是 leveldb-library。快速pod search leveldb-library 将我们指向leveldb-library Github repo,我们应该能够在其中找到有问题的文件。查看您的 Podfile.lock,您从 Firebase 继承了对 leveldb-library 的依赖。这个 leveldb-library pod 有点奇怪——repo 中的大多数标签都有一个“v”,比如v1.20,但也有一些缺少“v”,比如1.22。如果您查看port directory in the 1.22 tag,您会发现没有一个文件名提及posix,但如果您查看v1.20 tag,您会发现错误抱怨的port_posix.h 文件。

因此,您的 leveldb-library pod 副本中似乎有一些过时的文件,您应该将其清除并重新安装。你可以做的IIRC:

pod clean leveldb-library

接着是:

pod install

你应该得到一个新的副本。如果这不能解决问题,请继续深入了解您拥有的该 pod 的确切副本,并确保它与 pod 的 repo 中的内容相匹配。您也可以使用pod update,因为您在 Firebase 上至少落后一个版本。

【讨论】:

【参考方案2】:

在我将我的 macOS 更新到 catalina、升级我的 Cocoapod 并将我的 XCode 从 10.2 升级到 11.1 之后,我在 leveldb-library 上遇到了同样的错误(与 OP 相同的版本和相同的校验和)。

通过文件菜单 -> 工作区设置.. -> 构建系统将构建系统从新构建系统更改为 旧版构建系统 后,我解决了我的问题。 (参考https://***.com/a/53050109/3230406)

【讨论】:

以上是关于安装任何新的 Cocoapod 都会导致构建失败的主要内容,如果未能解决你的问题,请参考以下文章

Fastlane Scan 的构建过程错过了 Jenkins CI 上的 CocoaPod 框架

Travis CI 构建 [Cocoapod Swift] 失败,没有“这样的模块...”错误

Core Data 代码生成导致构建失败

添加 Firebase/Messaging CocoaPod 会导致 iOS 应用无法构建

还在使用 Git 仓库作为 CocoaPod 私服?--使用 Artifactory 1分钟搭建 CocoaPod 私服

使用 LLVM 构建和任何优化都会导致应用程序在启动时崩溃