[iOS] Add Macatalyst support for library mode (#90237)
authorSteve Pfister <steveisok@users.noreply.github.com>
Thu, 10 Aug 2023 00:27:57 +0000 (17:27 -0700)
committerGitHub <noreply@github.com>
Thu, 10 Aug 2023 00:27:57 +0000 (20:27 -0400)
This change allows you to target maccatalyst for building full, self-contained libraries.

src/libraries/tests.proj
src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template
src/tasks/MobileBuildTasks/Apple/AppleProject.cs
src/tasks/MobileBuildTasks/Apple/AppleSdk.cs

index edce0ba..385af58 100644 (file)
 
   <ItemGroup Condition="'$(TargetOS)' == 'maccatalyst'">
     <ProjectExclusions Include="$(RepoRoot)/src/tests/FunctionalTests/iOS/Simulator/XmlFormatWriterGeneratorAOT/iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj" />
+    <ProjectExclusions Include="$(RepoRoot)/src/tests/FunctionalTests/iOS/Simulator/LibraryMode/iOS.Simulator.LibraryMode.Test.csproj" />
   </ItemGroup>
 
   <!-- Run only explicitly selected tests for Mac Catalyst in App Sandbox -->
index 299bef9..4ac9ad7 100644 (file)
@@ -27,10 +27,6 @@ if(NOT %UseNativeAOTRuntime%)
     include_directories("%MonoInclude%")
 endif()
 
-#set_target_properties(%ProjectName% %AotTargetsList% PROPERTIES
-#    XCODE_ATTRIBUTE_SUPPORTS_MACCATALYST "YES"
-#)
-
 set_target_properties(%ProjectName% PROPERTIES
     MACOSX_BUNDLE TRUE
     MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
@@ -39,6 +35,7 @@ set_target_properties(%ProjectName% PROPERTIES
     XCODE_EMIT_EFFECTIVE_PLATFORM_NAME "YES"
     XCODE_EMBED_FRAMEWORKS "%DYLIB_PATH%"
     XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks"
+    XCODE_ATTRIBUTE_SUPPORTS_MACCATALYST "YES"
     RESOURCE "${APP_RESOURCES}"
 )
 
index 4ddea07..f7927fa 100644 (file)
@@ -13,7 +13,7 @@ namespace Microsoft.Apple.Build
 {
     public sealed class AppleProject
     {
-        private const string DefaultMinOSVersion = "11.0";
+        private string defaultMinOSVersion;
 
         private TaskLoggingHelper logger;
 
@@ -26,6 +26,8 @@ namespace Microsoft.Apple.Build
         public AppleProject(string projectName, string runtimeIdentifier, TaskLoggingHelper logger)
         {
             GetTargets(runtimeIdentifier, out targetOS, out targetArchitecture);
+
+            defaultMinOSVersion = (targetOS == "maccatalyst") ? "13.1" : "11.0";
             targetAbi = DetermineAbi(targetArchitecture);
 
             AppleSdk sdk = new AppleSdk(targetOS, logger);
@@ -44,7 +46,12 @@ namespace Microsoft.Apple.Build
             }
         }
 
-        public void Build(string workingDir, ClangBuildOptions buildOptions, bool stripDebugSymbols = false, string minOSVersion = DefaultMinOSVersion)
+        public void Build(string workingDir, ClangBuildOptions buildOptions, bool stripDebugSymbols = false)
+        {
+            Build(workingDir, buildOptions, defaultMinOSVersion, stripDebugSymbols);
+        }
+
+        public void Build(string workingDir, ClangBuildOptions buildOptions, string minOSVersion, bool stripDebugSymbols = false)
         {
             string clangArgs = BuildClangArgs(buildOptions, minOSVersion);
             Utils.RunProcess(logger, "xcrun", workingDir: workingDir, args: clangArgs);
index 203ff8f..29b9b98 100644 (file)
@@ -135,6 +135,7 @@ namespace Microsoft.Apple.Build
                 "iphonesimulator" => "iPhoneSimulator",
                 "tvos" => "AppleTVOS",
                 "tvos-simulator" => "AppleTVSimulator",
+                "maccatalyst" => "MacOSX",
                 _ => throw new ArgumentException($"{targetOS} does not have a valid platform name")
             };
     }