Ejemplo n.º 1
0
        private static void CopyRawSettingsFile(string rootPath, PBXProject project, string target, CASInitSettings casSettings)
        {
            if (!casSettings)
            {
                return;
            }

            var resourcesBuildPhase = project.GetResourcesBuildPhaseByTarget(target);

            for (int i = 0; i < casSettings.managersCount; i++)
            {
                string managerId       = casSettings.GetManagerId(i);
                int    managerIdLength = managerId.Length;
                string suffixChar      = char.ToLower(managerId[managerIdLength - 1]).ToString();
                string fileName        = "cas_settings" + managerIdLength.ToString() + suffixChar + ".json";
                string pathInAssets    = CASEditorUtils.GetNativeSettingsPath(BuildTarget.iOS, managerId);
                if (File.Exists(pathInAssets))
                {
                    try
                    {
                        File.Copy(pathInAssets, Path.Combine(rootPath, fileName), true);
                        var fileGuid = project.AddFile(fileName, fileName, PBXSourceTree.Source);
                        project.AddFileToBuildSection(target, resourcesBuildPhase, fileGuid);
                    }
                    catch (Exception e)
                    {
                        Debug.LogWarning(CASEditorUtils.logTag + "Copy Raw File To XCode Project failed: " + e.ToString());
                    }
                }
                else
                {
                    Debug.Log(CASEditorUtils.logTag + "Not found Raw file: " + pathInAssets);
                }
            }
        }
Ejemplo n.º 2
0
        private static void UpdateGADAppId(PlistDocument plist, CASInitSettings initSettings, DependencyManager deps)
        {
            if (!initSettings)
            {
                return;
            }
            #region Read Admob App ID from CAS Settings
            bool admobAppIdRequired = deps == null;
            if (deps != null)
            {
                var admobDep = deps.Find(AdNetwork.GoogleAds);
                if (admobDep != null)
                {
                    admobAppIdRequired = admobDep.IsInstalled();
                }
            }

            string admobAppId = null;
            if (initSettings.managersCount > 0)
            {
                string settingsPath = CASEditorUtils.GetNativeSettingsPath(BuildTarget.iOS, initSettings.GetManagerId(0));
                if (File.Exists(settingsPath))
                {
                    try
                    {
                        admobAppId = CASEditorUtils.GetAdmobAppIdFromJson(File.ReadAllText(settingsPath));
                    }
                    catch (Exception e)
                    {
                        if (!initSettings.IsTestAdMode() && admobAppIdRequired)
                        {
                            CASEditorUtils.StopBuildWithMessage(e.ToString(), BuildTarget.iOS);
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(admobAppId) && initSettings.IsTestAdMode())
            {
                admobAppId = CASEditorUtils.iosAdmobSampleAppID;
            }

            #endregion

            if (!string.IsNullOrEmpty(admobAppId))
            {
                plist.root.SetString("GADApplicationIdentifier", admobAppId);
            }
        }