将pod添加到单个自定义框架

时间:2020-06-21 21:35:15

标签: ios xcode cocoapods alamofire

Xcode 11.5,iOS 13.5

我创建了一个简单的Xcode项目,然后使用CocoaPods进行了初始化,因此初始步骤是:

  • 使用UI和单元测试目标创建了新项目(TestCocoa)
  • cd到根目录和pod init
  • 打开新创建的TestCocoa.xcworkspace

此后,我创建了新的Framework(BestAPI)并作为第二个项目(与原始TestCocoa项目一起)添加到原始工作区中。所以现在我的TestCocoa.xcworkspace有2个项目。在Podfile中,我仅为BestAPI项目添加了Alamofire并将其导入到swift文件中。但是当我尝试构建项目时,出现此错误:

Cannot load underlying module for 'Alamofire'

我试图清理项目pod deintegrate等,但没有任何效果。我尝试添加use_frameworks !,但是在这种情况下,我可以构建项目,但是在运行该项目时,我会遇到另一个错误:

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire

这是我的Podfile:

use_modular_headers!
workspace 'TestCocoa.xcworkspace'

testCocoa = 'TestCocoa.xcodeproj'
bestAPI = 'BestAPI/BestAPI.xcodeproj'

project testCocoa
project bestAPI

target 'TestCocoa' do
  project testCocoa

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

  target 'TestCocoaUITests' do
    # Pods for testing
  end
end

target 'BestAPI' do
  project bestAPI

  pod 'Alamofire'

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

一些截图:

Projects structure TestCocoa Embeded content BestAPI Embeded content

0 个答案:

没有答案