Skip to content

Commit 23d062b

Browse files
committed
[msbuild] Sign simulator apps by default. Fixes dotnet#18469.
Fixes dotnet#18469.
1 parent 34f58bb commit 23d062b

File tree

3 files changed

+12
-66
lines changed

3 files changed

+12
-66
lines changed

msbuild/Xamarin.MacDev.Tasks/Tasks/DetectSigningIdentity.cs

+1-58
Original file line numberDiff line numberDiff line change
@@ -591,64 +591,7 @@ public override bool Execute ()
591591
return !Log.HasLoggedErrors;
592592
}
593593
} else {
594-
// Framework is either iOS, tvOS or watchOS
595-
if (SdkIsSimulator) {
596-
if (AppleSdkSettings.XcodeVersion.Major >= 8 && RequireProvisioningProfile) {
597-
// Note: Starting with Xcode 8.0, we need to codesign iOS Simulator builds that enable Entitlements
598-
// in order for them to run. The "-" key is a special value allowed by the codesign utility that
599-
// allows us to get away with not having an actual codesign key.
600-
DetectedCodeSigningKey = "-";
601-
602-
if (!IsAutoCodeSignProfile (ProvisioningProfile)) {
603-
identity.Profile = MobileProvisionIndex.GetMobileProvision (platform, ProvisioningProfile);
604-
605-
if (identity.Profile is null) {
606-
Log.LogError (MSBStrings.E0140, PlatformName, ProvisioningProfile);
607-
return false;
608-
}
609-
610-
identity.AppId = ConstructValidAppId (identity.Profile, identity.BundleId);
611-
if (identity.AppId is null) {
612-
Log.LogError (MSBStrings.E0141, identity.BundleId, ProvisioningProfile);
613-
return false;
614-
}
615-
616-
provisioningProfileName = identity.Profile.Name;
617-
618-
DetectedProvisioningProfile = identity.Profile.Uuid;
619-
DetectedDistributionType = identity.Profile.DistributionType.ToString ();
620-
} else {
621-
certs = new X509Certificate2 [0];
622-
623-
if ((profiles = GetProvisioningProfiles (platform, type, identity, certs)) is null)
624-
return false;
625-
626-
if ((pairs = GetCodeSignIdentityPairs (profiles, certs)) is null)
627-
return false;
628-
629-
var match = GetBestMatch (pairs, identity);
630-
identity.Profile = match.Profile;
631-
identity.AppId = match.AppId;
632-
633-
if (identity.Profile is not null) {
634-
DetectedDistributionType = identity.Profile.DistributionType.ToString ();
635-
DetectedProvisioningProfile = identity.Profile.Uuid;
636-
provisioningProfileName = identity.Profile.Name;
637-
}
638-
639-
DetectedAppId = identity.AppId;
640-
}
641-
} else {
642-
// Note: Do not codesign. Codesigning seems to break the iOS Simulator in older versions of Xcode.
643-
DetectedCodeSigningKey = null;
644-
}
645-
646-
ReportDetectedCodesignInfo ();
647-
648-
return !Log.HasLoggedErrors;
649-
}
650-
651-
if (!SdkIsSimulator && !RequireCodeSigning) {
594+
if (SdkIsSimulator || !RequireCodeSigning) {
652595
// The "-" key is a special value allowed by the codesign utility that
653596
// allows us to get away with not having an actual codesign key.
654597
DetectedCodeSigningKey = "-";

msbuild/Xamarin.Shared/Xamarin.Shared.props

+3-5
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,12 @@ Copyright (C) 2020 Microsoft. All rights reserved.
143143
</PropertyGroup>
144144

145145
<!-- RequireCodeSigning -->
146-
<!-- iOS/watchOS/tvOS is simple: device builds require code signing, simulator builds do not. This is a big lie, for some simulator builds need to be signed, but the _DetectCodeSigning task handles those cases. -->
146+
<!-- iOS/watchOS/tvOS is simple: device builds require code signing, simulator builds technically don't even though some important features won't work unless the app is signed (launch screen won't show for instance) -->
147147
<PropertyGroup Condition="'$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst'">
148148
<!-- Make it possible to override the default logic by setting EnableCodeSigning -->
149149
<_RequireCodeSigning Condition="'$(_RequireCodeSigning)' == ''">$(EnableCodeSigning)</_RequireCodeSigning>
150-
<!-- Device builds must be signed -->
151-
<_RequireCodeSigning Condition="'$(_RequireCodeSigning)' == '' And '$(ComputedPlatform)' == 'iPhone'">true</_RequireCodeSigning>
152-
<!-- Otherwise code signing is disabled by default (simulator builds)-->
153-
<_RequireCodeSigning Condition="'$(_RequireCodeSigning)' == ''">false</_RequireCodeSigning>
150+
<!-- Device builds must be signed, and some features won't work in the simulator if the app isn't signed (launch screen for instance), so default to always sign -->
151+
<_RequireCodeSigning Condition="'$(_RequireCodeSigning)' == ''">true</_RequireCodeSigning>
154152
</PropertyGroup>
155153
<!-- macOS is a bit more complicated:
156154
* 'EnableCodeSigning' specifies whether the app is signed or not, and this defaults to false if it's not set.

msbuild/Xamarin.Shared/Xamarin.Shared.targets

+8-3
Original file line numberDiff line numberDiff line change
@@ -1831,9 +1831,14 @@ Copyright (C) 2018 Microsoft. All rights reserved.
18311831
</PropertyGroup>
18321832

18331833
<Target Name="_DetectSigningIdentity" Condition="'$(_CanOutputAppBundle)' == 'true'" DependsOnTargets="$(_DetectSigningIdentityDependsOn)">
1834+
<PropertyGroup>
1835+
<_CodesignEntitlements Condition="'$(_CodesignEntitlements)' == '' And '$(_SdkIsSimulator)' != 'true'">$(CodesignEntitlement)</_CodesignEntitlements>
1836+
<_CodesignProvision Condition="'$(_CodesignProvision)' == '' And '$(_SdkIsSimulator)' != 'true'">$(CodesignProvision)</_CodesignProvision>
1837+
<_SigningKey Condition="'$(_SigningKey)' == '' And '$(_SdkIsSimulator)' != 'true'">$(_SpecifiedCodesignKey)</_SigningKey>
1838+
</PropertyGroup>
18341839
<DetectSigningIdentity
18351840
SessionId="$(BuildSessionId)"
1836-
CodesignEntitlements="$(CodesignEntitlements)"
1841+
CodesignEntitlements="$(_CodesignEntitlements)"
18371842
CodesignRequireProvisioningProfile="$(CodesignRequireProvisioningProfile)"
18381843
Condition="'$(IsMacEnabled)' == 'true'"
18391844
AppBundleName="$(_AppBundleName)"
@@ -1843,8 +1848,8 @@ Copyright (C) 2018 Microsoft. All rights reserved.
18431848
RequireCodeSigning="$(_RequireCodeSigning)"
18441849
SdkIsSimulator="$(_SdkIsSimulator)"
18451850
SdkPlatform="$(_SdkPlatform)"
1846-
ProvisioningProfile="$(CodesignProvision)"
1847-
SigningKey="$(_SpecifiedCodesignKey)"
1851+
ProvisioningProfile="$(_CodesignProvision)"
1852+
SigningKey="$(_SigningKey)"
18481853
DetectedCodeSigningKey="$(_CodeSigningKey)"
18491854
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
18501855
>

0 commit comments

Comments
 (0)