xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.49k stars 515 forks source link

[iOS] Wrong path in IPA with Xcode 15 for AdditionalAppExtensions #19861

Open de-preut opened 10 months ago

de-preut commented 10 months ago

Steps to Reproduce

  1. Create a iOS app in Xcode 15
  2. Add a new app extension target in the iOS App, choose i.e. "AppIntent" as template
  3. Create a normal MAUI
  4. Follow the instruction of https://learn.microsoft.com/en-us/xamarin/ios/platform/ios14/ section "Embedded WidgetKit Support"
  5. (Optional step) try to change the command like mentioned in https://github.com/dotnet/maui/issues/19104#issuecomment-1833570071

Expected Behavior

The MAUI app can be started normally and the AppExtension (here: AppIntent) is working as expected.

Actual Behavior

The build runs without issue, but after deploying the MAUI app to an iOS simulator or device, I get the error message

An error was encountered processing the command (domain=IXErrorDomain, code=2):
Simulator device returned an error for the requested operation.
Failed to create promise.
Underlying error (domain=IXErrorDomain, code=2):
    Failed to create app extension placeholder for [...]/PlugIns/Intent.appex
    Failed to create promise.
error HE0046: Failed to install the app 'BUNDLEIDENFIER' on the device 'iOS 17.2 (21C62) - iPhone 15 Pro': simctl returned exit code 2

Environment

Version information ``` Visual Studio Professional 2022 for Mac Version 17.6.7 (build 417) Installation UUID: a965ccb9-0e7f-42b5-aa61-1e9d438e701d Runtime .NET 7.0.3 (64-bit) Architecture: Arm64 Microsoft.macOS.Sdk 13.1.1007; git-rev-head:8afca776a0a96613dfb7200e0917bb57f9ed5583; git-branch:release/7.0.1xx-xcode14.2 Roslyn (Language Service) 4.6.0-3.23180.6+99e956e42697a6dd886d1e12478ea2b27cceacfa NuGet Version: 6.4.0.117 .NET SDK (Arm64) SDK: /Users/depreut/dotnet/sdk/8.0.100/Sdks SDK Version: 8.0.100 MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks .NET Runtime (Arm64) Runtime: /Users/depreut/dotnet/dotnet Runtime Version: 8.0.0 Xamarin.Profiler Version: 1.8.0.49 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler Updater Version: 11 Apple Developer Tools Xcode: 15.2 22503 Build: 15C500b Xamarin.Mac Version: 9.3.0.23 Visual Studio Professional Hash: 9defd91b3 Branch: xcode14.3 Build date: 2023-10-23 16:14:59-0400 Xamarin.iOS Version: 16.4.0.23 Visual Studio Professional Hash: 9defd91b3 Branch: xcode14.3 Build date: 2023-10-23 16:15:00-0400 Xamarin Designer Version: 17.6.3.9 Hash: 2648399ae8 Branch: remotes/origin/d17-6 Build date: 2023-11-10 12:19:46 UTC Xamarin.Android Version: 13.2.2.0 (Visual Studio Professional) Commit: xamarin-android/d17-5/45b0e14 Android SDK: /Users/depreut/Library/Android/sdk Supported Android versions: 12.0 (API level 31) 11.0 (API level 30) 13.0 (API level 33) SDK Command-line Tools Version: 7.0 SDK Platform Tools Version: 34.0.5 SDK Build Tools Version: 34.0.0 rc3 Build Information: Mono: d9a6e87 Java.Interop: xamarin/java.interop/d17-5@149d70fe SQLite: xamarin/sqlite/3.40.1@68c69d8 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d Microsoft Build of OpenJDK Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk 11.0.21 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Eclipse Temurin JDK Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk 1.8.0.302 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Android SDK Manager Version: 17.6.0.50 Hash: a715dca Branch: HEAD Build date: 2023-11-10 12:19:52 UTC Android Device Manager Version: 0.0.0.1309 Hash: 06e3e77 Branch: HEAD Build date: 2023-11-10 12:19:52 UTC Build Information Release ID: 1706070417 Git revision: 179aa48a5702754e41a8218d0403ddc3be46706f Build date: 2023-11-10 12:18:09+00 Build branch: release-17.6 Build lane: release-17.6 Operating System Mac OS X 14.2.1 Darwin 23.2.0 Darwin Kernel Version 23.2.0 Wed Nov 15 21:53:34 PST 2023 root:xnu-10002.61.3~2/RELEASE_ARM64_T8103 arm64 Enabled user installed extensions FigmaSharp 0.8.3 ```

Manual Solution / work-a-round

Editing the created .app folder manually and rename the subfolder "Plugins" to "Extensions" solved the issue, but we need an automatic solution

de-preut commented 10 months ago

My current work-a-round

<Target Name="FixAppExtensionsPathInIPA" AfterTargets="Build">
   <Message Text="Rename 'PlugIns' folder to 'Extensions' to be compatible with Xcode15 builds"></Message>
   <Exec Command="mv $(_AppBundlePath)\PlugIns $(_AppBundlePath)\Extensions" />
</Target>
rolfbjarne commented 10 months ago

This seems to be depending on the type of extension, the "App Intents Extension" has this behavior, while older extensions do not.

I believe this will list the extensions with this behavior for each platform:

$ grep -l EXAppExtensionAttributes /Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/*.platform/Developer/Library/Xcode/Templates/Project\ Templates/*/Application\ Extension/*/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Templates/Project Templates/macOS/Application Extension/App Intents Extension.xctemplate/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Templates/Project Templates/macOS/Application Extension/Background Download Extension.xctemplate/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Templates/Project Templates/macOS/Application Extension/Generic Extension.xctemplate/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/Library/Xcode/Templates/Project Templates/watchOS/Application Extension/App Intents Extension.xctemplate/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/XROS.platform/Developer/Library/Xcode/Templates/Project Templates/xrOS/Application Extension/App Intents Extension.xctemplate/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/XROS.platform/Developer/Library/Xcode/Templates/Project Templates/xrOS/Application Extension/Media Device Discovery Extension.xctemplate/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application Extension/App Intents Extension.xctemplate/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application Extension/Background Download Extension.xctemplate/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application Extension/Device Activity Report Extension.xctemplate/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application Extension/Generic Extension.xctemplate/TemplateInfo.plist
/Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application Extension/Media Device Discovery Extension.xctemplate/TemplateInfo.plist

We'd have to add support for specifying the subdirectory name on a per-extension basis, so this will take a little bit to implement.

Ref: https://github.com/bazelbuild/rules_apple/issues/1943