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

Codesign fails for iOS target #4621

Closed
johnpaulsmith87 opened this issue Feb 11, 2022 · 7 comments
Closed

Codesign fails for iOS target #4621

johnpaulsmith87 opened this issue Feb 11, 2022 · 7 comments
Assignees
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) platform/iOS 🍎 t/bug Something isn't working
Milestone

Comments

@johnpaulsmith87
Copy link

Description

Codesign fails for iOS target. When all the settings appear to be correct (i.e correct project name, correct certificate, correct provisioning profile, correct Info.plist etc..), codesign just fails with exit code 1. Interestingly, when I change the name of project to anything other than the correct name, codesign will succeed but the resultant .ipa will fail to validate.
The app will run in debug configuration and with a simulator as target.
I should mention that this is for an already existing app as we're exploring the possibility of replacing it with .NET MAUI, so it already has a provisioning profile/certificate (Apple Distribution). I've created blank Xamarin.Forms and SwiftUI apps and was able to sign and validate with the same profile/certificate.
I understand that publishing may not be fully supported yet, but I was able to publish for Android without issue and get the signed .apk accepted by the play store.

Steps to Reproduce

  1. In macOS, run dotnet publish -f:net6.0-ios -c:Release /p:ArchiveOnBuild=true with the following settings in the .csproj:
    image
  2. It will build and detect the signing identity but fail to sign
    image
    (I've redacted some details related to the name of the project/certificates/profiles)

Version with bug

Preview 12 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 15

Did you find any workaround?

No as of yet.

Relevant log output

No response

@johnpaulsmith87 johnpaulsmith87 added the t/bug Something isn't working label Feb 11, 2022
@bolshoytoster
Copy link

@johnpaulsmith87 have you looked at some of the answers on this stackoverflow question?

@jfversluis jfversluis added the area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) label Feb 14, 2022
@jfversluis
Copy link
Member

Hey @johnpaulsmith87 I definitely have signing and archiving working (also see #4397 if you haven't seen it already) curious why this happens though.

Could you follow the instructions here: dotnet/macios#6813 (comment) in regards to enable more logging and attach the logs or maybe investigate yourself and see if you can discover anything with that?

@johnpaulsmith87
Copy link
Author

(bear in mind that I am building this on a Mac and VS 2022 Preview doesn't support MAUI as of this exact moment)
Thanks for the replies. Just to clarify, I can sign and archive the build and generate an *.ipa file by changing the name of the project (to an incorrect name), however, that archive will not pass XCode/xcrun validation. When I specify the correct project name; however, it will simply not sign as above. When I set dotnet publish -v d, the error detail isn't too helpful as far as I can tell but I'll paste it below
image

When I build it from a Windows machine using the exact command specified in #4397 I get validation errors
image

@Redth Redth added this to the 6.0.300 milestone Mar 23, 2022
@Redth
Copy link
Member

Redth commented Mar 23, 2022

@rolfbjarne is this related to the recent path issues/fixes?

@rolfbjarne
Copy link
Member

@Redth without knowing the exact versions involved I can't be sure, but this is most likely fixed in the latest service release that came out yesterday (preview 14.122 has the fix, while earlier versions don't).

@ElementalLogic
Copy link

I'm running 14.122 (with Xcode 13.2.1), and getting a similar error:

Target "_CodesignAppBundle" in file "C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.122\tools\msbuild\iOS\Xamarin.Shared.targets": 1> Using "Codesign" task from assembly "C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.122\tools\msbuild\iOS\..\iOS\Xamarin.iOS.Tasks.dll". 1> Task "Codesign" 1> Task Parameter:SessionId=0f1e4cdf14fa622132609c9ce8057ee583cdfb360497bc97f4c41ba596d325de 1> Task Parameter: 1> Resources= 1> bin\Release\net6.0-ios\ios-arm64\MauiApp4.app 1> CodesignAdditionalFilesToTouch=bin\Release\net6.0-ios\ios-arm64\MauiApp4.app.dSYM\Contents\Info.plist 1> CodesignAllocate=\Applications\Xcode.app\Contents\Developer\Toolchains\XcodeDefault.xctoolchain\usr\bin\codesign_allocate 1> CodesignDeep=false 1> CodesignDisableTimestamp=False 1> CodesignEntitlements=obj\Release\net6.0-ios\ios-arm64\Entitlements.xcent 1> CodesignExtraArgs= 1> CodesignKeychain= 1> CodesignRelativeAppBundlePath=Release\net6.0-ios\ios-arm64\MauiApp4.app 1> CodesignResourceRules= 1> CodesignSigningKey=B929A108AF682F32F11CE92B284A74FD86743382 1> CodesignStampFile=bin\Release\net6.0-ios\ios-arm64\MauiApp4.app\_CodeSignature\CodeResources 1> CodesignStampPath=obj\Release\net6.0-ios\ios-arm64\codesign\ 1> CodesignUseHardenedRuntime= 1> CodesignUseSecureTimestamp= 1> IsInputDirectory=true 1> Codesign: 2022-04-07T16:05:07.7790229+01:00 - Started 1> Codesign: 2022-04-07T16:05:07.7790229+01:00 - Initializing 1> [xma]: Trying to get a Build Connection for Session '0f1e4cdf14fa622132609c9ce8057ee583cdfb360497bc97f4c41ba596d325de': Xamarin.Messaging.Build.Client.BuildConnection.0f1e4cdf14fa622132609c9ce8057ee583cdfb360497bc97f4c41ba596d325de, Lifetime: AppDomain 1> Codesign: 2022-04-07T16:05:07.7790229+01:00 - Initialized 1> Codesign: 2022-04-07T16:05:07.7800233+01:00 - There's no available inputs to copy to the Mac 1> Codesign: 2022-04-07T16:05:07.7800233+01:00 - Serializing intputs 1> Codesign: 2022-04-07T16:05:07.7880226+01:00 - Executing 1> [xma]: Starting remote task execution for 'MauiApp4': Xamarin.MacDev.Tasks.Codesign 1> [xma]: Sending Request Xamarin.Messaging.Build.Contracts.ExecuteTaskMessage to topic xvs/build/execute-task/MauiApp4/0f1e4cd002fCodesign 1> [xma]: Received Response of Xamarin.Messaging.Build.Contracts.ExecuteTaskMessage to topic build0f1e4cdf14fa622132609c9ce8057ee583cdfb360497bc97f4c41ba596d325de23364jamie/+/xvs/build/execute-task/MauiApp4/0f1e4cd002fCodesign 1> Codesign: 2022-04-07T16:05:08.4528915+01:00 - Logging messages 1> The stamp file 'bin/Release/net6.0-ios/ios-arm64/MauiApp4.app/_CodeSignature/CodeResources' does not exist, so the item '/Users/jamiemoore/Library/Caches/Xamarin/mtbs/builds/MauiApp4/0f1e4cdf14fa622132609c9ce8057ee583cdfb360497bc97f4c41ba596d325de/bin/Release/net6.0-ios/ios-arm64/MauiApp4.app' needs to be codesigned. 1> Tool /usr/bin/codesign execution started with arguments: -v --force --timestamp=none --sign B929A108AF682F32F11CE92B284A74FD86743382 --entitlements /Users/jamiemoore/Library/Caches/Xamarin/mtbs/builds/MauiApp4/0f1e4cdf14fa622132609c9ce8057ee583cdfb360497bc97f4c41ba596d325de/obj/Release/net6.0-ios/ios-arm64/Entitlements.xcent /Users/jamiemoore/Library/Caches/Xamarin/mtbs/builds/MauiApp4/0f1e4cdf14fa622132609c9ce8057ee583cdfb360497bc97f4c41ba596d325de/bin/Release/net6.0-ios/ios-arm64/MauiApp4.app 1> Tool /usr/bin/codesign execution finished (exit code = 1). 1> /Users/jamiemoore/Library/Caches/Xamarin/mtbs/builds/MauiApp4/0f1e4cdf14fa622132609c9ce8057ee583cdfb360497bc97f4c41ba596d325de/bin/Release/net6.0-ios/ios-arm64/MauiApp4.app: cannot find code object on disk 1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.122\tools\msbuild\iOS\Xamarin.Shared.targets(2095,3): error : /usr/bin/codesign exited with code 1 1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.122\tools\msbuild\iOS\Xamarin.Shared.targets(2095,3): error : 1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.122\tools\msbuild\iOS\Xamarin.Shared.targets(2095,3): error : Failed to codesign '/Users/jamiemoore/Library/Caches/Xamarin/mtbs/builds/MauiApp4/0f1e4cdf14fa622132609c9ce8057ee583cdfb360497bc97f4c41ba596d325de/bin/Release/net6.0-ios/ios-arm64/MauiApp4.app': /Users/jamiemoore/Library/Caches/Xamarin/mtbs/builds/MauiApp4/0f1e4cdf14fa622132609c9ce8057ee583cdfb360497bc97f4c41ba596d325de/bin/Release/net6.0-ios/ios-arm64/MauiApp4.app: cannot find code object on disk 1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.122\tools\msbuild\iOS\Xamarin.Shared.targets(2095,3): error : 1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.122\tools\msbuild\iOS\Xamarin.Shared.targets(2095,3): error : 1> Codesign: 2022-04-07T16:05:08.4528915+01:00 - Finished 1> Done executing task "Codesign" -- FAILED. 1> Done building target "_CodesignAppBundle" in project "MauiApp4.csproj" -- FAILED. 1> 1> Done building project "MauiApp4.csproj" -- FAILED. 1> Done executing task "MSBuild" -- FAILED. 1>Done building target "DispatchToInnerBuilds" in project "MauiApp4.csproj" -- FAILED.

@rolfbjarne
Copy link
Member

I believe @ElementalLogic's comment is the same one as reported here: #5901 (and in any case not the same underlying issue as the one reported here).

And since I think this issue is fixed in the latest version, I'm closing this.

@ghost ghost locked as resolved and limited conversation to collaborators May 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) platform/iOS 🍎 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants