Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions samples/unity-of-bugs/Assets/Editor/XcodeProjectUpdater.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#if UNITY_IOS && !UNITY_2021_1_OR_NEWER
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;

namespace Editor
{
/// <summary>
/// Unity adds the '-mno-thumb' compiler flag by default to iOS builds, but this flag is outdated
/// and no longer supported by modern versions of Xcode. Leaving this flag in the project will cause
/// Xcode builds to fail with an "unsupported option '-mno-thumb' for target" error. This post-process
/// build step removes the flag to ensure the sample works on all versions of Unity.
/// </summary>
public static class XcodeProjectUpdater
{
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget target, string pathToBuildProject)
{
if (target != BuildTarget.iOS)
{
return;
}

Debug.Log("XcodeUpdater.OnPostProcessBuild started.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logger doesn't let us opt out or set level right? are we not using our logger here why?

Copy link
Contributor Author

@bitsandfoxes bitsandfoxes Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a script that lives outside the SDK and is not part of the shipped package.
It's is purely there to help us run builds locally, when targeting iOS on old Unity versions.


var pbxProjectPath = PBXProject.GetPBXProjectPath(pathToBuildProject);
var project = new PBXProject();
project.ReadFromFile(pbxProjectPath);

var targetGuid = project.GetUnityMainTargetGuid();

Debug.Log("Removing '-mno-thumb' from 'OTHER_CFLAGS'.");
project.UpdateBuildProperty(targetGuid, "OTHER_CFLAGS", null, new[] { "-mno-thumb" });

project.WriteToFile(pbxProjectPath);

Debug.Log("XcodeUpdater.OnPostProcessBuild finished.");
}
}
}
#endif
11 changes: 11 additions & 0 deletions samples/unity-of-bugs/Assets/Editor/XcodeProjectUpdater.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion scripts/pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Copy-Item "LICENSE.md" -Destination "package-release/LICENSE.md"

# Copy samples
Copy-Item "samples/unity-of-bugs/Assets/Scenes*" -Destination "package-release/Samples~/unity-of-bugs/" -Recurse
Copy-Item "samples/unity-of-bugs/Assets/Editor*" -Destination "package-release/Samples~/unity-of-bugs/" -Recurse
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had nothing there in the first place.

Copy-Item "samples/unity-of-bugs/Assets/Scripts*" -Destination "package-release/Samples~/unity-of-bugs/" -Recurse

# Create zip
Expand Down
Loading