0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

xCode26でUnityビルドするときにエラー発生した際の対策

Posted at

ld: warning: -ld_classic is deprecated and will be removed in a future release

Assertion failed: (it != _dylibToOrdinal.end()), function dylibToOrdinal, file OutputFile.cpp

最近お仕事でUnityプロジェクトを2021から6.0にアップデートしました。しかしいざXcode26でビルドする際に、なぜか上記のエラーが出る。xcode16.4の際に出ないのに

調べたらXcodeビルド時に、UnityFrameWorkの-ld64フラグ消せば行けるらしいので、消したら本当に行けました。

とはいえ毎回手作業面倒くさい。いずれにUnityは対応するはずですが、今が面倒。なのでpostBuildProcessでなんとかしました。そのためのコードをメモして残しておく

            var frameworkTargetGuid = pbxProject.GetUnityFrameworkTargetGuid();
            string[] configNames = { "Debug", "Release", "ReleaseForProfiling", "ReleaseForRunning" }; 
            const string buildSetting = "OTHER_LDFLAGS";
            
            foreach (var configName in configNames)
            {
                // 設定のGUIDを取得
                var configGuid = pbxProject.BuildConfigByName(frameworkTargetGuid, configName);
                if (string.IsNullOrEmpty(configGuid))
                {
                    Debug.LogWarning($"設定 {configName} のGUIDが見つかりませんでした。スキップします。");
                    continue;
                }

                // 既存のフラグを取得
                var currentFlags = pbxProject.GetBuildPropertyForConfig(configGuid, buildSetting);

                // -ld64 が含まれていれば削除
                if (string.IsNullOrEmpty(currentFlags) || !currentFlags.Contains("-ld64")) continue;
                // フラグを削除し、複数のスペースを一つに、前後のスペースを削除
                var newFlags = currentFlags
                    .Replace("-ld64", " ")
                    .Replace("  ", " ") // 二重になったスペースを削除
                    .Trim();
                
                // 新しい設定を上書き
                pbxProject.SetBuildPropertyForConfig(configGuid, buildSetting, newFlags);
                Debug.Log($"[PostProcess] ターゲット: {configName} から -ld64 を削除しました。");
            }
            
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?