How to solve "codesign exited with code 1." finally?

I am developing a crossplatform app targetting both Android and iOS devices using Xamarin.Forms (4.1) with Visual Studio (2019) running on a Windows machine (10). Of course I have a Mac (Mac Mini) so that I am able to build binaries for iOS devices. Until recently, I was using a free provisioning profile, but switched to a paid Apple developer account when I started implementing Push Notifications.

When working on the iOS project, I face the above error several times a day.
You can imagine that this is very annoying.

This is is MSBuildTask running for CodeSigning:

<CodesignVerify
            SessionId="$(BuildSessionId)"
            Condition="'$(IsMacEnabled)' == 'true'"
            ToolExe="$(CodesignExe)"
            ToolPath="$(CodesignPath)"
            CodesignAllocate="$(_CodesignAllocate)"
            Resource="$(AppBundleDir)"
        >
        </CodesignVerify>

This is the binary that is executed on my Mac including its parameters:

/usr/bin/codesign --verify -vvvv -R='anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.1] exists and (certificate leaf[field.1.2.840.113635.100.6.1.2] exists or certificate leaf[field.1.2.840.113635.100.6.1.4] exists)' bin/iPhone/Debug/*********.iOS.app (TaskId:186)
1>

These are the messages logged on my Mac:

codesign: (libsystem_info.dylib) Membership API: translate identifier
codesign: (libsystem_info.dylib) Retrieve User by ID
codesign: (Security) SecTrustEvaluateIfNecessary
codesign: (Security) SecKeychainAddCallback
codesign: (Security) [com.apple.securityd:security_exception] MacOS error: -67054

This is what this error number (67054) translates to:

Error: 0XFFFEFA12 -67054 a sealed resource is missing or invalid

This is what I did so far:

  • When being asked the first time, I "always" allow keychain access
  • I manually allowed access to respective keys to all apps (which makes no sense, because due to the above action, codesign already has access)

When this error occurs, I usually need to

  • Clean the solution on my windows machine
  • Delete bin and obj folders
  • Remove respective certificates on my build machine (Mac)
  • Retrieve the certificates from my Apple developer account and reinstall them
  • Have Xcode recognize the certs and some times it seems as if I even need to remove my Apple Id from Xcode and add it again
  • Restart Visual Studio and reconnect to the Mac
  • Make sure the project options for the iOS app recognize the certificates within the bundle signing configuration
  • Try again

Most of the times, this works.
Some times, I am too annoyed to do all of the above steps (and more) and so I am trying to invest only the minimum amount of effort to get things working.
Some times this is enough and it works.
Most of the times it doesn't.
When it does not work, I get frustrated and either head over to work with the Android app or do the above steps (and more) after all.

I searched the internet. Of course I did. And there are so (!) many (!) people facing this problem and virtually NO one has a real explanation about what's EXACTLY going on here. Every workaround and/or solution I could find has something to do with deleting certificates and reinstalling them.

However, why can it be that it works now and then I change a line of code, hit run and suddenly I get another codesigning error?

This is like the middleage when women with red hair danced naked around a fireplace and threw stuff like frogeyes, dead animals and mouldy bread into a big bowl and to everyones' surprise, the resulting soup magically healed funny diseases. This is exactly what developers do when the try to get codesigning errors solved while working with Xamarin Forms.

I want you to find out that its the breads' mold which actually cures the people. Go and find the penicillin.

Please.

Tagged:

Answers

  • ColeXColeX Member, Xamarin Team Xamurai
    edited July 12

    Hi ,Mephisztoe ,consider opening a ticket for better support.

Sign In or Register to comment.