Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frameworks duplication in iOS extension (plugin) prevents app to be published #17679

Closed
neminush opened this issue Mar 2, 2023 · 3 comments · Fixed by #18913
Closed

Frameworks duplication in iOS extension (plugin) prevents app to be published #17679

neminush opened this issue Mar 2, 2023 · 3 comments · Fixed by #18913
Labels
bug If an issue is a bug or a pull request a bug fix
Milestone

Comments

@neminush
Copy link

neminush commented Mar 2, 2023

Steps to Reproduce

  1. Download this Frameworks_duplication_example.zip example that illustrates our problem;
  2. Build it in 'Release | iPhone' configuration using an actual version of Visual Studio for Mac (https://visualstudio.microsoft.com/downloads/);
  3. Archive it for Publishing;
  4. Try to publish in the App Store Connect;
  5. You will receive a 'CFBundleIdentifier Collision' error;

Expected Behavior

The ipa archive is being prepared without duplicate frameworks and freely uploaded to 'TestFlight'

Actual Behavior

The ipa archive is being prepared with duplicate frameworks and upload to 'TestFlight' is rejected

Environment

Version information
Visual Studio Community 2022 for Mac
Version 17.5 (build 1802)
Installation UUID: 9a2d0522-08c1-4ea1-92a7-4c7f8eb08a26

Runtime
.NET 7.0.1 (64-bit)
Architecture: X64
Microsoft.macOS.Sdk 12.3.2372; git-rev-head:754abbf6a3563f6267e5717ae832b4ac25b1f2fb; git-branch:release/7.0.1xx-xcode13.3

Roslyn (Language Service)
4.5.0-3.23056.2+97881342e427ff5cdcba8f12b12ff8e6f3564431

NuGet
Version: 6.4.0.117

.NET SDK (x64)
SDK: /usr/local/share/dotnet/sdk/7.0.200/Sdks
SDK Versions:
	7.0.200
	7.0.103
	7.0.102
	6.0.406
	6.0.405
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	7.0.3
	7.0.2
	6.0.14
	6.0.13

Xamarin.Profiler
Version: 1.8.0.49
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode: 14.2 21534
Build: 14C18

Xamarin.Mac
Version: 9.1.0.5 Visual Studio Community
Hash: 7738c90c9
Branch: xcode14.2
Build date: 2023-01-25 15:56:14-0500

Xamarin.iOS
Version: 16.2.0.5 Visual Studio Community
Hash: 7738c90c9
Branch: xcode14.2
Build date: 2023-01-25 15:56:15-0500

Xamarin Designer
Version: 17.5.3.47
Hash: e8b5d371c3
Branch: remotes/origin/d17-5
Build date: 2023-02-14 00:26:48 UTC

Xamarin.Android
Version: 13.2.0.0 (Visual Studio Community)
Commit: xamarin-android/d17-5/797e2e1
Android SDK: /Users/neminush/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		12.1 (API level 32)
		12.0 (API level 31)
		13.0 (API level 33)

SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 33.0.3
SDK Build Tools Version: 33.0.0

Build Information: 
Mono: 6dd9def
Java.Interop: xamarin/java.interop/main@149d70fe
SQLite: xamarin/sqlite/3.40.0@fdc1e34
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@9f02d77

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.16.1
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.5.0.33
Hash: f0c0c52
Branch: remotes/origin/d17-5~2
Build date: 2023-02-14 00:26:53 UTC

Android Device Manager
Version: 0.0.0.1245
Hash: 7f8a990
Branch: 7f8a990
Build date: 2023-02-14 00:26:53 UTC

Build Information
Release ID: 1705001802
Git revision: bfdc90915981031f5bdda171c7eebf116a558598
Build date: 2023-02-14 00:24:57+00
Build branch: release-17.5
Build lane: release-17.5

Operating System
Mac OS X 13.1.0
Darwin 22.2.0 Darwin Kernel Version 22.2.0
    Fri Nov 11 02:08:47 PST 2022
    root:xnu-8792.61.2~4/RELEASE_X86_64 x86_64

Detailes

We have an iOS app that includes an iOS Share Extension to allow users to share their content.
The application was originally created to use Mono, but we recently migrated it at .NET 7 and faced a problem.

When we try to upload our *.ipa file to the App Store Connect, this service rejects our build and reports the following errors in response:

  • Asset validation failed (90685) CFBundleIdentifier Collision.
    There is more than one bundle with the CFBundleIdentifier value 'com.microsoft.libSkiaSharp' under the iOS application 'ILive.iOS.app'.
    (ID: 3c47ce8f-71a4-4a3e-8ed1-51da406918f2)

  • Asset validation failed (90206) Invalid Bundle.
    The bundle at 'ILive.iOS.app/PlugIns/ILive.iOS.Share.appex' contains disallowed file 'Frameworks'.
    (ID: b8190f6a-8561-4e90-b4b7-57314bc327e8)

  • Asset validation failed (90685) CFBundleIdentifier Collision.
    There is more than one bundle with the CFBundleIdentifier value 'org.videolan.DynamicMobileVLCKit' under the iOS application 'ILive.iOS.app'.
    (ID: 9b1f36f5-0649-41da-87f5-bce1217deac5)

  • Asset validation failed (90685) CFBundleIdentifier Collision.
    There is more than one bundle with the CFBundleIdentifier value 'com.microsoft.libHarfBuzzSharp' under the iOS application 'ILive.iOS.app'.
    (ID: 7cd6eaa1-63c2-47ea-aac5-a761b65309fa)

  • Asset validation failed (90205) Invalid Bundle.
    The bundle at 'ILive.iOS.app/PlugIns/ILive.iOS.Share.appex' contains disallowed nested bundles. (ID: f00fb3b2-a5d8-4e63-bebd-a32593d53d62)

In the screenshots you can see the changes that occurred after the migration.

The old option. The application built for Mono has the following structure (see screenshots). There are no problems with such build.
01 Mono - Main
02 Mono - Plugin part 1
03 Mono - Plugin part 2

The new option. The application built for .NET 7 has the following structure (see screenshots). There are a problem with frameworks duplication in 'ILive.iOS.Share.appex'.
04 dotNET7 - Main
05 dotNET7 - Plugin part 1
06 dotNET7 - Plugin part 2

The 'DynamicMobileVLCKit' framework is not directly used in 'iLive.iOS.Share', but it connects transitively. And if you don't connect nuget packages 'LibVLCSharp' and 'VideoLAN.LibVLC.iOS', then the project will simply not be assembled. These nuget packages are useless for this project, but required to build 'ILive.iOS.Share'.

The application in both cases (Mono and .NET 7) is normally builds, deploys to the device and works.

But in the second case, it cannot be published.

We can change the structure of our application and get rid of 'DynamicMobileVLCKit' framework in 'ILive.iOS.Share', but we will not be able to get rid of 'com.microsoft.libSkiaSharp'.

How do we solve this problem?

@rolfbjarne
Copy link
Member

rolfbjarne commented Mar 3, 2023

I can confirm the issue.

Can you try adding this workaround to the extension project, and see if it fixes the issue for you?

  <Target Name="RemoveFrameworks" AfterTargets="_ComputeFrameworkFilesToPublish" BeforeTargets="_CopyDirectoriesToBundle">
    <ItemGroup>
      <_DirectoriesToPublish Remove="@(_FilteredFrameworkToPublish)" />
    </ItemGroup>
  </Target>
  <Target Name="SetRPath" AfterTargets="_ComputeVariables" BeforeTargets="_LinkNativeExecutable">
    <PropertyGroup>
      <_EmbeddedFrameworksRPath>@executable_path/../../Frameworks</_EmbeddedFrameworksRPath>
    </PropertyGroup>
  </Target>

The workaround makes the extension project not copy the frameworks into the appex, and then tells the extension executable to look in the parent app container for any frameworks. Note that this workaround will only work as long as the main app already contains the frameworks the extension needs (which seems to be the case for your project).

@rolfbjarne rolfbjarne added this to the .NET 8 milestone Mar 3, 2023
@rolfbjarne rolfbjarne added the bug If an issue is a bug or a pull request a bug fix label Mar 3, 2023
@neminush
Copy link
Author

neminush commented Mar 3, 2023

@rolfbjarne This workaround completely solves our problem. Thank you very much

@rolfbjarne
Copy link
Member

Any fix for #17876 will also fix this issue.

rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Sep 1, 2023
Fixes xamarin#17876.

Put any frameworks in app extensions in the Frameworks directory in the
containing app bundle. This saves a lot of space if the same framework is used
in both an app extension and the containing project (or multiple app
extensions).

Fixes xamarin#17876.
Fixes xamarin#17679.
rolfbjarne added a commit that referenced this issue Sep 11, 2023
Fixes #17876. (#18913)

Put any frameworks in app extensions in the Frameworks directory in the
containing app bundle. This saves a lot of space if the same framework is used
in both an app extension and the containing project (or multiple app
extensions).

Fixes #17876.
Fixes #17679.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix
Projects
None yet
2 participants