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

Unity导出Xcode项目运行iPhone 6报错:ld: library not found for -liPhone-lib

Fixing "ld: library not found for -liPhone-lib" in Unity-Built Xcode Projects

Hey there, let’s work through this linker error together—it’s super common with Unity-to-iOS builds, so you’re not alone! This error means Xcode can’t find Unity’s core native library (libiPhone-lib.a) that’s required to run your app. Here are the most reliable fixes to get your project running on iPhone 6:

1. Start Fresh: Re-export from Unity with Correct Settings

First, let’s make sure Unity’s build setup is solid before we touch Xcode:

  • Open your Unity project, head to File > Build Settings
  • Confirm iOS is selected as the target platform (click Switch Platform if it wasn’t already)
  • Jump to Player Settings > iOS > Other Settings:
    • Set Architecture to ARM64 (iPhone 6 supports this, and modern Unity builds rely on it—avoid mixing architectures like ARMv7 and ARM64)
    • Ensure Scripting Backend is set to IL2CPP (this is the stable default for iOS in newer Unity versions)
  • Clean up Unity’s cached files: Go to Edit > Clear All Player Prefs, then open your C# project (Assets > Open C# Project) and clean the solution in your IDE
  • Export the Xcode project to a brand-new folder (don’t overwrite your existing one—fresh exports avoid leftover corrupted files)

2. Double-Check Library Search Paths in Xcode

Once you’ve got the fresh Xcode project open:

  • Select your project root in the left-side Project Navigator, then go to your app’s Target > Build Settings
  • Search for Library Search Paths
  • Make sure the path $(SRCROOT)/Libraries is listed—this tells Xcode to look in the Libraries folder where Unity stores libiPhone-lib.a
  • If it’s missing, click the + button and paste that path in. Also, set Always Search User Paths to YES

3. Verify the Library File Exists

  • In Xcode’s Project Navigator, expand the Libraries folder
  • Look for libiPhone-lib.a—if it’s missing, the export from Unity failed. Go back to Unity, re-export the project (sometimes the library doesn’t copy over correctly)
  • If it’s there, right-click it and select Show in Finder to confirm the file isn’t empty or corrupted. If it looks off, delete the entire Xcode export folder and re-export from Unity

4. Ensure the Library is Linked to Your Target

  • Sometimes the library is present but not linked to your app target. Go to Target > Build Phases > Link Binary With Libraries
  • Check if libiPhone-lib.a is in the list. If not, click the + button, select it from the available libraries (or navigate to Libraries/libiPhone-lib.a if it’s not listed)

5. Fix Version Mismatches Between Unity & Xcode

This error often pops up if Unity and Xcode versions aren’t compatible. For example:

  • Unity 2022.x requires Xcode 14.0 or later
  • Older Unity versions (like 2020.x) work best with Xcode 12-13
  • Check Unity’s official docs for the exact compatible Xcode version for your Unity build, then update either tool to match. Re-export and build after updating

6. Clean & Rebuild Xcode’s Cache

Old build artifacts can stick around and cause issues:

  • Hold the Option key and go to Product > Clean Build Folder (this wipes all cached build files)
  • Then go to Product > Build For > Running to build the project from scratch
  • Try running it on your iPhone 6 again

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 10:56:53