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

dyld: Library not loaded错误求助,求Alamofire Pod安装解决方案

Fixing "dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire" Error

First, let's recap the error you're encountering:

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire,引用路径为/Users/rigel/Library/Developer/CoreSimulator/Devices/DFE42BCD-C617-4C9F-9EF3-EEC02635013C/data/Containers/Bundle/Application/3391D0FF-76B5-44EF-BD05-4759635C467B/AppName.app/AppName,原因是image not found。

错误截图
Embed Pods Frameworks截图

This issue typically pops up when CocoaPods fails to properly embed the Alamofire framework into your app bundle. Let's work through the solutions step by step:

1. Reinstall CocoaPods Dependencies

This is the most common fix for Pod-related glitches:

  • Close Xcode entirely (don't just minimize it)
  • Open Terminal, navigate to your project folder, and run these commands:
    rm -rf Pods Podfile.lock
    pod install
    
  • Once done, open your project using the .xcworkspace file (never use the .xcodeproj when working with Pods) and try running again.

2. Verify Your Podfile Configuration

Double-check that Alamofire is correctly linked to your target:

target 'AppName' do
  use_frameworks!
  pod 'Alamofire', '~> 5.8' # Use the version that fits your project
end

If you have multiple targets in your project, make sure Alamofire is included in the right ones, or use an abstract_target to share dependencies across targets.

3. Inspect the Embed Pods Frameworks Build Phase

Looking at your screenshot, let's confirm this critical setup:

  • In Xcode, select your project in the Project Navigator, then choose your app target
  • Switch to the Build Phases tab
  • Locate the Embed Pods Frameworks section
    • Ensure Alamofire.framework is listed here
    • For the framework, check that the Embed option is set to Embed & Sign (not Do Not Embed)
  • If it's missing, re-run pod install—this should add it back automatically.

4. Clean Build Folder & Derived Data

Old cached build files often cause unexpected issues:

  • In Xcode, press Cmd + Shift + K to clean the build folder
  • Delete the Derived Data folder to wipe all cached artifacts. Run this in Terminal:
    rm -rf ~/Library/Developer/Xcode/DerivedData
    
  • Restart Xcode and rebuild your project.

5. Clear Simulator/Device Cache

Corrupted app bundles on the simulator or device can trigger this error:

  • On the simulator, go to Device > Erase All Content and Settings (or just delete the app manually)
  • For a physical device, uninstall the app, reconnect it to your Mac, then rebuild.

6. Check Framework Search Paths

Make sure your project knows where to find Pod frameworks:

  • In your target's Build Settings tab
  • Search for Framework Search Paths
  • Ensure $(inherited) is included in the list (this pulls in paths configured by CocoaPods)
  • If it's missing, add it and set the option to recursive.

If none of these steps resolve the issue, double-check that your Xcode version is compatible with the Alamofire version you're using (refer to Alamofire's official docs for version compatibility notes). Also, always make sure you're opening the .xcworkspace file instead of the .xcodeproj—this is a common mistake that causes Pod linking issues.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 07:00:59