ソースコード
using UnityEditor; using UnityEditor.Callbacks; using UnityEditor.iOS.Xcode; namespace Kogane.Internal { /// <summary> /// Xcode 15 でビルドできるようにするエディタ拡張 /// Xcode の Build Settings の「Other Linker Flags」に「-ld_classic」を設定することでビルドできるようにする /// /// https://forum.unity.com/threads/project-wont-build-using-xode15-release-candidate.1491761/ /// /// https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes /// > Known Issues /// > Binaries using symbols with a weak definition crash at runtime on iOS 14/macOS 12 or older. /// > This impacts primarily C++ projects due to their extensive use of weak symbols. (114813650) (FB13097713) /// > /// > Workaround: Bump the minimum deployment target to iOS 15, macOS 12, watchOS 8 or tvOS 15, or add -Wl, /// > -ld_classic to the OTHER_LDFLAGS build setting. /// </summary> internal static class FixXcode15BuildOnPostProcessBuild { //================================================================================ // 関数(static) //================================================================================ /// <summary> /// ビルド完了時に呼び出されます /// </summary> [PostProcessBuild] private static void OnPostProcessBuild ( BuildTarget buildTarget, string pathToBuiltProject ) { if ( buildTarget != BuildTarget.iOS ) return; var projectPath = PBXProject.GetPBXProjectPath( pathToBuiltProject ); var project = new PBXProject(); project.ReadFromFile( projectPath ); var targetGuid = project.GetUnityMainTargetGuid(); project.AddBuildProperty( targetGuid, "OTHER_LDFLAGS", "-ld_classic" ); project.WriteToFile( projectPath ); } } }
補足
Binaries using symbols with a weak definition crash at runtime on iOS 14/macOS 12 or older. This impacts primarily C++ projects due to their extensive use of weak symbols. (114813650) (FB13097713)
Workaround: Bump the minimum deployment target to iOS 15, macOS 12, watchOS 8 or tvOS 15, or add -Wl,-ld_classic to the OTHER_LDFLAGS build setting.
Weak symbol imports are linked as non-weak imports, when used from LTO object files. (115521975) (FB13171424)
Workaround: Add -Wl,-weak_reference_mismatches,weak or -Wl,-ld_classic options to the OTHER_LDFLAGS build setting.
Xcode 15 の既知の問題の回避策として、
OTHER_LDFLAGS
に ld_classic
を追加するように紹介されている