// Sets the required project settings for the Xcode project to work with the SDK.
        public static void SetBuildProperties(ExtendedPBXProject project)
        {
            project.SetBuildProperty(project.GetAllTargetGuids(), ExtendedPBXProject.SwiftVersionKey, "3.0");
            project.SetBuildProperty(project.UnityTargetGuid, ExtendedPBXProject.SwiftBridgingHeaderKey, "Libraries/Shopify/Plugins/iOS/Shopify/Unity-iPhone-Bridging-Header.h");
            project.SetBuildProperty(project.UnityTargetGuid, ExtendedPBXProject.RunpathSearchKey, "@executable_path/Frameworks");

            bool isBelowMinimumTarget = false;

#if UNITY_5_5_OR_NEWER
            if (UnityEditor.PlayerSettings.iOS.targetOSVersionString == null ||
                UnityEditor.PlayerSettings.iOS.targetOSVersionString.Length == 0 ||
                float.Parse(UnityEditor.PlayerSettings.iOS.targetOSVersionString) < 9.0)
            {
                isBelowMinimumTarget = true;
            }
#elif UNITY_5_4_2_OR_NEWER
            isBelowMinimumTarget = UnityEditor.PlayerSettings.iOS.targetOSVersion < iOSTargetOSVersion.iOS_9_0;
#else
            isBelowMinimumTarget = true;
#endif

            if (isBelowMinimumTarget)
            {
                project.SetBuildProperty(project.GetAllTargetGuids(), ExtendedPBXProject.DeploymentTarget, "9.0");
            }
        }
Пример #2
0
        // Sets the required project settings for the Xcode project to work with the SDK.
        public static void SetBuildProperties(ExtendedPBXProject project)
        {
            project.SetBuildProperty(project.GetAllTargetGuids(), ExtendedPBXProject.SwiftVersionKey, "4.0");
            project.SetBuildProperty(project.UnityTargetGuid, ExtendedPBXProject.RunpathSearchKey, "@executable_path/Frameworks");

            project.AddBuildProperty(project.GetUnityFrameworkTargetGuid(), ExtendedPBXProject.LibrarySearchPathsKey, "$(inherited)");
            project.AddBuildProperty(project.GetUnityFrameworkTargetGuid(), ExtendedPBXProject.LibrarySearchPathsKey, "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)");
            project.AddBuildProperty(project.GetUnityFrameworkTargetGuid(), ExtendedPBXProject.LibrarySearchPathsKey, "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)");
            project.AddBuildProperty(project.GetUnityFrameworkTargetGuid(), ExtendedPBXProject.OtherLinkerFlagsKey, "-all_load");

            bool isBelowMinimumTarget = false;

#if UNITY_5_5_OR_NEWER
            if (UnityEditor.PlayerSettings.iOS.targetOSVersionString == null ||
                UnityEditor.PlayerSettings.iOS.targetOSVersionString.Length == 0 ||
                float.Parse(UnityEditor.PlayerSettings.iOS.targetOSVersionString) < 9.0)
            {
                isBelowMinimumTarget = true;
            }
#elif UNITY_5_4_2_OR_NEWER
            isBelowMinimumTarget = UnityEditor.PlayerSettings.iOS.targetOSVersion < iOSTargetOSVersion.iOS_9_0;
#else
            isBelowMinimumTarget = true;
#endif

            if (isBelowMinimumTarget)
            {
                project.SetBuildProperty(project.GetAllTargetGuids(), ExtendedPBXProject.DeploymentTarget, "10.0");
            }
        }
Пример #3
0
 /// Sets the correct build properties to run
 private static void SetBuildProperties(ExtendedPBXProject project)
 {
     iOSPostProcessor.SetBuildProperties(project);
     project.SetBuildProperty(project.TestTargetGuid, ExtendedPBXProject.SwiftBridgingHeaderKey, "Libraries/Shopify/Plugins/iOS/Shopify/Unity-iPhone-Tests-Bridging-Header.h");
     project.SetBuildProperty(project.TestTargetGuid, ExtendedPBXProject.RunpathSearchKey, "@loader_path/Frameworks");
     project.SetBuildProperty(project.TestTargetGuid, ExtendedPBXProject.ProjectModuleNameKey, "$(PRODUCT_NAME:c99extidentifier)Tests");
     project.SetBuildPropertyForConfig(project.GetDebugConfig(project.UnityTargetGuid), ExtendedPBXProject.EnableTestabilityKey, "YES");
     project.SetBuildPropertyForConfig(project.GetDebugConfig(project.UnityTargetGuid), ExtendedPBXProject.SwiftOptimizationLevelKey, "-Onone");
 }
Пример #4
0
        /// <summary>
        /// Perform post processing on the build to only run Shopify Tests
        /// </summary>
        public static void ProcessForTests(string buildPath)
        {
            var project = new ExtendedPBXProject(buildPath);

            SetBuildProperties(project);
            SetCorrectTestsTarget(project);
            project.RemoveFileFromBuild(project.TestTargetGuid, project.FindFileGuidByProjectPath("Unity-iPhone Tests/Unity_iPhone_Tests.m"));
            iOSPostProcessor.SetSwiftInterfaceHeader(project);
            project.Save();
        }
Пример #5
0
        /// Sets the correct target for Shopify Tests
        private static void SetCorrectTestsTarget(ExtendedPBXProject project)
        {
            string testPath      = Path.Combine(project.BuildPath, "Libraries/Shopify/Plugins/iOS/Shopify/BuyTests/");
            var    testDirectory = new DirectoryInfo(testPath);

            try {
                project.SetFilesInDirectoryToTestTarget(testDirectory);
            } catch (Exception e) {
                Debug.Log(e.Message);
            }
        }
        public static void ProcessForExport(BuildTarget target, string buildPath)
        {
            if (target != BuildTarget.iOS)
            {
                return;
            }

            var project = new ExtendedPBXProject(buildPath);

            SetCorrectTestsTarget(project);
            SetBuildProperties(project);
            SetSwiftInterfaceHeader(project);
            project.Save();
        }
        /// Sets the correct target for Shopify Tests
        private static void SetCorrectTestsTarget(ExtendedPBXProject project)
        {
            string testPath      = Path.Combine(project.BuildPath, "Libraries/Shopify/Plugins/iOS/Shopify/BuyTests/");
            string testerPath    = Path.Combine(project.BuildPath, "Libraries/Shopify/Plugins/iOS/Shopify/BuyTests/UnityTestHelpers/Tester.mm");
            var    testDirectory = new DirectoryInfo(testPath);

            try {
                project.SetFilesInDirectoryToTestTarget(testDirectory);

                // Re-add Tester.mm file to main target to allow Tester.cs to find it's DllImport.
                project.AddFileToMainTarget(testerPath);
            } catch (Exception e) {
                Debug.Log(e.Message);
            }
        }
        public static void SetSwiftInterfaceHeader(ExtendedPBXProject project)
        {
            var bundleIdentifier = PlayerSettings.iPhoneBundleIdentifier;

            char[] separator   = { '.' };
            var    keywords    = bundleIdentifier.Split(separator);
            var    productName = keywords[keywords.Length - 1];

            string swiftInterfaceHeaderPath = Path.Combine(project.BuildPath, "Libraries/Shopify/Plugins/iOS/Shopify/SwiftInterfaceHeader.h");

            if (File.Exists(swiftInterfaceHeaderPath))
            {
                string[] lines = File.ReadAllLines(swiftInterfaceHeaderPath, System.Text.Encoding.UTF8);

                if (lines.Length != 0)
                {
                    lines[0] = "#import \"" + productName + "-Swift.h\"";
                }

                File.WriteAllLines(swiftInterfaceHeaderPath, lines);
            }
        }