dyld:未加载库(多项目工作区)

时间:2018-04-24 18:17:29

标签: swift xcode cocoapods

我正在尝试将我的应用程序运行到iPhone模拟器。现在我正在使用CocoaPods。

我的项目结构:

  • StepicIOS.workspace
  • 特性
    • ExternalWorkers
      • ExternalWorkers.xcodeproj
  • 普通
    • StepikCore
      • StepikCore.xcodeproj

Pod文件:

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

workspace 'StepikIOS'

xcodeproj 'Common/StepikCore/StepikCore.xcodeproj'
xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'

def net_pods
    pod 'Alamofire', '~> 4.7.2'
end

target :ExternalWorkers do
    xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'
    net_pods
end

target :ExternalWorkersTests do
    xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'
    net_pods
end

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

enter image description here enter image description here

当我运行应用程序时出现错误:

  

dyld:未加载库:@ rpath / Alamofire.framework / Alamofire
  参考自:   /Users/nikita/Library/Developer/Xcode/DerivedData/StepikIOS-ghofwgasymvhnxbjmtdesdkbcdal/Build/Products/Debug-iphonesimulator/ExternalWorkers.framework/ExternalWorkers   原因:未找到图像

如何解决此错误?

1 个答案:

答案 0 :(得分:2)

我更改了我的Pod文件,如下所示:

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

workspace 'StepikIOS'

xcodeproj 'SteoikIOS.xcodeproj'
xcodeproj 'Common/StepikCore/StepikCore.xcodeproj'
xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'

def net_pods
    pod 'Alamofire', '~> 4.7.2'
end

target: StepikIOS do
    xcodeproj 'SteoikIOS.xcodeproj'
    net_pods
end

target :ExternalWorkers do
    xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'
    net_pods
end

target :ExternalWorkersTests do
    xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'
    net_pods
end

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

因为必须为主应用目标安装所有依赖项。