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)
- Set Architecture to
- 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)/Librariesis listed—this tells Xcode to look in the Libraries folder where Unity storeslibiPhone-lib.a - If it’s missing, click the
+button and paste that path in. Also, set Always Search User Paths toYES
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.ais in the list. If not, click the+button, select it from the available libraries (or navigate toLibraries/libiPhone-lib.aif 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
相关产品推荐
相关产品推荐

