Unity XUPorter overwriteBuildSetting相关的坑



1.overwriteBuildSetting里的参数不是xcode里面带空格的名称,需要在文档里选


这个问题之前弄了半天,才弄明白。不得不吐槽, XUPorter 东西是好东西,但是作者文档写得有点不友好。用起来得自己摸索很多东西。string参数对应xcode里面的build setting,参考的文档如下:

Xcode Build Settings Reference:
https://pewpewthespells.com/blog/buildsettings.html#gcc_generate_debugging_symbols

https://developer.apple.com/legacy/library/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW48

一句调用示例:
project.overwriteBuildSetting("DEPLOYMENT_POSTPROCESSING", "YES");



2.overwriteBuildSetting函数不起作用

实测,目前被XUPorter的overwriteBuildSetting函数根本不起作用overwriteBuildSetting,xcode下打断点发现根本不能调用到内层循环的。
  buildConfig.Value.overwriteBuildSetting(settingName, newValue);这句代码。所以经过如下修改,就可以了。贴上我修改后的函数:
public bool overwriteBuildSetting( string settingName, string newValue, string buildConfigName = "all") {
			Debug.Log("overwriteBuildSetting " + settingName + " " + newValue + " " + buildConfigName);
			foreach( KeyValuePair buildConfig in buildConfigurations )
            {
                //Debug.Log ("build config " + buildConfig);
                //xporter的坑,要加上这句overwriteBuildSetting才能生效
                buildConfig.Value.overwriteBuildSetting(settingName, newValue);
                XCBuildConfiguration b = buildConfig.Value;
				if ( (string)b.data["name"] == buildConfigName || (string)b.data["name"] == "all") {
					//Debug.Log ("found " + buildConfigName + " config");
					buildConfig.Value.overwriteBuildSetting(settingName, newValue);
					modified = true;
				} else {
					//Debug.LogWarning ("skipping " + buildConfigName + " config " + (string)b.data["name"]);
				}
			}
			return modified;
		}



这个问题坑了我一下午。。。哎。。。坑啊。。。


你可能感兴趣的:(【Unity】)