使用 Xcode 8 和 Swift 3.0 获取 "No such module 'RxSwift'"

Getting "No such module 'RxSwift'" with Xcode 8 and Swift 3.0

我尝试在我的项目中使用 RxSwift。我的播客文件如下所示,↓

我收到这个错误:

这是我的 Link 带库的二进制文件 状态:

我花了三个多小时试图修复它。但是网站上的答案对我不起作用...

您正在将 pods 插入到测试目标中,而不是项目目标中。

要解决此问题,请将 pods 移动到项目目标,如下所示:

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

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

    # Pods for ProjectName
    # Insert your pods here
    pod 'RxSwift'
    pod 'RxCocoa'

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

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

end

像下面这样替换您的 Podfile:

platform :ios, '9.0'

target 'RxStudy' do
    use_frameworks!

    pod 'RxSwift'
    pod 'RxCocoa'

    target 'RxStudyTests' do
        #Add pod here if you want the access of pod in Tests target.
        #Example: pod 'RxSwift'
    end

    target 'RxStudyUITests' do
        #Add pod here if you want the access of pod in Tests target.
        #Example: pod 'RxSwift'
    end

end

您的 Podfile 的问题是您试图在测试目标中添加 pods 而不是实际的项目目标。如上所述更改文件后,再次安装 Pods,然后 运行 项目,即使您得到 "No such module error",因为它可能是第一次发生。