【问题标题】:Module not found - cocoapods未找到模块 - cocoapods
【发布时间】:2019-02-05 07:49:29
【问题描述】:

我正在尝试将这个 library 安装到我的项目(假设是子 xcodeproj)父项目(假设是父 xcodeproj)中。

Child .xcodeproj 有自己的 podfile,我在其中添加了 RxSwift、RxCocoa、Realm 和这个 GeoSwift 库。这是 cocoapods 文件,如下所示

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "9.0"
inhibit_all_warnings!
use_frameworks!

project 'LocationManager/LocationManager'

def pods 

    pod 'GEOSwift'
    pod 'RxSwift', '~> 4.0'
    pod 'RxCocoa', '~> 4.0'
    pod 'RealmSwift', '~> 3.0'
end

target 'LocationManager' do

    pods

    target 'LocationManagerTests' do

        inherit! :search_paths

        pod 'RxBlocking', '~> 4.0'
        pod 'RxTest', '~> 4.0'
    end
end

这个 LocationManager 作为另一个 podfile 安装到另一个 XCode 项目中

def location_pods
   pod 'GEOSwift'


   pod 'LocationManager', :git => 'git@github.com:myrepo/locationmanager.git', :branch => 'users/me/add-geoswift'

end

target 'TestApp' do

   location_pods

   project 'TestApp.project'
end

当我尝试编译 TestApp 目标时,XCode 抛出如下错误 找不到 GeoSwift 模块。此错误位于 Pods > LocationManager > MockLocationManager.swift 内部。在其他地方导入了相同的模块 Pods > LocationManager 工作。 import RxSwift 和 import RxCoca 也有效。当我访问Pods > Targets > LocationManager > Build Phases > Target Dependencies 时,我看到了除 GeoSwift 之外的所有 pod

我可以知道如何解决这个问题吗?将 GeoSwift 添加到此 targetDependency 也不会编译。将LocationManager.xcworkspace 编译为单独的实体时,它工作得非常好。该模块import GeoSwift 不会引发任何编译错误。

【问题讨论】:

  • 您在第二个代码块的第 5 行末尾缺少一个结束单引号 (')。会不会产生这样的问题?
  • 在安装 pod 后您是否清理并构建了您的工作区?
  • @MichaelHulet 感谢您的关注。只是打字时出错。那不是问题。
  • @Rivendell 不,也没有帮助
  • 你尝试过更新 pod 吗?

标签: ios xcode cocoapods


【解决方案1】:

我遇到了类似的问题。

进入 Pod:

然后点击“Build Settings”,找到标题为“Swift Language Version”的行,并尝试将其更新到最新(在我的例子中是4.1)。

这对我有用!希望它也可以帮助其他人。

更多信息:Xcode 9 Swift Language Version (SWIFT_VERSION)

【讨论】:

    【解决方案2】:

    据我所知,Cocoapods 不支持子项目。我也遇到了这个问题,我将我的所有子项目提升为主项目中的文件夹,并将它们放在不同的目标下。现在这些目标也可以使用 Cocoapods。

    【讨论】:

      猜你喜欢
      • 2016-06-02
      • 2023-03-04
      • 2018-04-15
      • 2020-09-28
      • 1970-01-01
      • 2019-09-11
      • 1970-01-01
      • 2020-09-24
      • 2019-09-23
      相关资源
      最近更新 更多