iPhone 上的 Xamarin 部署无法与 Xcode 14 一起使用

无法在物理设备上部署任何 Xamarin iOS 应用。也许你们中的某些人已经遇到过同样的问题并且知道解决方法?

Xcode:版本 14.0 (14A309) Visual Studio for Mac:17.3.4(内部版本 4)

尝试调试时出现以下错误。我已经多次尝试清理项目并删除 bin 和 obj 文件夹:

Target _CopyAppConfigFile:
  Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
Target CopyFilesToOutputDirectory:
    Xamarin.iOS -> .../Xamarin/Xamarin.iOS/bin/iPhone/Debug/Xamarin.iOS.exe
Target _CopyResourcesToBundle:
  Skipping target "_CopyResourcesToBundle" because all output files are up-to-date with respect to the input files.
Target _WriteAppManifest:
  Skipping target "_WriteAppManifest" because all output files are up-to-date with respect to the input files.
Target _CompileToNative:
    /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch @/Xamarin/Xamarin.iOS/obj/iPhone/Debug/device-builds/iphone14.2-16.0/response-file.rsp 
    Xamarin.iOS 15.12.0.2 (d17-3: 87f98a75e) using framework: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk
    Compilation failed with code 1, command:
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wno-receiver-forward-class -Wno-objc-missing-super-calls -Wno-unguarded-availability-new -stdlib=libc++ -gdwarf-2 -std=c++14 -I/Library/Frameworks/Xamarin.iOS.framework/Versions/15.12.0.2/SDKs/MonoTouch.iphoneos.sdk/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk -Qunused-arguments -miphoneos-version-min=9.0 -arch arm64 -c -o /Xamarin/Xamarin.iOS/obj/iPhone/Debug/device-builds/iphone14.2-16.0/mtouch-cache/arm64/registrar.o -x objective-c++ -D DEBUG /Xamarin/Xamarin.iOS/obj/iPhone/Debug/device-builds/iphone14.2-16.0/mtouch-cache/registrar.m
    In file included from /Xamarin/Xamarin.iOS/obj/iPhone/Debug/device-builds/iphone14.2-16.0/mtouch-cache/registrar.m:3:
    /Xamarin/Xamarin.iOS/obj/iPhone/Debug/device-builds/iphone14.2-16.0/mtouch-cache/registrar.h:112:9: fatal error: 'CHIP/CHIP.h' file not found
    #import <CHIP/CHIP.h>
            ^~~~~~~~~~~~~
    1 error generated.
    MTOUCH : error MT4109: Failed to compile the generated registrar code. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new
Done building target "_CompileToNative" in project "Xamarin.iOS.csproj" -- FAILED.

尝试部署发布版本时,我得到:

/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch -sdkroot "/Applications/Xcode.app/Contents/Developer" --installdev ".../Xamarin.iOS/bin/iPhone/Release/Xamarin.iOS.app" --device ios "--devname=iPhone 13 Pro" --install-progress
error HE0004: Could not load the framework 'DVTITunesSoftwareServiceFoundation' (path: /Applications/Xcode.app/Contents/SharedFrameworks/DVTITunesSoftwareServiceFoundation.framework/DVTITunesSoftwareServiceFoundation): 
dlopen(/Applications/Xcode.app/Contents/SharedFrameworks/DVTITunesSoftwareServiceFoundation.framework/DVTITunesSoftwareServiceFoundation, 0x0001): Library not loaded: '@rpath/ContentDelivery.framework/Versions/A/ContentDelivery'
  Referenced from: '/Applications/Xcode.app/Contents/SharedFrameworks/DVTITunesSoftwareServiceFoundation.framework/Versions/A/DVTITunesSoftwareServiceFoundation'
  Reason: tried: '/usr/lib/swift/ContentDelivery.framework/Versions/A/ContentDelivery' (no such file), '/Library/Frameworks/Xamarin.iOS.framework/Versions/15.12.0.2/lib/mlaunch/mlaunch.app/Contents/MacOS/../Frameworks/ContentDelivery.framework/Versions/A/ContentDelivery' (no such file), '/Applications/Xcode.app/Contents/SharedFrameworks/DVTITunesSoftwareServiceFoundation.framework/Versions/A/Frameworks/ContentDelivery.framework/Versions/A/ContentDelivery' (no such file), '/usr/lib/swift/ContentDelivery.framework/Versions/A/ContentDelivery' (no such file), '/Library/Frameworks/Xamarin.iOS.framework/Versions/15.12.0.2/lib/mlaunch/mlaunch.app/Contents/MacOS/../Frameworks/ContentDelivery.framework/Versions/A/ContentDelivery' (no such file), '/Applications/Xcode.app/Contents/SharedFrameworks/DVTITunesSoftwareServiceFoundation.framework/Versions/A/Frameworks/ContentDelivery.framework/Versions/A/ContentDelivery' (no such file), '/System/Library/Frameworks/ContentDelivery.framework/Versions/A/ContentDelivery' (no such file)

Application could not be uploaded to the device.
stack overflow Xamarin Deploy on iPhone not working with Xcode 14
原文答案
author avatar

接受的答案

将命令行工具降级到 13.4 对我有帮助。

在 xCode (still 14) -> Preferences -> Location -> Command Line Tools 中,选择版本 13.4 而不是 14。重新启动工具,它再次工作......

enter image description here

希望它也适合你!


答案:

作者头像

我建议降级到以前版本的 XCode(例如 https://download.developer.apple.com/Developer_Tools/Xcode_13.4.1/Xcode_13.4.1.xip 如果以开发人员身份登录)

在这里你可以选择你想要的 XCode 版本: https://developer.apple.com/download/all

您可以并排安装多个 XCode 版本。使用 sudo xcode-select -s /path/to/XCode.app 在它们之间切换。

作者头像

我有一个类似的问题。我已将 xcode 更新为 14,并且 Visual Studio(来自 Windows)停止使用 xamarin.ios 调试/构建。我需要将 xcode 降级到以前的版本以使其恢复正常。

作者头像

Apple 在一夜之间发布了 Xcode 14,它在我的机器上自动更新,所以它现在是正式使用的版本,但仍然不支持使用 VS Mac Preview 构建 Xamarin 应用程序。 :(

作者头像

通过 Xamarin.iOS 的最新更新,问题得到解决。我正在运行 14.0.1 XCODE、17.3.6 Visual Studio 2022 社区 16.0.0.72 Xamarin.iOS 我能够将解决方案部署到较旧的(15.5)和较新的(16.0)模拟器所以问题已解决,请更新所有相关工具。注意我还检查了 Rider IDE 的部署。

作者头像

After installing command-line manually, command-line tools is empty, after selecting XCode 14.0.1 itself resolved the issue.

enter image description here

相关问题