Skip to content

Commit

Permalink
[msbuild] Add support for signing with the placeholder key. (#20823)
Browse files Browse the repository at this point in the history
Add support for signing with a placeholder key ("-") from the developer,
and then use this to sign the prebuilt HotRestart app this way.

The app will have to be signed anyway on the end user machine, so this
shouldn't have any real effect (I've tested it locally and Hot Restart
still works).

This simplifies our build (both locally and on bots), because we won't
need a certificate around to do the actual signing.
  • Loading branch information
rolfbjarne committed Jul 12, 2024
1 parent 219c74a commit cfff124
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
<_LinkMode>None</_LinkMode>
<UseInterpreter>true</UseInterpreter>
<MtouchExtraArgs>--registrar:dynamic</MtouchExtraArgs>
<!-- disable code signing unless we're building in CI, to avoid requiring code signing during developer builds (who will usually never need the prebuilt app) -->
<EnableCodeSigning Condition="'$(BUILD_REVISION)' == ''">false</EnableCodeSigning>
<!-- Use a placeholder signing key, which simplifies our build (no need for an actual certificate). -->
<!-- The app will have to be signed on the end user machine anyway, so this shouldn't have any real effect. -->
<CodesignKey>-</CodesignKey>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.iOS.HotRestart.Application" Version="1.1.5" />
Expand Down
9 changes: 8 additions & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/DetectSigningIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static string ConstructValidAppId (string appid, string allowed, out int matchLe
void ReportDetectedCodesignInfo ()
{
Log.LogMessage (MessageImportance.High, MSBStrings.M0125);
if (codesignCommonName is not null)
if (codesignCommonName is not null || !string.IsNullOrEmpty (DetectedCodeSigningKey))
Log.LogMessage (MessageImportance.High, " Code Signing Key: \"{0}\" ({1})", codesignCommonName, DetectedCodeSigningKey);
if (provisioningProfileName is not null)
Log.LogMessage (MessageImportance.High, " Provisioning Profile: \"{0}\" ({1})", provisioningProfileName, DetectedProvisioningProfile);
Expand Down Expand Up @@ -573,6 +573,13 @@ public override bool Execute ()
identity.BundleId = BundleIdentifier;
DetectedAppId = BundleIdentifier; // default value that can be changed below

// If the developer chooses to use the placeholder codesigning key, accept that.
if (SigningKey == "-") {
DetectedCodeSigningKey = SigningKey;
ReportDetectedCodesignInfo ();
return !Log.HasLoggedErrors;
}

if (Platform == ApplePlatform.MacOSX) {
if (!RequireCodeSigning || !string.IsNullOrEmpty (DetectedCodeSigningKey)) {
ReportDetectedCodesignInfo ();
Expand Down

7 comments on commit cfff124

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.