Enable codesigning by default in the simulator · Issue #18469 · dotnet/macios (original) (raw)

It seems the simulator won't load launch screens unless the app is signed.

Ref: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1834468

Since most apps have launch screens, it might make sense to enable code signing in the simulator by default.

Note: we should look into what Xcode does if you don't have a Developer Account.

However, some additional testing might be required, because simply setting EnableCodeSigning=true doesn't work as expected:

$ dotnet build /p:EnableCodeSigning=true [...] error : The "Codesign" task was not given a value for the required parameter "SigningKey", nor was there a "CodesignSigningKey" metadata on the resource [...]

OK, let's try giving the build a code signing key:

$ dotnet build /p:EnableCodeSigning=true /p:CodesignKey='Apple Development: Rolf Kvinge (CZ9YXM2X9A)' [...] error : The "Codesign" task was not given a value for the required parameter "SigningKey", nor was there a "CodesignSigningKey" metadata on the resource [...]

No change!

what gets us passed that error is actually setting CodesignRequireProvisioningProfile=true, although it runs into another one:

$ dotnet build /p:EnableCodeSigning=true /p:CodesignRequireProvisioningProfile=true [...] _CodesignVerify: /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/iPhoneSimulator/Debug/TestLaunchScreen.iOS.app bin/iPhoneSimulator/Debug/TestLaunchScreen.iOS.app: valid on disk bin/iPhoneSimulator/Debug/TestLaunchScreen.iOS.app: satisfies its Designated Requirement test-requirement: code failed to satisfy specified code requirement(s) error MSB6006: "codesign" exited with code 3.

So what actually makes the app build successfully is passing DisableCodesignVerification=true as well:

$ dotnet build /p:EnableCodeSigning=true /p:CodesignRequireProvisioningProfile=true /p:DisableCodesignVerification=true [...]

From looking at the source code, this is what happens (don't take this as truth, it needs verification when implementing any fixes) for the simulator in the DetectSigningIdentity task:

Setting CodesignRequireProvisioningProfile=true got us passed these two issues, but there's a third:

TLDR;

Add the following to the csproj to work around this:

true true true

This should work on device as well: