新建Xamarin.Forms iOS项目缺失引用,构建失败求助
Hey there, since you're new to Xamarin, let's work through this assembly reference error in your AppDelegate.cs step by step—we'll get your project building smoothly in no time!
First, Validate Core Dependencies
A fresh Xamarin.Forms iOS project must have these core references to function properly:
Xamarin.Forms(version must match the one used in your shared/.NET Standard project)Xamarin.iOS(pre-installed with Visual Studio for Mac, but needs correct linking)- Optional but standard:
Xamarin.Essentials
Step 1: Fix NuGet Package Issues (Even After Updating)
Sometimes bulk updates leave broken or mismatched package references. Try this targeted fix:
- Right-click your iOS project → Manage NuGet Packages
- Navigate to the Installed tab, locate
Xamarin.Forms(andXamarin.Essentialsif present) - Uninstall these packages, then fully close Visual Studio
- Reinstall the stable version of
Xamarin.Forms(ensure it matches the version in your shared project exactly) - After installation, right-click the iOS project → Restore NuGet Packages to pull all dependent files correctly
Step 2: Fix the Blank "Add Reference" Window
An empty reference window is almost always a cache or project corruption issue:
- Close Visual Studio completely
- Delete the
binandobjfolders from your iOS project directory (these auto-generated folders are safe to remove) - Open Terminal and run this command to clear Visual Studio's component cache:
Replacerm -rf ~/Library/Caches/VisualStudio/[Your_VS_Version][Your_VS_Version]with your actual Visual Studio version (e.g.,2022) - Restart Visual Studio and try opening the "Add Reference" window again
Step 3: Verify AppDelegate.cs Code Structure
The assembly error often stems from missing using statements or incorrect inheritance. Double-check your code matches this structure:
using System; using Foundation; using UIKit; using Xamarin.Forms; // Critical line—if red, Xamarin.Forms isn't referenced properly namespace YourAppName.iOS { [Register("AppDelegate")] public partial class AppDelegate : FormsApplicationDelegate // Must inherit from this class { public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Forms.Init(); // Initialize Xamarin.Forms framework LoadApplication(new App()); // Load your shared project's main App class return base.FinishedLaunching(app, options); } } }
If Xamarin.Forms is underlined in red, go back to Step 1 to fix the NuGet installation.
Step 4: Check Project Links & XCode Compatibility
- Ensure your iOS project references your shared/.NET Standard project: Right-click iOS project → Add → Reference → Select your shared project from the list
- Confirm XCode 9.3 is fully set up: Open XCode once to accept license agreements and verify it runs without errors (Visual Studio relies on XCode's underlying tools)
- Note: XCode 9.3 is quite old—if all other steps fail, consider updating XCode to a version compatible with your current Visual Studio (check VS release notes for supported XCode versions)
Final Check: Clean & Rebuild
After completing the steps above:
- Go to Build → Clean All
- Then Build → Rebuild Solution
This should resolve most assembly reference issues in a fresh template project.
内容的提问来源于stack exchange,提问作者Luke

