Skip to content

Commit

Permalink
[MMP][60534] MMP Should check that Deployment Target is not below min…
Browse files Browse the repository at this point in the history
… version (#3122)

Return a build error if Deployment Target is too low
Add an mmptest for the change
  • Loading branch information
Timothy Risi authored and spouliot committed Jan 4, 2018
1 parent ec74453 commit 6ff74c5
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 8 deletions.
12 changes: 12 additions & 0 deletions docs/website/mmp-errors.md
Expand Up @@ -66,6 +66,18 @@ The easiest way to get exact version information is to use the **Xamarin Studio*

This usually indicates a bug in Xamarin.Mac; please file a bug report at [https://bugzilla.xamarin.com](https://bugzilla.xamarin.com/enter_bug.cgi?product=Xamarin.Mac) with a test case.

### <a name="MM0073"/>MM0073: Xamarin.Mac * does not support a deployment target of * (the minimum is *). Please select a newer deployment target in your project's Info.plist.

The minimum deployment target is the one specified in the error message; please select a newer deployment target in the project's Info.plist.

If updating the deployment target is not possible, then please use an older version of Xamarin.Mac.

### <a name="MM0074"/>MM0074: Xamarin.Mac * does not support a deployment target of * (the maximum is *). Please select an older deployment target in your project's Info.plist or upgrade to a newer version of Xamarin.Mac.

Xamarin.Mac does not support setting the minimum deployment target to a higher version than the version this particular version of Xamarin.Mac was built for.

Please select an older minimum deployment target in the project's Info.plist, or upgrade to a newer version of Xamarin.Mac.

### <a name="MM0079">MM0079: Internal Error - No executable was copied into the app bundle. Please contact 'support@xamarin.com'

### <a name="MM0080">MM0080: Disabling NewRefCount, --new-refcount:false, is deprecated.
Expand Down
2 changes: 1 addition & 1 deletion docs/website/mtouch-errors.md
Expand Up @@ -308,7 +308,7 @@ The minimum deployment target is the one specified in the error message; please

If updating the deployment target is not possible, then please use an older version of Xamarin.iOS.

### <a name="MT0074"/>MT0074: Xamarin.iOS * does not support a minimum deployment target of * (the maximum is *). Please select an older deployment target in your project's Info.plist or upgrade to a newer version of Xamarin.iOS.
### <a name="MT0074"/>MT0074: Xamarin.iOS * does not support a deployment target of * (the maximum is *). Please select an older deployment target in your project's Info.plist or upgrade to a newer version of Xamarin.iOS.

Xamarin.iOS does not support setting the minimum deployment target to a higher version than the version this particular version of Xamarin.iOS was built for.

Expand Down
9 changes: 8 additions & 1 deletion tests/common/mac/ProjectTestHelpers.cs
Expand Up @@ -44,6 +44,7 @@ public class UnifiedTestConfig
public string ItemGroup { get; set; } = "";
public string SystemMonoVersion { get; set; } = "";
public string TargetFrameworkVersion { get; set; } = "";
public Dictionary<string, string> PlistReplaceStrings { get; set; } = new Dictionary<string, string>();

// Binding project specific
public string APIDefinitionConfig { get; set; }
Expand Down Expand Up @@ -174,7 +175,13 @@ public static string GenerateEXEProject (UnifiedTestConfig config)
WriteMainFile (config.TestDecl, config.TestCode, true, config.FSharp, Path.Combine (config.TmpDir, config.FSharp ? "Main.fs" : "Main.cs"));

string sourceDir = FindSourceDirectory ();
File.Copy (Path.Combine (sourceDir, "Info-Unified.plist"), Path.Combine (config.TmpDir, "Info.plist"), true);

CopyFileWithSubstitutions (Path.Combine (sourceDir, "Info-Unified.plist"), Path.Combine (config.TmpDir, "Info.plist"), text => {
foreach (var key in config.PlistReplaceStrings.Keys)
text = text.Replace (key, config.PlistReplaceStrings [key]);
return text;
});

return CopyFileWithSubstitutions (Path.Combine (sourceDir, config.ProjectName), Path.Combine (config.TmpDir, config.ProjectName), text =>
{
Expand Down
39 changes: 39 additions & 0 deletions tests/mmptest/src/MMPTest.cs
Expand Up @@ -774,5 +774,44 @@ public void OldXcodeTest ()
TI.TestUnifiedExecutable (test, shouldFail: false, configuration: "Debug", environment: new string [] { "MD_APPLE_SDK_ROOT", Path.GetDirectoryName (Path.GetDirectoryName (oldXcode)) });
});
}

[Test]
public void BuildUnified_BelowMinDeploymentTargetShouldFail ()
{
RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
PlistReplaceStrings = new Dictionary<string, string> {
{ "<string>10.7</string>", "<string>10.4</string>"}
}
};
TI.TestUnifiedExecutable (test, shouldFail: true);
});
}

[Test]
public void BuildUnified_AboveSDKDeploymentTargetShouldFail ()
{
RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
PlistReplaceStrings = new Dictionary<string, string> {
{ "<string>10.7</string>", "<string>11.0</string>"}
}
};
TI.TestUnifiedExecutable (test, shouldFail: true);
});
}

[Test]
public void BuildUnified_ValidSDKDeploymentTargetShouldWork ()
{
RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
PlistReplaceStrings = new Dictionary<string, string> {
{ "<string>10.7</string>", "<string>10.12</string>"}
}
};
TI.TestUnifiedExecutable (test, shouldFail: false);
});
}
}
}
7 changes: 7 additions & 0 deletions tools/common/Application.cs
Expand Up @@ -400,6 +400,13 @@ public void InitializeCommon ()
throw ErrorHelper.CreateError (91, "This version of {0} requires the {1} {2} SDK (shipped with Xcode {3}). Either upgrade Xcode to get the required header files or {4} (to try to avoid the new APIs).", ProductName, PlatformName, SdkVersions.GetVersion (Platform), SdkVersions.Xcode, Error91LinkerSuggestion);
}

if (DeploymentTarget != null) {
if (DeploymentTarget < Xamarin.SdkVersions.GetMinVersion (Platform))
throw new PlatformException (73, true, "{4} {0} does not support a deployment target of {1} for {3} (the minimum is {2}). Please select a newer deployment target in your project's Info.plist.", Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetMinVersion (Platform), PlatformName, ProductName);
if (DeploymentTarget > Xamarin.SdkVersions.GetVersion (Platform))
throw new PlatformException (74, true, "{4} {0} does not support a deployment target of {1} for {3} (the maximum is {2}). Please select an older deployment target in your project's Info.plist or upgrade to a newer version of {4}.", Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetVersion (Platform), PlatformName, ProductName);
}

if (Platform == ApplePlatform.WatchOS && EnableCoopGC.HasValue && !EnableCoopGC.Value)
throw ErrorHelper.CreateError (88, "The GC must be in cooperative mode for watchOS apps. Please remove the --coop:false argument to mtouch.");

Expand Down
7 changes: 1 addition & 6 deletions tools/mtouch/Application.cs
Expand Up @@ -1252,13 +1252,8 @@ void Initialize ()
DeploymentTarget = new Version (9, 0);
#endif

if (DeploymentTarget == null) {
if (DeploymentTarget == null)
DeploymentTarget = Xamarin.SdkVersions.GetVersion (Platform);
} else if (DeploymentTarget < Xamarin.SdkVersions.GetMinVersion (Platform)) {
throw new MonoTouchException (73, true, "Xamarin.iOS {0} does not support a deployment target of {1} for {3} (the minimum is {2}). Please select a newer deployment target in your project's Info.plist.", Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetMinVersion (Platform), PlatformName);
} else if (DeploymentTarget > Xamarin.SdkVersions.GetVersion (Platform)) {
throw new MonoTouchException (74, true, "Xamarin.iOS {0} does not support a deployment target of {1} for {3} (the maximum is {2}). Please select an older deployment target in your project's Info.plist or upgrade to a newer version of Xamarin.iOS.", Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetVersion (Platform), PlatformName);
}

if (Platform == ApplePlatform.iOS && (HasDynamicLibraries || HasFrameworks) && DeploymentTarget.Major < 8) {
ErrorHelper.Warning (78, "Incremental builds are enabled with a deployment target < 8.0 (currently {0}). This is not supported (the resulting application will not launch on iOS 9), so the deployment target will be set to 8.0.", DeploymentTarget);
Expand Down

0 comments on commit 6ff74c5

Please sign in to comment.