Exemplo n.º 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());
        }
Exemplo n.º 2
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());
        }