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

VS2022下Xamarin开发iOS应用集成Firebase真机运行报错求助

Xamarin.iOS App Won’t Run on Physical iPhone with FirebaseFirestore: Two Persistent Errors

I’m building a company app using C# and Xamarin with Visual Studio 2022. Testing goes smoothly on Android physical devices, Android emulators, and iOS simulators—but the app fails to launch on a real iPhone. Here’s what’s happening:

First Error: UnpackFrameworks Task Failure

When I try to deploy to the iPhone, I get this build error immediately:

The "UnpackFrameworks" task failed unexpectedly.
System.IO.IOException: The file 'obj\iPhone\Debug\Frameworks\FirebaseFirestore.framework\FirebaseFirestore' already exists.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
   at System.IO.FileInfo.CopyTo(String destFileName)
   at Xamarin.iOS.Tasks.Windows.Zip.CopyDirectory(String source, String destination) in /Users/builder/azdo/_work/2/s/xamarin-macios/msbuild/Xamarin.iOS.Tasks.Windows/Zip.cs:line 31
   at Xamarin.iOS.Tasks.Windows.Zip.Extract(String sourceFileName, String destinationPath) in /Users/builder/azdo/_work/2/s/xamarin-macios/msbuild/Xamarin.iOS.Tasks.Windows/Zip.cs:line 17
   at Xamarin.iOS.HotRestart.Tasks.UnpackFrameworks.Execute() in /Users/builder/azdo/_work/2/s/xamarin-macios/msbuild/Xamarin.iOS.Tasks.Windows/Tasks/UnpackHotRestartFrameworks.cs:line 55
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

I’ve already tried deleting the obj and bin folders multiple times, but the error keeps coming back.

Second Error: Firebase TypeInitializationException

After modifying the Xamarin.iOS.HotRestart.targets file to work around the first issue, the app now throws a runtime error related to Firebase:

Xamarin.PreBuilt.iOS[635:177579] System.TypeInitializationException: The type initializer for 'Plugin.CloudFirestore.FirestoreProvider' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: firestore
  at Plugin.CloudFirestore.FirestoreWrapper..ctor (Firebase.CloudFirestore.Firestore firestore) <0x104558138 + 0x0001a> in <xxxxxxxxxxxxxxxxxxxxx>:0 
  at Plugin.CloudFirestore.FirestoreProvider..cctor () <0x1039aa4c0 + 0x00014> in <xxxxxxxxxxxxxxxxxxxxx>:0 
   --- End of inner exception stack trace ---
  at Plugin.CloudFirestore.CloudFirestoreImplementation.get_Instance () <0x1039a99b0 + 0x00000> in <xxxxxxxxxxxxxxxxxxxxx>:0 

The weird thing is: if I remove all Firebase components from the app, it runs perfectly fine on the physical iPhone.

Does anyone have a solution to get Firebase working correctly on real iOS devices with Xamarin?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 16:25:17