UpdateBuildProperty() public method

public UpdateBuildProperty ( IEnumerable targetGuids, string name, IEnumerable addValues, IEnumerable removeValues ) : void
targetGuids IEnumerable
name string
addValues IEnumerable
removeValues IEnumerable
return void
示例#1
0
 //设置编译属性
 private static void SetBuildProperties(PBXProject proj, Hashtable table)
 {
     if (table != null)
     {
         string    target   = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
         Hashtable setTable = table.SGet <Hashtable>("=");
         foreach (DictionaryEntry i in setTable)
         {
             proj.SetBuildProperty(target, i.Key.ToString(), i.Value.ToString());
         }
         Hashtable addTable = table.SGet <Hashtable>("+");
         foreach (DictionaryEntry i in addTable)
         {
             ArrayList     array = i.Value as ArrayList;
             List <string> list  = new List <string>();
             foreach (var flag in array)
             {
                 list.Add(flag.ToString());
             }
             proj.UpdateBuildProperty(target, i.Key.ToString(), list, null);
         }
         Hashtable removeTable = table.SGet <Hashtable>("-");
         foreach (DictionaryEntry i in removeTable)
         {
             ArrayList     array = i.Value as ArrayList;
             List <string> list  = new List <string>();
             foreach (var flag in array)
             {
                 list.Add(flag.ToString());
             }
             proj.UpdateBuildProperty(target, i.Key.ToString(), null, list);
         }
     }
 }
示例#2
0
        public void DuplicateOptionHandlingWorks()
        {
            ResetGuidGenerator();
            PBXProject proj = ReadPBXProject("base_dup.pbxproj");

            string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName());

            proj.UpdateBuildProperty(target, "TEST_DUP", new string[] { "test2" }, new string[] { "test3" });
            proj.UpdateBuildProperty(target, "TEST_DUP2", null, new string[] { "test_key" }); // duplicate value removal

            TestOutput(proj, "dup1.pbxproj");
        }
 private static void EditXcodeProject(string buildFolder)
 {
     PBXProject project = new PBXProject();
     string path = Path.Combine(buildFolder, FileUtil.NiceWinPath("Unity-iPhone.xcodeproj/project.pbxproj"));
     project.ReadFromFile(path);
     string targetGuid = project.TargetGuidByName(PBXProject.GetUnityTargetName());
     if (AdvertisementSettings.enabled && AdvertisementSettings.IsPlatformEnabled(RuntimePlatform.IPhonePlayer))
     {
         string target = Path.Combine(buildFolder, Path.Combine("UnityAds", "UnityAds.framework"));
         FileUtil.CopyDirectoryRecursive(Path.Combine(extensionPath, FileUtil.NiceWinPath("Editor/Resources/iOS/builds/UnityAds.framework")), target, true);
         project.AddFileToBuild(targetGuid, project.AddFile(Path.Combine("UnityAds", "UnityAds.framework"), "Frameworks/UnityAds.framework", PBXSourceTree.Source));
         project.AddBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", "$(SRCROOT)/UnityAds");
         project.AddFrameworkToProject(targetGuid, "AdSupport.framework", true);
         project.AddFrameworkToProject(targetGuid, "StoreKit.framework", false);
         project.AddFrameworkToProject(targetGuid, "CoreTelephony.framework", false);
     }
     else
     {
         project.RemoveFile(project.FindFileGuidByRealPath(Path.Combine("UnityAds", "UnityAds.framework")));
         string[] removeValues = new string[] { "$(SRCROOT)/UnityAds" };
         project.UpdateBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", null, removeValues);
         string str5 = Path.Combine(buildFolder, "UnityAds");
         if (Directory.Exists(str5))
         {
             Directory.Delete(str5, true);
         }
     }
     project.AddFileToBuild(targetGuid, project.AddFile("UnityAdsConfig.h", "Classes/UnityAds/UnityAdsConfig.h"));
     project.WriteToFile(path);
 }
    private static void OnPostprocessBuild(BuildTarget buildTarget, string buildPath)
    {
        //iOS以外にビルドしている場合は更新処理を行わないように
        if (buildTarget != BuildTarget.iOS){
            return;
        }

        //Xcodeの設定データを読み込む
        XcodeProjectSetting setting = Resources.Load<XcodeProjectSetting>(SETTING_DATA_PATH);
        if(setting == null){
            Debug.Log ("Resources/" + SETTING_DATA_PATH + "がありません!");
            return;
        }

        //Xcodeプロジェクトの読み込み
        string pbxProjPath = PBXProject.GetPBXProjectPath(buildPath);
        PBXProject pbxProject = new PBXProject();
        pbxProject.ReadFromString(File.ReadAllText(pbxProjPath));

        //ターゲットのID取得
        string targetGuid = pbxProject.TargetGuidByName(PBXProject.GetUnityTargetName());

        //指定ディレクトリ内のファイルを全てコピーする
        if(!string.IsNullOrEmpty(setting.CopyDirectoryPath)){
            DirectoryProcessor.CopyAndAddBuildToXcode (pbxProject, targetGuid, setting.CopyDirectoryPath, buildPath, "");
        }

        //コンパイラフラグの設定
        foreach (XcodeProjectSetting.CompilerFlagsSet compilerFlagsSet in setting.CompilerFlagsSetList) {

            foreach (string targetPath in compilerFlagsSet.TargetPathList) {
                if(!pbxProject.ContainsFileByProjectPath(targetPath)){
                    Debug.Log (targetPath + "が無いのでコンパイラフラグが設定できませんでした");
                    continue;
                }

                string fileGuid        = pbxProject.FindFileGuidByProjectPath(targetPath);
                List<string> flagsList = pbxProject.GetCompileFlagsForFile(targetGuid, fileGuid);

                flagsList.Add(compilerFlagsSet.Flags);
                pbxProject.SetCompileFlagsForFile(targetGuid, fileGuid, flagsList);
            }

        }

        //システムのフレームワークを追加
        foreach (string framework in setting.FrameworkList) {
            pbxProject.AddFrameworkToProject(targetGuid, framework, false);
        }

        //Linker Flagの設定
        pbxProject.UpdateBuildProperty(targetGuid, XcodeProjectSetting.LINKER_FLAG_KEY, setting.LinkerFlagArray, null);

        //フレームワークがあるディレクトリへのパス設定
        pbxProject.UpdateBuildProperty(targetGuid, XcodeProjectSetting.FRAMEWORK_SEARCH_PATHS_KEY, setting.FrameworkSearchPathArray, null);

        //BitCodeの設定
        pbxProject.SetBuildProperty(targetGuid, XcodeProjectSetting.ENABLE_BITCODE_KEY, setting.EnableBitCode ? "YES" : "NO");

        //プロジェクトファイル書き出し
        File.WriteAllText(pbxProjPath, pbxProject.WriteToString());

        //URLスキームの設定
        List<string> urlSchemeList = new List<string>(setting.URLSchemeList);
        InfoPlistProcessor.SetURLSchemes (buildPath, setting.URLIdentifier, urlSchemeList);

        //デフォルトで設定されているスプラッシュ画像の設定を消す
        if(setting.NeedToDeleteLaunchiImagesKey){
            InfoPlistProcessor.DeleteLaunchiImagesKey (buildPath);
        }

        //ATSの設定
        InfoPlistProcessor.SetATS (buildPath, setting.EnableATS);

        //ステータスバーの設定
        InfoPlistProcessor.SetStatusBar (buildPath, setting.EnableStatusBar);
    }