public void ExplictStripOption_ThirdPartyLibrary_AndWarnsIfSo(bool?strip, bool shouldStrip) { MMPTests.RunMMPTest(tmpDir => { string originalLocation = Path.Combine(Configuration.SourceRoot, "tests", "test-libraries", "libtest-fat.macos.dylib"); string newLibraryLocation = Path.Combine(tmpDir, "libTest.dylib"); File.Copy(originalLocation, newLibraryLocation); TI.UnifiedTestConfig test = CreateStripTestConfig(strip, tmpDir, $" --native-reference=\"{newLibraryLocation}\""); test.Release = true; var testResult = TI.TestUnifiedExecutable(test); var bundleDylib = Path.Combine(test.BundlePath, "Contents", "MonoBundle", "libTest.dylib"); Assert.That(bundleDylib, Does.Exist, "libTest.dylib presence in app bundle"); var architectures = MachO.GetArchitectures(bundleDylib); if (shouldStrip) { Assert.AreEqual(1, architectures.Count, "libTest.dylib should only contain 1 architecture"); Assert.AreEqual(Abi.x86_64, architectures [0], "libTest.dylib should be x86_64"); testResult.Messages.AssertWarning(2108, "libTest.dylib was stripped of architectures except x86_64 to comply with App Store restrictions. This could break existing codesigning signatures. Consider stripping the library with lipo or disabling with --optimize=-trim-architectures"); } else { Assert.AreEqual(2, architectures.Count, "libTest.dylib should contain 2+ architectures"); Assert.That(architectures, Is.EquivalentTo(new Abi [] { Abi.i386, Abi.x86_64 }), "libTest.dylib should be x86_64 + i386"); testResult.Messages.AssertWarningCount(1); // dylib ([...]/xamarin-macios/tests/mmptest/bin/Debug/tmp-test-dir/Xamarin.MMP.Tests.MMPTests.RunMMPTest47/bin/Release/UnifiedExample.app/Contents/MonoBundle/libTest.dylib) was built for newer macOS version (10.11) than being linked (10.9) } }); }
void AssertStrip(string libPath, bool shouldStrip) { var archsFound = MachO.GetArchitectures(libPath); if (shouldStrip) { Assert.AreEqual(1, archsFound.Count, "Did not contain one archs"); Assert.True(archsFound.Contains(Abi.x86_64), "Did not contain x86_64"); } else { Assert.That(archsFound.Count, Is.GreaterThanOrEqualTo(2), "Did not contain two or more archs"); Assert.True(archsFound.Contains(Abi.i386) || archsFound.Contains(Abi.ARM64), "Did not contain i386 nor arm64"); Assert.True(archsFound.Contains(Abi.x86_64), "Did not contain x86_64"); } }
void AssertStrip(string libPath, bool shouldStrip) { var archsFound = MachO.GetArchitectures(libPath); if (shouldStrip) { Assert.AreEqual(1, archsFound.Count, "Did not contain one archs"); Assert.True(archsFound.Contains(Abi.x86_64), "Did not contain x86_64"); } else { Assert.AreEqual(2, archsFound.Count, "Did not contain two archs"); Assert.True(archsFound.Contains(Abi.i386), "Did not contain i386"); Assert.True(archsFound.Contains(Abi.x86_64), "Did not contain x86_64"); } }