ios 没有这样的模块......在Xcode中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39970273/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 10:33:23  来源:igfitidea点击:

No such module ... in Xcode

iosswiftxcodecocoapodspodfile

提问by Lastmboy

I've run into a problem with Xcode (using Swift) that has me completely stumped. I realize that this question has been asked and answered, but none of the answers have worked for me, and my situation seems to be a bit different than the others, as all of my pods are failing (not just a specific one). They all worked fine a week ago.

我遇到了 Xcode(使用 Swift)的一个问题,这让我完全被难住了。我意识到已经提出并回答了这个问题,但没有一个答案对我有用,而且我的情况似乎与其他人有点不同,因为我的所有 pod 都失败了(不仅仅是一个特定的)。一周前,他们都工作得很好。

I use Cocoapods for some of the more common Swift frameworks (e.g. Alamofire, Eureka, Kingfisher, SwiftyJSON, etc.). They were all working fine in Xcode 7. However, one of the (automatic) updates bumped up my Xcode version, after which it became mandatory to specify your target in the podfile. I did this and ran pod install. The pods are all still there, but now every import statement that relates to these frameworks fails.

我将 Cocoapods 用于一些更常见的 Swift 框架(例如 Alamofire、Eureka、Kingfisher、SwiftyJSON 等)。它们在 Xcode 7 中都运行良好。但是,其中一项(自动)更新提高了我的 Xcode 版本,之后必须在 podfile 中指定目标。我这样做并运行了 pod install。Pod 仍然存在,但现在与这些框架相关的每个导入语句都失败了。

At first I thought it was an Alamofire issue, as that's the first one that failed with the "No such module 'Alamofire'" error. I tried everything I could with Alamofire, including the following:

起初我认为这是一个 Alamofire 问题,因为这是第一个因“No such module 'Alamofire'”错误而失败的问题。我尝试了 Alamofire 所能做的一切,包括以下内容:

  • Clean and rebuild
  • Clean build folder
  • Restart Xcode
  • Re-boot computer
  • Delete all derived data
  • Added framework to "Linked Frameworks and Libraries"
  • Added framework to "Link Binary with Libraries"
  • Verified that I am opening the workspace rather than the project
  • Re-installed CocoaPods
  • Re-installed Xcode ver 7.3.1
  • 清洁和重建
  • 清理构建文件夹
  • 重启Xcode
  • 重启电脑
  • 删除所有派生数据
  • 向“链接的框架和库”添加了框架
  • 添加了“将二进制文件与库链接”的框架
  • 验证我打开的是工作区而不是项目
  • 重新安装 CocoaPods
  • 重新安装 Xcode 7.3.1 版

Nothing would remove the "No such module ..." error. Finally, I removed Alamofire from the pods and just dragged the Alamofire project into my project. This allowed me to remove the import statements for Alamofire. However, to my dismay, now the next framework caused "No such module". I moved the next three frameworks into my project, and it looks like it is just going to keep going. Apparently, none of my Pods frameworks are being recognized anymore. I installed Xcode 8 and tried that with Swift 2.3, but I get the same "No such module" errors.

没有什么可以消除“没有这样的模块......”错误。最后,我从 Pod 中删除了 Alamofire,然后将 Alamofire 项目拖到我的项目中。这允许我删除 Alamofire 的导入语句。然而,令我沮丧的是,现在下一个框架导致“没有这样的模块”。我将接下来的三个框架移到我的项目中,看起来它会继续下去。显然,我的 Pods 框架都不再被识别。我安装了 Xcode 8 并尝试使用 Swift 2.3,但我得到了相同的“没有这样的模块”错误。

I really would prefer to use Cocoapods, as it makes upgrades a lot easier, along with other bonuses. I'm guessing I have some setting wrong that is screwing up all my pods, but have not had any luck finding it. This is a bit of a disaster as it has shut down development for several days, with no sign of a fix. If there is anything I can do or provide to assist in finding a solution, just let me know. If anyone could provide any possible solutions or even things to try, it would be greatly appreciated. I'm currently working with Xcode version 7.3.1.

我真的更喜欢使用 Cocoapods,因为它使升级更容易,还有其他奖励。我猜我有一些设置错误,导致我所有的豆荚都搞砸了,但我没有运气找到它。这有点像一场灾难,因为它已经关闭了几天的开发,没有任何修复的迹象。如果有什么我可以做或提供的东西来帮助找到解决方案,请告诉我。如果有人可以提供任何可能的解决方案甚至尝试的方法,我们将不胜感激。我目前正在使用 Xcode 7.3.1 版。

My pod file looks something like this:

我的 pod 文件如下所示:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'Y2GOsp' do
    use_frameworks!

    # Pods for Y2GOsp
    pod 'Alamofire', '~> 3.0'
    pod 'AlecrimCoreData', '~> 4.0'
    pod 'Kingfisher', '~> 2.4'
    pod 'Eureka', '~> 1.6'
    pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git', :branch => 'xcode7'
    pod 'PhoneNumberKit', '~> 0.1'
    pod 'PKHUD'
    pod 'Dollar'
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '2.2'
        end
    end
end

回答by Lastmboy

Comments from @l'L'l led me to the solution. I went to

@l'L'l 的评论使我找到了解决方案。我去了

build settings > frameworks search path

and set it to the following:

并将其设置为以下内容:

$(inherited) (non-recursive)
$(PROJECT_DIR)/build/Debug-iphoneos (non-recursive)
$(SRCROOT) (recursive)

It is now correctly finding the pod frameworks.

它现在可以正确地找到 pod 框架。

回答by krish

In Pod file

在 Pod 文件中

Uncomment below lines to define a global platform for your project

取消注释以下几行,为您的项目定义一个全球平台

platform :ios, '10.0'

平台:ios,'10.0'

use_frameworks!

使用_框架!

Now in xcode

现在在 xcode

a) Clean your project

a) 清理你的项目

b) Make sure that all your "Pods" > "Build Settings" > "Build Active Architecture Only" is set to "NO"

b) 确保你所有的“Pods”>“Build Settings”>“Build Active Architecture Only”设置为“NO”

c) Now, build project

c) 现在,构建项目

回答by Siklab.ph

Make sure you opened the .xcworkspacefile in Xcode and not just the .xcodeprojfile.

确保您.xcworkspace在 Xcode 中打开了文件,而不仅仅是.xcodeproj文件。

回答by Developer Sheldon

try to make the version of your SDK into earlier versions

尝试将您的 SDK 版本改成早期版本

pod 'Alamofire', '~> 3.0'
pod 'AlecrimCoreData', '~> 4.0'
pod 'Kingfisher', '~> 2.4'
pod 'Eureka', '~> 1.6'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git', :branch => 'xcode7'
pod 'PhoneNumberKit', '~> 0.1'
pod 'PKHUD'
pod 'Dollar'

for example change 3.0 to available previous version, it worked once for me when i was facing the same issue.

例如,将 3.0 更改为可用的先前版本,当我遇到同样的问题时,它对我有用过一次。

pod 'Alamofire', '~> 2.4' #I am assuming prev available version is 2.4

But it doesn't have to be the "Alamofire" version result in "No such Module", you may try every one in your list in the pod file.

但不一定是“Alamofire”版本导致“No such Module”,您可以尝试 pod 文件中列表中的每一个。

回答by joliejuly

Sometimes pod deintegrateand then pod installhelps me as well

有时pod deintegrate,然后也pod install帮助我