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

nik*_*212 2 xcode cocoapods swift

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

我的项目结构:

  • StepicIOS.workspace
  • 特征
    • 外部工人
      • ExternalWorkers.xcodeproj
  • 常见的
    • StepikCore
      • StepikCore.xcodeproj

豆荚文件:

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
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明 在此处输入图片说明

当我运行应用程序时,我收到一个错误:

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

如何修复此错误?

nik*_*212 6

我按如下方式更改了我的 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
Run Code Online (Sandbox Code Playgroud)

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