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

Code object is not signed at all System.ServiceModel.Web.dll #20555

Closed
Elinares-82 opened this issue May 3, 2024 · 13 comments
Closed

Code object is not signed at all System.ServiceModel.Web.dll #20555

Elinares-82 opened this issue May 3, 2024 · 13 comments
Labels
need-info Waiting for more information before the bug can be investigated

Comments

@Elinares-82
Copy link

Elinares-82 commented May 3, 2024

Steps to Reproduce

  1. Ported XF app to MAUI
  2. Compile de app connected to a brand new Mac machine Macbook Air M1
  3. Not compilation success since Code object is not signed at all with random .dll

Expected Behavior

Compile the app as we can do it with an old machine Macbook Pro Intel processor.

Actual Behavior

Not compile with the following error:

Severity Code Description Project File Line Suppression State Details
Error /usr/bin/codesign exited with code 1:
/Users/xxxxx/Library/Caches/Xamarin/mtbs/builds/NeighborStore.Mobile.App/65bf70b6a9038eb78bf23acea14c81430aa649c361aff5226066ad748ca94b87/bin/Debug/net8.0-ios/iossimulator-x64/NeighborStore.Mobile.App.app: code object is not signed at all
In subcomponent: /Users/xxxxx/Library/Caches/Xamarin/mtbs/builds/NeighborStore.Mobile.App/65bf70b6a9038eb78bf23acea14c81430aa649c361aff5226066ad748ca94b87/bin/Debug/net8.0-ios/iossimulator-x64/NeighborStore.Mobile.App.app/System.ServiceModel.Web.dll NeighborStore.Mobile.App C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.2.8004\tools\msbuild\iOS\Xamarin.Shared.targets 2256

Severity Code Description Project File Line Suppression State Details
Error Failed to codesign '/Users/xxxxx/Library/Caches/Xamarin/mtbs/builds/NeighborStore.Mobile.App/65bf70b6a9038eb78bf23acea14c81430aa649c361aff5226066ad748ca94b87/bin/Debug/net8.0-ios/iossimulator-x64/NeighborStore.Mobile.App.app': /Users/xxxx/Library/Caches/Xamarin/mtbs/builds/NeighborStore.Mobile.App/65bf70b6a9038eb78bf23acea14c81430aa649c361aff5226066ad748ca94b87/bin/Debug/net8.0-ios/iossimulator-x64/NeighborStore.Mobile.App.app: code object is not signed at all
In subcomponent: /Users/xxxx/Library/Caches/Xamarin/mtbs/builds/NeighborStore.Mobile.App/65bf70b6a9038eb78bf23acea14c81430aa649c361aff5226066ad748ca94b87/bin/Debug/net8.0-ios/iossimulator-x64/NeighborStore.Mobile.App.app/System.ServiceModel.Web.dll

    	NeighborStore.Mobile.App	C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.2.8004\tools\msbuild\iOS\Xamarin.Shared.targets	2256	

Environment

Windows machine connected to mac

All the certificates are in the KeyStore

Version information

Visual Studio 17.9.6
Macbook Air M1 2020 Sonoma 14.4.1 Xcode 15.2

I created a new MAUI solution and configured the app identifier and compile as expected and run the app in a physical phone and emulator as well.

Build Logs

Example Project (If Possible)

MSBuild_Logs.zip

@rolfbjarne
Copy link
Member

rolfbjarne commented May 3, 2024

This error happens if there's a Resources directory in the app bundle (see #20135).

It looks like these two items:

<ItemGroup>
  <EmbeddedResource Include="Resources\Configuration\appsettings.json">
    <LogicalName>appsettings.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
  <EmbeddedResource Include="Resources\Configuration\server.json">
    <LogicalName>server.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
</ItemGroup>

somehow ends up in the Resources/Configuration subdirectory, even though LogicalName is set to the correct value to avoid that.

I have two ideas to try:

  1. Use forward slashes instead of backwards slashes:
<ItemGroup>
  <EmbeddedResource Include="Resources/Configuration/appsettings.json">
    <LogicalName>appsettings.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
  <EmbeddedResource Include="Resources/Configuration/server.json">
    <LogicalName>server.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
</ItemGroup>
  1. Use BundleResource instead of EmbeddedResource:
<ItemGroup>
  <BundleResource Include="Resources\Configuration\appsettings.json">
    <LogicalName>appsettings.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
  <BundleResource Include="Resources\Configuration\server.json">
    <LogicalName>server.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
</ItemGroup>

Can you try either of these to see if they work?

@rolfbjarne rolfbjarne added the need-info Waiting for more information before the bug can be investigated label May 3, 2024
@rolfbjarne rolfbjarne added this to the Future milestone May 3, 2024
@Elinares-82
Copy link
Author

This error happens if there's a Resources directory in the app bundle (see #20135).

It looks like these two items:

<ItemGroup>
  <EmbeddedResource Include="Resources\Configuration\appsettings.json">
    <LogicalName>appsettings.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
  <EmbeddedResource Include="Resources\Configuration\server.json">
    <LogicalName>server.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
</ItemGroup>

somehow ends up in the Resources/Configuration subdirectory, even though LogicalName is set to the correct value to avoid that.

I have two ideas to try:

  1. Use forward slashes instead of backwards slashes:
<ItemGroup>
  <EmbeddedResource Include="Resources/Configuration/appsettings.json">
    <LogicalName>appsettings.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
  <EmbeddedResource Include="Resources/Configuration/server.json">
    <LogicalName>server.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
</ItemGroup>
  1. Use BundleResource instead of EmbeddedResource:
<ItemGroup>
  <BundleResource Include="Resources\Configuration\appsettings.json">
    <LogicalName>appsettings.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
  <BundleResource Include="Resources\Configuration\server.json">
    <LogicalName>server.json</LogicalName>
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </EmbeddedResource>
</ItemGroup>

Can you try either of these to see if they work?

Sure, I'll try this and let you know the results. however, this is not happening with the other old mac, may be is for the new M1, why this happens?

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels May 3, 2024
@Elinares-82
Copy link
Author

BundleResource 

Using the option 1 I got the same error. With the option 2 the app compiles well, however, does not run since the files server.json and appsettings.json are needed in the assembly. Also, the background color is not being displayed. I'm attaching another msbuild in case can help to provide more information.

Uploading msbuild.zip…

@Elinares-82
Copy link
Author

I moved the server and appsettings files outside of the Resources folder and apparently in compiling. however, when the app startup I go a new exception

ObjCRuntime.ObjCException
Message=Objective-C exception thrown. Name: ObjCRuntime.RuntimeException Reason: Failed to lookup the required marshalling information.
Additional information:
Selector: _ct_block_application:didRegisterForRemoteNotificationsWithDeviceToken:_0x600002c57780
Type: GUL_AppDelegate-8A8785C0-9E13-46EB-A7F1-291ED62552C6
(ObjCRuntime.RuntimeException)
Cannot get the method descriptor for the selector '_ct_block_application:didRegisterForRemoteNotificationsWithDeviceToken:_0x600002c57780' on the type 'NeighborStore.Mobile.App.AppDelegate', because the selector does not correspond to a method (ObjCRuntime.RuntimeException)
at Registrar.DynamicRegistrar.GetMethodNoThrow(Type original_type, Type type, String selector, Boolean is_static) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:line 907
at Registrar.DynamicRegistrar.GetMethodNoThrow(Type original_type, Type type, String selector, Boolean is_static) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:line 902
at Registrar.DynamicRegistrar.GetMethodNoThrow(Type original_type, Type type, String selector, Boolean is_static) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:line 902
at Registrar.DynamicRegistrar.GetMethodNoThrow(Type original_type, Type type, String selector, Boolean is_static) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:line 902
at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:line 858
at ObjCRuntime.Runtime.GetMethodAndObjectForSelector(IntPtr klass, IntPtr sel, SByte is_static, IntPtr obj, IntPtr* mthisPtr, IntPtr desc) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 912
at ObjCRuntime.Runtime.get_method_and_object_for_selector(IntPtr cls, IntPtr sel, SByte is_static, IntPtr obj, IntPtr* mthis, IntPtr desc, IntPtr* exception_gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/runtime/Delegates.generated.cs:line 712

Native stack trace:
0 CoreFoundation 0x0000000117b58761 _exceptionPreprocess + 242
1 libobjc.A.dylib 0x0000000124875904 objc_exception_throw + 48
2 libxamarin-dotnet-debug.dylib 0x0000000110450016 xamarin_process_managed_exception + 934
3 libxamarin-dotnet-debug.dylib 0x000000011044fbbb xamarin_process_managed_exception_gchandle + 59
4 libxamarin-dotnet-debug.dylib 0x000000011045ccf3 xamarin_invoke_trampoline + 8547
5 libxamarin-dotnet-debug.dylib 0x0000000110463d39 xamarin_arch_trampoline + 105
6 libxamarin-dotnet-debug.dylib 0x0000000110464f1a xamarin_x86_64_common_trampoline + 118
7 CoreFoundation 0x0000000117b5f38c invoking
+ 140
8 CoreFoundation 0x0000000117b5c6b3 -[NSInvocation invoke] + 302
9 CoreFoundation 0x0000000117b5c923 -[NSInvocation invokeWithTarget:] + 70
10 CleverTapSDK 0x000000010e915b18 __31+[CleverTap swizzleAppDelegate]_block_invoke.118 + 200
11 UIKitCore 0x000000013d8f17ef __63-[UIApplication pushRegistry:didUpdatePushCredentials:forType:]_block_invoke + 106
12 libdispatch.dylib 0x0000000124ed6a90 _dispatch_call_block_and_release + 12
13 libdispatch.dylib 0x0000000124ed7d3a _dispatch_client_callout + 8
14 libdispatch.dylib 0x0000000124ee6ac0 _dispatch_main_queue_drain + 1420
15 libdispatch.dylib 0x0000000124ee6526 _dispatch_main_queue_callback_4CF + 31
16 CoreFoundation 0x0000000117ab4dc4 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
17 CoreFoundation 0x0000000117aaf6ff __CFRunLoopRun + 2463
18 CoreFoundation 0x0000000117aae97d CFRunLoopRunSpecific + 557
19 GraphicsServices 0x000000012707c08f GSEventRunModal + 137
20 UIKitCore 0x000000013d8ca53d -[UIApplication _run] + 972
21 UIKitCore 0x000000013d8cefab UIApplicationMain + 123
22 libxamarin-dotnet-debug.dylib 0x000000011041f50a xamarin_UIApplicationMain + 58
23 libmonosgen-2.0.dylib 0x00000001111c7765 do_icall + 341
24 libmonosgen-2.0.dylib 0x00000001111c5ef7 do_icall_wrapper + 295
25 libmonosgen-2.0.dylib 0x00000001111b6c16 mono_interp_exec_method + 3990
26 libmonosgen-2.0.dylib 0x00000001111b4383 interp_runtime_invoke + 259
27 libmonosgen-2.0.dylib 0x000000011129a6f8 mono_runtime_invoke_checked + 136
28 libmonosgen-2.0.dylib 0x00000001112a203b mono_runtime_exec_main_checked + 107
29 libmonosgen-2.0.dylib 0x0000000111106b62 mono_jit_exec + 354
30 libxamarin-dotnet-debug.dylib 0x0000000110463bea xamarin_main + 1898
31 NeighborStore.Mobile.App 0x0000000104a85b54 main + 68
32 dyld 0x000000010db023e0 start_sim + 10
33 ??? 0x00000002053c7366 0x0 + 8677782374

Source=Microsoft.iOS
StackTrace:
at ObjCRuntime.Runtime.ThrowNSException(IntPtr ns_exception) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 507
at ObjCRuntime.Runtime.throw_ns_exception(IntPtr exc) in /Users/builder/azdo/_work/1/s/xamarin-macios/runtime/Delegates.generated.cs:line 279
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
at NeighborStore.Mobile.App.Program.Main(String[] args) in F:\eMobile\Src\NeighborStore.Mobile\NeighborStore.Mobile.App\Platforms\iOS\Program.cs:line 13

@Elinares-82
Copy link
Author

ObjCRuntime.RuntimeException Reason: Failed to lookup the required marshalling information.

I had to comment these lines, but the push notification won't work.

image

image

@rolfbjarne
Copy link
Member

BundleResource 

Using the option 1 I got the same error. With the option 2 the app compiles well, however, does not run since the files server.json and appsettings.json are needed in the assembly. Also, the background color is not being displayed. I'm attaching another msbuild in case can help to provide more information.

Uploading msbuild.zip…

Looks like the msbuild.zip didn't upload correctly, can you try again please?

@rolfbjarne
Copy link
Member

Cannot get the method descriptor for the selector '_ct_block_application:didRegisterForRemoteNotificationsWithDeviceToken:_0x600002c57780' on the type 'NeighborStore.Mobile.App.AppDelegate', because the selector does not correspond to a method (ObjCRuntime.RuntimeException)

...

10 CleverTapSDK 0x000000010e915b18 __31+[CleverTap swizzleAppDelegate]_block_invoke.118 + 200

The problem is that the CleverTapSDK doesn't do swizzling right.

They intercept calls to application:didRegisterForRemoteNotificationsWithDeviceToken:. In their interceptor method they do their stuff, before they call the original (your) application:didRegisterForRemoteNotificationsWithDeviceToken: implementation. An additional detail is that every Objective-C method takes an hidden argument, which is the selector of the called method. Their bug is that they call the original implementation with the selector of their interceptor implementation - this is typically not a problem for an Objective-C program (although it's wrong and certainly visible if you look for it), but for us it's paramount this hidden argument is correct, because we use the selector to find the managed method to call, and we won't find the managed method using their selector name (thus the exception).

@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated and removed need-attention An issue requires our attention/response labels May 6, 2024
@Elinares-82
Copy link
Author

Elinares-82 commented May 6, 2024

but for us it's paramount this hidden argument is correct, because we use the selector to find the managed method to call, and we won't find the managed method using their selector name (thus the exception).

So that I'm understanding is I have to report this to CleverTap team to fix it? My Question is why with the older Mac this is not happening?

I'll remove the CleverTap implementation and test again.

This is the repo of CleverTap in case you could check it up

https://github.com/CleverTap/clevertap-xamarin/blob/master/clevertap-component/src/ios/CleverTap.DotNet.iOS.Binding/CleverTap.DotNet.iOS.Binding/ApiDefinition.cs

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels May 6, 2024
@Elinares-82
Copy link
Author

but for us it's paramount this hidden argument is correct, because we use the selector to find the managed method to call, and we won't find the managed method using their selector name (thus the exception).

So that I'm understanding is I have to report this to CleverTap team to fix it? My Question is why with the older Mac this is not happening?

I'll remove the CleverTap implementation and test again.

This is the repo of CleverTap in case you could check it up

https://github.com/CleverTap/clevertap-xamarin/blob/master/clevertap-component/src/ios/CleverTap.DotNet.iOS.Binding/CleverTap.DotNet.iOS.Binding/ApiDefinition.cs

I removed clevertap implementation and the app is running as expected with the brand-new MacBook air M1. The MacBook pro Intel compiles the app as well without any change, so I do not understand this different.

@rolfbjarne
Copy link
Member

but for us it's paramount this hidden argument is correct, because we use the selector to find the managed method to call, and we won't find the managed method using their selector name (thus the exception).

So that I'm understanding is I have to report this to CleverTap team to fix it?

Correct.

My Question is why with the older Mac this is not happening?

I don't know; I'd need a test project that I can use to reproduce the behavior in order to figure this out.

@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated and removed need-attention An issue requires our attention/response labels May 8, 2024
@Elinares-82
Copy link
Author

but for us it's paramount this hidden argument is correct, because we use the selector to find the managed method to call, and we won't find the managed method using their selector name (thus the exception).

So that I'm understanding is I have to report this to CleverTap team to fix it?

Correct.

My Question is why with the older Mac this is not happening?

I don't know; I'd need a test project that I can use to reproduce the behavior in order to figure this out.

I'm working on an example project to use CleverTap and try to replicate this issue.

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels May 9, 2024
@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated and removed need-attention An issue requires our attention/response labels May 20, 2024
@Elinares-82
Copy link
Author

but for us it's paramount this hidden argument is correct, because we use the selector to find the managed method to call, and we won't find the managed method using their selector name (thus the exception).

So that I'm understanding is I have to report this to CleverTap team to fix it?

Correct.

My Question is why with the older Mac this is not happening?

I don't know; I'd need a test project that I can use to reproduce the behavior in order to figure this out.

I'm working on an example project to use CleverTap and try to replicate this issue.

Apparently CleverTap released a new version of their nuget and now it's working. But I got the error serval times even when I deleted bin, obj, mac build. But for some reason I was able to compile a run the app in the emulator. I'll try in a physical device.

Copy link
Contributor

Hi @Elinares-82. Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-info Waiting for more information before the bug can be investigated
Projects
None yet
Development

No branches or pull requests

2 participants