diff --git a/src/mono/sample/iOS/Makefile b/src/mono/sample/iOS/Makefile
index 7d4a6c680fcc1..be7c2bcefe0aa 100644
--- a/src/mono/sample/iOS/Makefile
+++ b/src/mono/sample/iOS/Makefile
@@ -18,5 +18,21 @@ run: clean appbuilder
$(DOTNET) publish -c $(MONO_CONFIG) /p:TargetArchitecture=$(MONO_ARCH) \
/p:UseLLVM=$(USE_LLVM) /p:ForceAOT=$(AOT)
+run-sim: clean appbuilder
+ $(DOTNET) publish -c $(MONO_CONFIG) /p:TargetOS=iOSSimulator /p:TargetArchitecture=$(MONO_ARCH) \
+ /p:UseLLVM=$(USE_LLVM) /p:ForceAOT=$(AOT)
+
+run-catalyst:
+ $(DOTNET) publish -c $(MONO_CONFIG) /p:TargetOS=MacCatalyst /p:TargetArchitecture=$(MONO_ARCH) \
+ /p:UseLLVM=False /p:ForceAOT=False
+
+run-sim-interp: clean appbuilder
+ $(DOTNET) publish -c $(MONO_CONFIG) /p:TargetOS=iOSSimulator /p:TargetArchitecture=$(MONO_ARCH) \
+ /p:UseLLVM=$(USE_LLVM) /p:ForceAOT=$(AOT) /p:MonoForceInterpreter=true
+
+run-catalyst-interp:
+ $(DOTNET) publish -c $(MONO_CONFIG) /p:TargetOS=MacCatalyst /p:TargetArchitecture=$(MONO_ARCH) \
+ /p:UseLLVM=False /p:ForceAOT=False /p:MonoForceInterpreter=true
+
clean:
rm -rf bin
diff --git a/src/mono/sample/iOS/Program.csproj b/src/mono/sample/iOS/Program.csproj
index 56f3124b3865c..580d61cf70fb9 100644
--- a/src/mono/sample/iOS/Program.csproj
+++ b/src/mono/sample/iOS/Program.csproj
@@ -8,11 +8,19 @@
$(ArtifactsBinDir)microsoft.netcore.app.runtime.$(TargetOS.ToLower())-$(TargetArchitecture)\$(Configuration)\runtimes\$(TargetOS.ToLower())-$(TargetArchitecture)\
false
$(TargetOS.ToLower())-$(TargetArchitecture)
- true
- Link
$(DefineConstants);CI_TEST
+
+
+
+
+
+
+
+ -
+
+
@@ -35,7 +43,7 @@
$(MSBuildThisFileDirectory)$(PublishDir)\app
iPhone 11
True
- true
+ true
@@ -83,11 +91,16 @@
+
+
+
+
+
+
+
+
+%Entitlements%
+
+
diff --git a/src/tasks/AppleAppBuilder/Templates/runtime.m b/src/tasks/AppleAppBuilder/Templates/runtime.m
index ef8bdbd4dfce5..17c8be6ff0463 100644
--- a/src/tasks/AppleAppBuilder/Templates/runtime.m
+++ b/src/tasks/AppleAppBuilder/Templates/runtime.m
@@ -246,14 +246,14 @@
const char *appctx_keys [] = {
"RUNTIME_IDENTIFIER",
"APP_CONTEXT_BASE_DIRECTORY",
-#ifndef INVARIANT_GLOBALIZATION
+#if !defined(INVARIANT_GLOBALIZATION) && !TARGET_OS_MACCATALYST
"ICU_DAT_FILE_PATH"
#endif
};
const char *appctx_values [] = {
APPLE_RUNTIME_IDENTIFIER,
bundle,
-#ifndef INVARIANT_GLOBALIZATION
+#if !defined(INVARIANT_GLOBALIZATION) && !TARGET_OS_MACCATALYST
icu_dat_path
#endif
};
diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs
index dcba5f973e9c2..442eb539af38b 100644
--- a/src/tasks/AppleAppBuilder/Xcode.cs
+++ b/src/tasks/AppleAppBuilder/Xcode.cs
@@ -83,11 +83,24 @@ public string GenerateXCode(
}
}
+ var entitlements = new List>();
+
+ bool hardenedRuntime = false;
+ if (Target == TargetNames.MacCatalyst && !(forceInterpreter || forceAOT)) {
+ hardenedRuntime = true;
+
+ /* for mmmap MAP_JIT */
+ entitlements.Add (KeyValuePair.Create ("com.apple.security.cs.allow-jit", ""));
+ /* for loading unsigned dylibs like libicu from outside the bundle or libSystem.Native.dylib from inside */
+ entitlements.Add (KeyValuePair.Create ("com.apple.security.cs.disable-library-validation", ""));
+ }
+
string cmakeLists = Utils.GetEmbeddedResource("CMakeLists.txt.template")
.Replace("%ProjectName%", projectName)
.Replace("%AppResources%", string.Join(Environment.NewLine, resources.Select(r => " " + r)))
.Replace("%MainSource%", nativeMainSource)
- .Replace("%MonoInclude%", monoInclude);
+ .Replace("%MonoInclude%", monoInclude)
+ .Replace("%HardenedRuntime%", hardenedRuntime ? "TRUE" : "FALSE");
string[] dylibs = Directory.GetFiles(workspace, "*.dylib");
@@ -152,8 +165,23 @@ public string GenerateXCode(
.Replace("%BundleIdentifier%", projectName);
File.WriteAllText(Path.Combine(binDir, "Info.plist"), plist);
+
+ var needEntitlements = entitlements.Count != 0;
+ cmakeLists = cmakeLists.Replace("%HardenedRuntimeUseEntitlementsFile%",
+ needEntitlements ? "TRUE" : "FALSE");
+
File.WriteAllText(Path.Combine(binDir, "CMakeLists.txt"), cmakeLists);
+ if (needEntitlements) {
+ var ent = new StringBuilder();
+ foreach ((var key, var value) in entitlements) {
+ ent.AppendLine ($"{key}");
+ ent.AppendLine (value);
+ }
+ string entitlementsTemplate = Utils.GetEmbeddedResource("app.entitlements.template");
+ File.WriteAllText(Path.Combine(binDir, "app.entitlements"), entitlementsTemplate.Replace("%Entitlements%", ent.ToString()));
+ }
+
string targetName;
switch (Target)
{