Esempio n. 1
0
        public static void OnCocoaPodsReady(BuildTarget buildTarget, string buildPath)
        {
            if (buildTarget != BuildTarget.iOS)
            {
                return;
            }

            var editorSettings            = CASEditorSettings.Load();
            var needLocalizeUserTracking  = IsNeedLocalizeUserTrackingDescription(editorSettings);
            var needEmbedDynamicLibraries = IsNeedEmbedDynamicLibraries();

            if (!needEmbedDynamicLibraries && !needLocalizeUserTracking)
            {
                return;
            }

            var    project = OpenXCode(buildPath);
            string mainTargetGuid;
            string frameworkTargetGuid;

            GetTargetsGUID(project, out mainTargetGuid, out frameworkTargetGuid);
            if (needLocalizeUserTracking)
            {
                LocalizeUserTrackingDescription(buildPath, project, mainTargetGuid, editorSettings);
            }

            if (needEmbedDynamicLibraries)
            {
                var depManager = DependencyManager.Create(BuildTarget.iOS, Audience.Mixed, true);
                EmbedDynamicLibrariesIfNeeded(buildPath, project, mainTargetGuid, depManager);
            }

            SaveXCode(project, buildPath);
        }
Esempio n. 2
0
        [PostProcessBuild(47)]  //must be between 40 and 50 to ensure that it's not overriden by Podfile generation (40) and that it's added before "pod install" (50)
        public static void MainPostprocess(BuildTarget target, string buildPath)
        {
            if (target != BuildTarget.iOS)
            {
                return;
            }

            // Init Settings can be null
            var initSettings   = CASEditorUtils.GetSettingsAsset(BuildTarget.iOS, false);
            var editorSettings = CASEditorSettings.Load();
            var depManager     = DependencyManager.Create(BuildTarget.iOS, Audience.Mixed, true);

            string        plistPath = Path.Combine(buildPath, "Info.plist");
            PlistDocument plist     = new PlistDocument();

            plist.ReadFromFile(plistPath);

            UpdateGADDelayMeasurement(plist, editorSettings);
            UpdateGADAppId(plist, initSettings, depManager);
            UpdateSKAdNetworksInfo(plist);
            UpdateLSApplicationQueriesSchames(plist);
            UpdateAppTransportSecuritySettings(plist);
            SetAttributionReportEndpoint(plist, editorSettings);
            SetDefaultUserTrackingDescription(plist, editorSettings);

            File.WriteAllText(plistPath, plist.WriteToString());

            var    project = OpenXCode(buildPath);
            string mainTargetGuid;
            string frameworkTargetGuid;

            GetTargetsGUID(project, out mainTargetGuid, out frameworkTargetGuid);

            EnableSwiftLibraries(buildPath, project, mainTargetGuid, frameworkTargetGuid);
            CopyRawSettingsFile(buildPath, project, mainTargetGuid, initSettings);
            SetExecutablePath(buildPath, project, mainTargetGuid, depManager);

            SaveXCode(project, buildPath);

            if (editorSettings.generateIOSDeepLinksForPromo)
            {
                ApplyCrosspromoDynamicLinks(buildPath, mainTargetGuid, initSettings, depManager);
            }

#if UNITY_2019_3_OR_NEWER
            UpdatePodfileForUnity2019(buildPath);
#endif
            Debug.Log(CASEditorUtils.logTag + "Postrocess Build done.");
        }
Esempio n. 3
0
        private void OnEnable()
        {
            SetSettingsPlatform();

            InitMainProperties(serializedObject);
            InitEditorSettingsProperties();

            allowedPackageUpdate = Utils.IsPackageExist(Utils.packageName);

            dependencyManager = DependencyManager.Create(platform, ( Audience )audienceTaggedProp.enumValueIndex, true);

            HandleDeprecatedComponents();
            InitEDM4U();
            InitEnvironmentDetails();

            EditorApplication.delayCall += () =>
            {
                newCASVersion = Utils.GetNewVersionOrNull(Utils.gitUnityRepo, MobileAds.wrapperVersion, false);
            };
        }
        public static void ConfigureProject(BuildTarget target, CASEditorSettings editorSettings)
        {
            if (target != BuildTarget.Android && target != BuildTarget.iOS)
            {
                return;
            }

            var settings = Utils.GetSettingsAsset(target, false);

            if (!settings)
            {
                Utils.StopBuildWithMessage("Settings asset not found. Please use menu Assets > CleverAdsSolutions > Settings " +
                                           "to create and set settings for build.", target);
            }

            var deps = DependencyManager.Create(target, Audience.Mixed, true);

            if (!Application.isBatchMode)
            {
                var newCASVersion = Utils.GetNewVersionOrNull(Utils.gitUnityRepo, MobileAds.wrapperVersion, false);
                if (newCASVersion != null)
                {
                    Utils.DialogOrCancelBuild("There is a new version " + newCASVersion + " of the CAS Unity available for update.", target);
                }

                if (deps != null)
                {
                    if (!deps.installedAny)
                    {
                        Utils.StopBuildWithMessage("Dependencies of native SDK were not found. " +
                                                   "Please use 'Assets > CleverAdsSolutions > Settings' menu to integrate solutions or any SDK separately.", target);
                    }

                    if (deps.IsNewerVersionFound())
                    {
                        Utils.DialogOrCancelBuild("There is a new versions of the native dependencies available for update." +
                                                  "Please use 'Assets > CleverAdsSolutions >Settings' menu to update.", target);
                    }
                }
            }

            if (settings.managersCount == 0 || string.IsNullOrEmpty(settings.GetManagerId(0)))
            {
                StopBuildIDNotFound(target);
            }

            string admobAppId = UpdateRemoteSettingsAndGetAppId(settings, target, deps);

            if (target == BuildTarget.Android)
            {
                ConfigureAndroid(settings, editorSettings, admobAppId);
            }
            else if (target == BuildTarget.iOS)
            {
                ConfigureIOS();
            }

#pragma warning disable CS0618 // Type or member is obsolete
            // Use directrly property to avoid Debug build
            if (settings.testAdMode && !EditorUserBuildSettings.development)
            {
                Debug.LogWarning(Utils.logTag + "Test Ads Mode enabled! Make sure the build is for testing purposes only!\n" +
                                 "Use 'Assets > CleverAdsSolutions > Settings' menu to disable Test Ad Mode.");
            }
            else
            {
                Debug.Log(Utils.logTag + "Project configuration completed");
            }
#pragma warning restore CS0618 // Type or member is obsolete
        }