简体   繁体   English

Xcode和Cocoapods“没有这样的模块”错误

[英]Xcode and Cocoapods “No such module” error

I recently upgraded to Xcode 8 and an existing project to Swift 3. After having a variety of issues with Cocoapods, I decided to start over from scratch. 我最近升级到Xcode 8和现有项目到Swift 3.在与Cocoapods有各种各样的问题后,我决定从头开始。 After running pod deintegrate and deleting Podfile , Podfile.lock , and [Project].xcworkspace , I had a blank slate as far as Cocoapods was concerned. 在运行pod deintegrate并删除PodfilePodfile.lock[Project].xcworkspace ,就[Project].xcworkspace ,我有一个空白的名单。

I then took the following actions: 然后我采取了以下行动:

  1. Opened a terminal at the project location and ran pod init , then pod install (using the stub Podfile that pod init creates). 在项目位置打开终端并运行pod init ,然后执行pod install (使用pod init创建的存根Podfile)。

    This appeared to be successful, but came with the following two warnings: 这似乎是成功的,但附带以下两个警告:

[!] The `Xena [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Xena/Pods-Xena.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target.

[!] The `Xena [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Xena/Pods-Xena.release.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target.

At this point, opening Xcode and building the project gives the "No such module" error, which is entirely expected. 此时,打开Xcode并构建项目会产生“No such module”错误,这是完全可以预料到的。

Following the instructions at this question solves this problem and rerunning pod install is a success. 按照此问题的说明解决此问题并重新运行pod install是成功的。

  1. Closed Xcode, added the modules I'm using to the Podfile (see below), the ran pod install again. 关闭Xcode,将我正在使用的模块添加到Podfile(见下文),再次运行pod install According to the terminal output, this is successful. 根据终端输出,这是成功的。

  2. Opened Xcode and built the project. 打开Xcode并构建项目。 I again receive the "No such module" error, specifically No such module 'ReactiveCocoa' 我再次收到“No such module”错误,特别是No such module 'ReactiveCocoa'

    I have confirmed that the same problem occurs with SnapKit, Hue, KMPlaceholderTextView, KeychainSwift, and Siren, depending on the order of the import statements. 我已经确认SnapKit,Hue,KMPlaceholderTextView,KeychainSwift和Siren会出​​现同样的问题,具体取决于import语句的顺序。 For some reason, none of the Google modules are affected by this problem. 出于某种原因,没有任何Google模块受此问题的影响。

My Podfile: 我的Podfile:

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

target 'Xena' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Xena
  pod 'ReactiveCocoa', :git => 'https://github.com/ReactiveCocoa/ReactiveCocoa.git'
  pod 'SnapKit', '~> 3.0.2'
  pod 'Hue', '~> 2.0.1'
  pod 'KMPlaceholderTextView', '~> 1.3.0'
  pod 'GooglePlacePicker'
  pod 'GooglePlaces'
  pod 'GoogleMaps'
  pod 'KeychainSwift', '~> 7.0'
  pod 'Siren'

  target 'XenaTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'XenaUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

Make sure you are opening .xcworkspace and not .xcodeproj file. 确保打开.xcworkspace而不是.xcodeproj文件。

You may further look into this post . 你可以进一步研究这篇文章

Also under : Target > General > Linked Frameworks and Libraries Make sure your frameworks are there. 同样位于:Target> General> Linked Frameworks and Libraries确保您的框架在那里。 Even Pods_Xena.framework is there 甚至还有Pods_Xena.framework

Try: 尝试:

Xcode ->Preferences ->Location ->DerivedData Xcode - >首选项 - >位置 - > DerivedData

open the folder DerivedData and move it to Trash 打开DerivedData文件夹并将其移至“废纸篓”

Uncomment the next line to define a global platform for your project 取消注释下一行以定义项目的全局平台

platform :iOS, '9.0'

Uncommenting the second line in your pod file will help you. 取消注释pod文件中的第二行将对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM