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.48k stars 514 forks source link

.NET: copy the pdb for our platform assembly to the .app #11879

Closed rolfbjarne closed 1 year ago

rolfbjarne commented 3 years ago

Steps to Reproduce

  1. Build an iOS.NET app
  2. Look for Microsoft.iOS.pdb in the .app
  3. Fail

Expected Behavior

We should bundle the Microsoft.iOS.pdb for Debug configurations, or if MtouchDebug/MmpDebug is true.

Diagnosis

This is because of https://github.com/dotnet/sdk/issues/1458.

Workaround

Add this to a Directory.Build.targets file:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <!-- https://github.com/dotnet/sdk/issues/1458#issuecomment-420456386 -->
    <Target Name="_ResolveCopyLocalNuGetPackagePdbsAndXml" Condition="$(CopyLocalLockFileAssemblies) == true" AfterTargets="ResolveReferences">
        <ItemGroup>
            <ReferenceCopyLocalPaths
                Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).pdb')"
                Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != '' and Exists('%(RootDir)%(Directory)%(Filename).pdb')" />
        </ItemGroup>
    </Target>
</Project>

but we should come up with something in our own targets files.

spouliot commented 2 years ago

This makes both "Source Link" and "sources embedded inside PDB" unusable for iOS, macOS, MacCatalyst (and tvOS).

However this works fine with Android builds - so it might be an easy "cut and paste" solution to fix this :-)

l bin/Debug/net6.0-ios/iossimulator-arm64/DebugMyApp.Mobile.app/*.pdb
-rw-r--r--  1 poupou  staff   338K 13 Oct 19:26 bin/Debug/net6.0-ios/iossimulator-arm64/DebugMyApp.Mobile.app/DebugMyApp.Mobile.pdb

l bin/Debug/net6.0-macos/osx-arm64/DebugMyApp.Mobile.app/Contents/MonoBundle/*.pdb                             
-rw-r--r--  1 poupou  staff   286K 13 Oct 09:29 bin/Debug/net6.0-macos/osx-arm64/DebugMyApp.Mobile.app/Contents/MonoBundle/DebugMyApp.Mobile.pdb

l bin/Debug/net6.0-maccatalyst/maccatalyst-arm64/DebugMyApp.Mobile.app/Contents/MonoBundle/*.pdb               
-rw-r--r--  1 poupou  staff   337K 13 Oct 19:19 bin/Debug/net6.0-maccatalyst/maccatalyst-arm64/DebugMyApp.Mobile.app/Contents/MonoBundle/DebugMyApp.Mobile.pdb

l bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/*.pdb                                
-rw-r--r--  1 poupou  staff   460K 13 Oct 16:43 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/DebugMyApp.Mobile.pdb
-rwxr--r--  1 poupou  staff    82K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Java.Interop.pdb
-rwxr--r--  1 poupou  staff    39K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Mono.Android.Export.pdb
-rwxr--r--  1 poupou  staff    12M 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Mono.Android.pdb
-rwxr--r--  1 poupou  staff    12K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.Core.Extensions.Logging.Singleton.pdb
-rwxr--r--  1 poupou  staff    15K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.Core.Extensions.Logging.pdb
-rwxr--r--  1 poupou  staff    13K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.Diagnostics.Eventing.pdb
-rwxr--r--  1 poupou  staff    12K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.Foundation.Logging.pdb
-rwxr--r--  1 poupou  staff   107K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.Foundation.pdb
-rwxr--r--  1 poupou  staff    11K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.UI.Adapter.Microsoft.Extensions.Logging.pdb
-rwxr--r--  1 poupou  staff    42K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.UI.BindingHelper.Android.pdb
-rwxr--r--  1 poupou  staff    82K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.UI.Composition.pdb
-rwxr--r--  1 poupou  staff    30K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.UI.Dispatching.pdb
-rwxr--r--  1 poupou  staff    31K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.UI.FluentTheme.pdb
-rwxr--r--  1 poupou  staff   1.1M 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.UI.FluentTheme.v1.pdb
-rwxr--r--  1 poupou  staff   1.3M 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.UI.FluentTheme.v2.pdb
-rwxr--r--  1 poupou  staff    32K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.UI.RemoteControl.pdb
-rwxr--r--  1 poupou  staff    37K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.UI.Toolkit.pdb
-rwxr--r--  1 poupou  staff   3.8M 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.UI.pdb
-rwxr--r--  1 poupou  staff   1.4M 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Uno.pdb
-rwxr--r--  1 poupou  staff    46K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Activity.pdb
-rwxr--r--  1 poupou  staff    17K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Annotation.Experimental.pdb
-rwxr--r--  1 poupou  staff    64K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Annotation.pdb
-rwxr--r--  1 poupou  staff    34K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.AppCompat.AppCompatResources.pdb
-rwxr--r--  1 poupou  staff   433K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.AppCompat.pdb
-rwxr--r--  1 poupou  staff    17K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Arch.Core.Common.pdb
-rwxr--r--  1 poupou  staff    15K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Arch.Core.Runtime.pdb
-rwxr--r--  1 poupou  staff    13K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.AsyncLayoutInflater.pdb
-rwxr--r--  1 poupou  staff    46K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Browser.pdb
-rwxr--r--  1 poupou  staff    16K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.CardView.pdb
-rwxr--r--  1 poupou  staff    38K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Collection.pdb
-rwxr--r--  1 poupou  staff   386K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.ConstraintLayout.Core.pdb
-rwxr--r--  1 poupou  staff   258K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.ConstraintLayout.pdb
-rwxr--r--  1 poupou  staff    41K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.CoordinatorLayout.pdb
-rwxr--r--  1 poupou  staff   689K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Core.pdb
-rwxr--r--  1 poupou  staff    26K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.CursorAdapter.pdb
-rwxr--r--  1 poupou  staff    29K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.CustomView.pdb
-rwxr--r--  1 poupou  staff    16K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.DocumentFile.pdb
-rwxr--r--  1 poupou  staff    27K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.DrawerLayout.pdb
-rwxr--r--  1 poupou  staff    28K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.DynamicAnimation.pdb
-rwxr--r--  1 poupou  staff   122K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Fragment.pdb
-rwxr--r--  1 poupou  staff    13K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Interpolator.pdb
-rwxr--r--  1 poupou  staff    18K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Legacy.Support.Core.UI.pdb
-rwxr--r--  1 poupou  staff    13K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Legacy.Support.Core.Utils.pdb
-rwxr--r--  1 poupou  staff    12K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Legacy.Support.V4.pdb
-rwxr--r--  1 poupou  staff    21K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Lifecycle.Common.pdb
-rwxr--r--  1 poupou  staff    17K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Lifecycle.LiveData.Core.pdb
-rwxr--r--  1 poupou  staff    15K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Lifecycle.Runtime.pdb
-rwxr--r--  1 poupou  staff    18K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Lifecycle.ViewModel.pdb
-rwxr--r--  1 poupou  staff    14K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Lifecycle.ViewModelSavedState.pdb
-rwxr--r--  1 poupou  staff    29K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Loader.pdb
-rwxr--r--  1 poupou  staff    13K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.LocalBroadcastManager.pdb
-rwxr--r--  1 poupou  staff   164K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Media.pdb
-rwxr--r--  1 poupou  staff    14K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Print.pdb
-rwxr--r--  1 poupou  staff   231K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.RecyclerView.pdb
-rwxr--r--  1 poupou  staff    16K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.SavedState.pdb
-rwxr--r--  1 poupou  staff    22K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.SlidingPaneLayout.pdb
-rwxr--r--  1 poupou  staff    29K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.SwipeRefreshLayout.pdb
-rwxr--r--  1 poupou  staff    12K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Tracing.Tracing.pdb
-rwxr--r--  1 poupou  staff    66K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.Transition.pdb
-rwxr--r--  1 poupou  staff    22K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.VectorDrawable.Animated.pdb
-rwxr--r--  1 poupou  staff    17K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.VectorDrawable.pdb
-rwxr--r--  1 poupou  staff    49K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.VersionedParcelable.pdb
-rwxr--r--  1 poupou  staff    35K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.ViewPager.pdb
-rwxr--r--  1 poupou  staff    28K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.AndroidX.ViewPager2.pdb
-rwxr--r--  1 poupou  staff   698K 12 Oct 10:54 bin/Debug/net6.0-android/android-arm64/DebugMyApp.DebugMyApp/assemblies/Xamarin.Google.Android.Material.pdb
spouliot commented 2 years ago

according to https://github.com/dotnet/sdk/issues/1458#issuecomment-1244736464 that might be fixed (opt-in) in 7.0

spouliot commented 2 years ago

from a quick test https://github.com/SimonCropp/Cymbal seems to work fine too

spouliot commented 1 year ago

@rolfbjarne it would be nice to include this for net8 along with enabling SourceLink and embedding the generated source code into the .pdb.

This would allow VSCode to debug the iOS/Mac SDK internals (including binding code) just like it already works (without any workaround) for the Android SDK. https://twitter.com/spouliot/status/1653828865221861391?s=20

c.c. @dalexsoto

rolfbjarne commented 1 year ago

according to dotnet/sdk#1458 (comment) that might be fixed (opt-in) in 7.0

Unfortunately setting CopyDebugSymbolFilesFromPackages=true only works with normal NuGets (resolved in the ResolvePackageAssets target), not runtime packs (resolved in the ResolveRuntimePackAssets target). There doesn't seem to be a way to have ResolveRuntimePackAssets find pdbs.

However this works fine with Android builds - so it might be an easy "cut and paste" solution to fix this :-)

Android's build logic is very different from ours :/

Android also implemented SourceLink support (https://github.com/xamarin/xamarin-android/pull/7298), which we haven't yet, but I've opened an issue for this: https://github.com/xamarin/xamarin-macios/issues/18968