diff --git a/.gitignore b/.gitignore index 48753c95a..603f6d435 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ Source/*.csproj *.lastbuilddate *.opendb *.DS_Store +*.xcodeproj # NUNIT *.VisualState.xml diff --git a/Source/Tools/Flax.Build/Projects/XCodeProjectGenerator.cs b/Source/Tools/Flax.Build/Projects/XCodeProjectGenerator.cs index 05b8facc2..a5bcfcf3f 100644 --- a/Source/Tools/Flax.Build/Projects/XCodeProjectGenerator.cs +++ b/Source/Tools/Flax.Build/Projects/XCodeProjectGenerator.cs @@ -24,7 +24,7 @@ namespace Flax.Build.Projects } /// - public override string ProjectFileExtension => "pbxproj"; + public override string ProjectFileExtension => string.Empty; /// public override string SolutionFileExtension => "xcodeproj"; @@ -44,39 +44,117 @@ namespace Flax.Build.Projects /// public override void GenerateProject(Project project) { - Console.WriteLine(project.Path); - var contents = new StringBuilder(); - - contents.AppendLine("// !$*UTF8*$!"); - contents.AppendLine("{"); - contents.AppendLine("\tarchiveVersion = 1;"); - contents.AppendLine("\tclasses = {"); - contents.AppendLine("\t};"); - contents.AppendLine("\tobjectVersion = 46;"); - contents.AppendLine("\tobjects = {"); - - contents.AppendLine("\t};"); - contents.AppendLine("\trootObject = " + GetRandomGuid() + " /* Project object */;"); - contents.AppendLine("}"); - - Utilities.WriteFileIfChanged(Path.Combine(project.Path), contents.ToString()); } /// public override void GenerateSolution(Solution solution) { + // TOOD: use random IDs for project and configurations + var groupId = "04FD6344277A0F15000EA5CA"; + var projectId = "04FD6345277A0F15000EA5CA"; + var projectName = solution.Name; + var projectWorkspacePath = Path.Combine(solution.Path, projectName + ".xcworkspace"); + + // Generate folders Directory.CreateDirectory(solution.Path); + Directory.CreateDirectory(projectWorkspacePath); - var contents = new StringBuilder(); - - contents.AppendLine(""); - contents.AppendLine(""); - foreach (var project in solution.Projects) + // Generate XCode project { - } - contents.AppendLine(""); + var contents = new StringBuilder(); - Utilities.WriteFileIfChanged(Path.Combine(solution.Path, solution.Name + ".xcworkspace", "contents.xcworkspacedata"), contents.ToString()); + contents.AppendLine("// !$*UTF8*$!"); + contents.AppendLine("{"); + contents.AppendLine("\tarchiveVersion = 1;"); + contents.AppendLine("\tclasses = {"); + contents.AppendLine("\t};"); + contents.AppendLine("\tobjectVersion = 55;"); + contents.AppendLine("\tobjects = {"); + + contents.AppendLine(""); + contents.AppendLine("/* Begin PBXGroup section */"); + contents.AppendLine("\t\t" + groupId + " = {"); + contents.AppendLine("\t\t\tisa = PBXGroup;"); + contents.AppendLine("\t\t\tchildren = ("); + contents.AppendLine("\t\t\t);"); + contents.AppendLine("\t\t\tsourceTree = \"\";"); + contents.AppendLine("\t\t};"); + contents.AppendLine("/* End PBXGroup section */"); + + contents.AppendLine(""); + contents.AppendLine("/* Begin PBXProject section */"); + contents.AppendLine("\t\t" + projectId + " /* Project object */ = {"); + contents.AppendLine("\t\t\tisa = PBXProject;"); + contents.AppendLine("\t\t\tattributes = {"); + contents.AppendLine("\t\t\t\tBuildIndependentTargetsInParallel = 1;"); + contents.AppendLine("\t\t\t\tLastUpgradeCheck = 1320;"); + contents.AppendLine("\t\t\t};"); + contents.AppendLine("\t\t\tbuildConfigurationList = 04FD6348277A0F15000EA5CA /* Build configuration list for PBXProject \"" + projectName + "\" */;"); + contents.AppendLine("\t\t\tcompatibilityVersion = \"Xcode 13.0\";"); + contents.AppendLine("\t\t\tdevelopmentRegion = en;"); + contents.AppendLine("\t\t\thasScannedForEncodings = 0;"); + contents.AppendLine("\t\t\tknownRegions = ("); + contents.AppendLine("\t\t\t\ten,"); + contents.AppendLine("\t\t\t\tBase,"); + contents.AppendLine("\t\t\t);"); + contents.AppendLine("\t\t\tmainGroup = " + groupId+ ";"); + contents.AppendLine("\t\t\tprojectDirPath = \"\";"); + contents.AppendLine("\t\t\tprojectRoot = \"\";"); + contents.AppendLine("\t\t\ttargets = ("); + contents.AppendLine("\t\t\t);"); + contents.AppendLine("\t\t};"); + contents.AppendLine("/* End PBXProject section */"); + + contents.AppendLine(""); + contents.AppendLine("/* Begin XCBuildConfiguration section */"); + contents.AppendLine("\t\t04FD6349277A0F15000EA5CA /* Debug */ = {"); + contents.AppendLine("\t\t\tisa = XCBuildConfiguration;"); + contents.AppendLine("\t\t\tbuildSettings = {"); + contents.AppendLine("\t\t\t};"); + contents.AppendLine("\t\t\tname = Debug;"); + contents.AppendLine("\t\t};"); + contents.AppendLine("\t\t04FD634A277A0F15000EA5CA /* Release */ = {"); + contents.AppendLine("\t\t\tisa = XCBuildConfiguration;"); + contents.AppendLine("\t\t\tbuildSettings = {"); + contents.AppendLine("\t\t\t};"); + contents.AppendLine("\t\t\tname = Release;"); + contents.AppendLine("\t\t};"); + contents.AppendLine("/* End XCBuildConfiguration section */"); + + contents.AppendLine(""); + contents.AppendLine("/* Begin XCConfigurationList section */"); + contents.AppendLine("\t\t04FD6348277A0F15000EA5CA /* Build configuration list for PBXProject \"" + projectName + "\" */ = {"); + contents.AppendLine("\t\t\tisa = XCConfigurationList;"); + contents.AppendLine("\t\t\tbuildConfigurations = ("); + contents.AppendLine("\t\t\t\t04FD6349277A0F15000EA5CA /* Debug */,"); + contents.AppendLine("\t\t\t\t04FD634A277A0F15000EA5CA /* Release */,"); + contents.AppendLine("\t\t\t);"); + contents.AppendLine("\t\t\tdefaultConfigurationIsVisible = 0;"); + contents.AppendLine("\t\t\tdefaultConfigurationName = Release;"); + contents.AppendLine("\t\t};"); + contents.AppendLine("/* End XCConfigurationList section */"); + + contents.AppendLine("\t};"); + contents.AppendLine("\trootObject = " + projectId + " /* Project object */;"); + contents.AppendLine("}"); + + Utilities.WriteFileIfChanged(Path.Combine(solution.Path, "project.pbxproj"), contents.ToString()); + } + + // Generate XCode workspace data + { + var contents = new StringBuilder(); + + contents.AppendLine(""); + contents.AppendLine(""); + contents.AppendLine(" "); + contents.AppendLine(" "); + contents.AppendLine(""); + + Utilities.WriteFileIfChanged(Path.Combine(projectWorkspacePath, "contents.xcworkspacedata"), contents.ToString()); + } } private string GetRandomGuid()