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

求助:处理Xcode中"file too small"链接器错误

Fixing "ld: file too small (length=19)" Error for libc++.dylib in Xcode

That tiny 19-byte libc++.dylib file in your project is almost certainly a broken symlink, empty placeholder, or corrupted copy—definitely not the actual system library the linker expects. Let's walk through the most reliable fixes to get your build working again:

  • Replace the broken file with the system's official libc++.dylib
    System libraries like libc++.dylib shouldn't be stored locally in your project directory. Instead, link against the version provided by macOS/Xcode:

    1. First, delete the broken /Users/xxx/xxx/xxx/libc++.dylib file from your project folder (and remove its reference from Xcode if it's still listed).
    2. In Xcode, navigate to your target's Build Phases > Link Binary With Libraries.
    3. Click the + button, search for libc++.dylib (or libc++.tbd for newer SDKs), select it, and add it to your list. This ensures you're using the valid, up-to-date library from the system SDK.
  • Fix incorrect file references in your project
    If you previously added a local copy of the library, double-check its path in Xcode:

    1. Select the libc++.dylib entry in the Project Navigator.
    2. Open the File Inspector (right-hand pane).
    3. Verify the Path field points to a valid file. If it's a relative path that's broken, update it to the system path (e.g., /usr/lib/libc++.dylib) or remove the reference entirely and add it via the Build Phases method above.
  • Wipe derived data and rebuild from scratch
    Corrupted derived data can sometimes cause weird linker issues:

    1. Go to Xcode > Settings > Locations.
    2. Click the arrow next to Derived Data to open the folder.
    3. Delete the folder corresponding to your project.
    4. Back in Xcode, clean your project with Cmd+Shift+K, then rebuild with Cmd+B.
  • Verify your Xcode installation
    If the system SDK itself is corrupted, this can lead to missing or broken library references:

    1. Go to Xcode > Settings > Locations and ensure Command Line Tools is set to your active Xcode version.
    2. If problems persist, try updating Xcode to the latest version via the App Store, or reinstall it completely to fix any corrupted SDK files.

A quick note: Storing local copies of system libraries is generally a bad practice—they can become outdated or corrupted as you update macOS or Xcode, leading to exactly the kind of error you're seeing. Using the system-provided library via Xcode's build settings avoids these issues long-term.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 08:43:03