コード例 #1
0
        public static void PrepareProject(string buildPath)
        {
            Debug.Log("preparing your xcode project for appodeal");
            var projectPath = PBXProject.GetPBXProjectPath(buildPath);
            var project     = new PBXProject();

            project.ReadFromString(File.ReadAllText(projectPath));

#if UNITY_2019_3_OR_NEWER
            var target = project.GetUnityMainTargetGuid();
#else
            var target = project.TargetGuidByName("Unity-iPhone");
#endif

            AddProjectFrameworks(frameworkList, project, target, false);
            AddProjectFrameworks(weakFrameworkList, project, target, true);
            AddProjectLibs(platformLibs, project, target);
            project.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

            var xcodeVersion = AppodealUnityUtils.getXcodeVersion();
            if (xcodeVersion == null ||
                AppodealUnityUtils.compareVersions(xcodeVersion, minVersionToEnableBitcode) >= 0)
            {
                project.SetBuildProperty(target, "ENABLE_BITCODE", "YES");
            }
            else
            {
                project.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
            }

            project.AddBuildProperty(target, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)/Libraries");
            project.AddBuildProperty(target, "LIBRARY_SEARCH_PATHS", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)");
#if UNITY_2019_3_OR_NEWER
            project.AddBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
#else
            project.AddBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
#endif
            project.AddBuildProperty(target, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");
            project.SetBuildProperty(target, "SWIFT_VERSION", "4.0");

            File.WriteAllText(projectPath, project.WriteToString());
        }
コード例 #2
0
 public static void PrepareBuild()
 {
     setSelectedArchitectures(AppodealUnityUtils.getAndroidArchitecture());
 }
コード例 #3
0
        private static void setSelectedArchitectures(AppodealUnityUtils.AndroidArchitecture arch)
        {
            if (arch == AppodealUnityUtils.AndroidArchitecture.invalid)
            {
                EditorUtility.DisplayDialog("Architecture problems were found in the project",
                                            "For some reason it isn't possible to define selected architectures. " +
                                            "Please check your settings. You also can check architectures manually",
                                            "Ok");
                return;
            }
            var selectedArches =
                new HashSet <AppodealUnityUtils.AndroidArchitecture>();

            foreach (AppodealUnityUtils.AndroidArchitecture a in Enum.GetValues(
                         typeof(AppodealUnityUtils.AndroidArchitecture)))
            {
                if ((arch & a) > 0)
                {
                    selectedArches.Add(a);
                }
            }

            var androidNativeDir   = AppodealUnityUtils.combinePaths(Application.dataPath, "Plugins", "Android");
            var nativeLibs         = Directory.GetDirectories(androidNativeDir);
            var needToUpdateAssets = false;
            var dialogWasShown     = false;

            foreach (var libPath in nativeLibs)
            {
                var
                         dir           = Path.GetFileName(libPath);
                var      archFullPaths =
                    new Dictionary <AppodealUnityUtils.AndroidArchitecture, string>();
                var archSafeFullPaths =
                    new Dictionary <AppodealUnityUtils.AndroidArchitecture, string>();
                var presentedArches =
                    new HashSet <AppodealUnityUtils.AndroidArchitecture>();
                var savedArches =
                    new HashSet <AppodealUnityUtils.AndroidArchitecture>();
                foreach (AppodealUnityUtils.AndroidArchitecture a in Enum.GetValues(
                             typeof(AppodealUnityUtils.AndroidArchitecture)))
                {
                    if (a == AppodealUnityUtils.AndroidArchitecture.invalid)
                    {
                        continue;
                    }
                    var fullPath = AppodealUnityUtils.combinePaths(androidNativeDir, dir, "libs", archDict[a]);
                    var safePath = AppodealUnityUtils.combinePaths(JNI_SAFE_PATH, dir);
                    archFullPaths.Add(a, fullPath);
                    archSafeFullPaths.Add(a, safePath);
                    if (Directory.Exists(fullPath))
                    {
                        presentedArches.Add(a);
                    }
                    if (Directory.Exists(AppodealUnityUtils.combinePaths(safePath, archDict[a])))
                    {
                        savedArches.Add(a);
                    }
                }

                if (presentedArches.Count == 0 && savedArches.Count == 0)
                {
                    continue;
                }

                foreach (AppodealUnityUtils.AndroidArchitecture a in Enum.GetValues(
                             typeof(AppodealUnityUtils.AndroidArchitecture)))
                {
                    if (a == AppodealUnityUtils.AndroidArchitecture.invalid)
                    {
                        continue;
                    }
                    if (selectedArches.Contains(a) == presentedArches.Contains(a))
                    {
                        continue;
                    }
                    if (presentedArches.Contains(a))
                    {
                        if (!Directory.Exists(archSafeFullPaths[a]))
                        {
                            Directory.CreateDirectory(archSafeFullPaths[a]);
                        }
                        Directory.Move(archFullPaths[a],
                                       AppodealUnityUtils.combinePaths(archSafeFullPaths[a], archDict[a]));
                        needToUpdateAssets = true;
                    }
                    else
                    {
                        if (savedArches.Contains(a))
                        {
                            Directory.Move(AppodealUnityUtils.combinePaths(archSafeFullPaths[a], archDict[a]),
                                           archFullPaths[a]);
                            needToUpdateAssets = true;
                        }
                        else
                        {
                            var message = "Plugin " + dir + " doesn't support the following architecture: " +
                                          archDict[a] +
                                          ". Building with this plugin can lead to crashes on devices with unsupported architectures.";
                            EditorUtility.DisplayDialog("Architecture problems were found in the project", message,
                                                        "Ok");
                            dialogWasShown = true;
                        }
                    }
                }
            }

            if (needToUpdateAssets)
            {
                AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            }
            if (!dialogWasShown)
            {
                EditorUtility.DisplayDialog("Appodeal Notification",
                                            "Filtering finished. All possible problems resolved.",
                                            "Ok");
            }
        }
コード例 #4
0
        public static void PrepareProject(string buildPath)
        {
            Debug.Log("preparing your xcode project for appodeal");
            var projPath = Path.Combine(buildPath, "Unity-iPhone.xcodeproj/project.pbxproj");

            absoluteProjPath = Path.GetFullPath(buildPath);
            var project = new PBXProject();

            project.ReadFromString(File.ReadAllText(projPath));
            var unityiPhone = project.TargetGuidByName("Unity-iPhone");

#if UNITY_2019_3
            var unityFramework = project.TargetGuidByName("UnityFramework");
            AddProjectFrameworks(frameworkList, project, unityFramework, false);
            AddProjectFrameworks(weakFrameworkList, project, unityFramework, true);
            AddProjectLibs(platformLibs, project, unityFramework);
            project.AddBuildProperty(unityFramework, "OTHER_LDFLAGS", "-ObjC");
            project.AddBuildProperty(unityFramework, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)/Libraries");
#endif

            AddProjectFrameworks(frameworkList, project, unityiPhone, false);
            AddProjectFrameworks(weakFrameworkList, project, unityiPhone, true);
            AddProjectLibs(platformLibs, project, unityiPhone);
            project.AddBuildProperty(unityiPhone, "OTHER_LDFLAGS", "-ObjC");

            //Major Xcode version version should be the same as that used by the native SDK developers.
            var xcodeVersion = AppodealUnityUtils.getXcodeVersion();
            if (xcodeVersion == null ||
                AppodealUnityUtils.compareVersions(xcodeVersion, minVersionToEnableBitcode) >= 0)
            {
                project.SetBuildProperty(unityiPhone, "ENABLE_BITCODE", "YES");
#if UNITY_2019_3
                project.SetBuildProperty(unityFramework, "ENABLE_BITCODE", "YES");
#endif
            }
            else
            {
                project.SetBuildProperty(unityiPhone, "ENABLE_BITCODE", "NO");
#if UNITY_2019_3
                project.SetBuildProperty(unityFramework, "ENABLE_BITCODE", "NO");
#endif
            }

            project.AddBuildProperty(unityiPhone, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)/Libraries");
            project.AddBuildProperty(unityiPhone, "LIBRARY_SEARCH_PATHS", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)");
            project.AddBuildProperty(unityiPhone, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
            project.AddBuildProperty(unityiPhone, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");
            project.SetBuildProperty(unityiPhone, "SWIFT_VERSION", "4.0");
#if UNITY_2019_3
            project.AddBuildProperty(unityFramework, "LIBRARY_SEARCH_PATHS", "$(SRCROOT)/Libraries");
            project.AddBuildProperty(unityFramework, "LIBRARY_SEARCH_PATHS", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)");
            project.AddBuildProperty(unityFramework, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
            project.AddBuildProperty(unityFramework, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");
            project.AddBuildProperty(unityFramework, "CLANG_ENABLE_MODULES", "YES");
            project.SetBuildProperty(unityFramework, "SWIFT_VERSION", "4.0");
#endif

            //Adapters are archived in order not to exceed the 100 Mb limit on GitHub
            //Some users use GitHub with Unity Cloud Build
            var apdFolder    = "Adapters";
            var appodealPath = Path.Combine(Application.dataPath, "Appodeal");
            var adaptersPath = Path.Combine(appodealPath, apdFolder);
            if (Directory.Exists(adaptersPath))
            {
                foreach (var file in Directory.GetFiles(adaptersPath))
                {
                    if (!Path.GetExtension(file).Equals(".zip"))
                    {
                        continue;
                    }
                    Debug.Log("unzipping:" + file);
                    AddAdaptersDirectory(apdFolder, project, unityiPhone);
#if UNITY_2019_3
                    AddAdaptersDirectory(apdFolder, project, unityFramework);
#endif
                }
            }

            File.WriteAllText(projPath, project.WriteToString());
        }