You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

多项目工作区下dyld: Library not loaded问题求助

Fixing dyld: Library not loaded Error with CocoaPods & Multi-Project Workspace

Hey there, let's work through this dyld: Library not loaded error you're facing with your StepikIOS workspace. This is a common issue when using CocoaPods with multiple Xcode projects in a workspace, so let's break down the fixes step by step:

1. First, Fix Your Truncated Podfile

Your provided Podfile cuts off at target :Exte...—this is likely a root cause. You need to ensure every target in your two Xcode projects is properly linked to the pods you've defined. Here's how to structure it correctly:

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

# Link pods to StepikCore target
target 'StepikCore' do
  xcodeproj 'Common/StepikCore/StepikCore.xcodeproj'
  net_pods
end

# Link pods to ExternalWorkers target
target 'ExternalWorkers' do
  xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'
  net_pods
end

Replace the target names with the actual target names from each .xcodeproj if they differ.

2. Reset CocoaPods Installation

Corrupted Pod installations or outdated caches often cause this error. Run these commands in your project root:

  • Delete existing Pod artifacts: rm -rf Podfile.lock Pods/
  • Update your CocoaPods repo and reinstall: pod install --repo-update
  • Critical: Always open StepikIOS.workspace (not individual .xcodeproj files) after this step.

3. Verify Build Settings Inheritance

Ensure your targets inherit CocoaPods' search paths:

  1. Open your workspace in Xcode.
  2. Select a target (e.g., StepikCore) and go to Build Settings.
  3. Search for Framework Search Paths—add $(inherited) and ${PODS_ROOT}/Alamofire (set to recursive).
  4. Search for Library Search Paths—add $(inherited) if it's missing.

4. Check Framework Embedding

Since you're using use_frameworks!, dynamic frameworks need to be embedded in your app:

  1. Go to your target's General tab.
  2. Scroll to Frameworks, Libraries, and Embedded Content.
  3. For every CocoaPods framework (like Alamofire), set the embed option to Embed & Sign.

5. Clean Project & Simulator Caches

Stale build artifacts can cause linking issues:

  • In Xcode: Press Cmd+Shift+K to clean the project, then Cmd+Option+Shift+K to clean the build folder.
  • In the iPhone Simulator: Go to Device > Erase All Content and Settings, then quit and restart the simulator.

6. Remove Manual Framework References

If you manually added any pod frameworks (like Alamofire) to your projects before using CocoaPods, delete them—duplicate references will cause conflicts.

If you've tried all these steps and still see the error, double-check that your target names in the Podfile exactly match the target names in each .xcodeproj (case-sensitive!).

内容的提问来源于stack exchange,提问作者Nick

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:33:33