Пример #1
0
        public virtual bool UpdateXCodeProj()
        {
            string FacebookID          = GetParamOrConfigString(FacebookIDFlag, "Your Facebook ID hasn't been set!  Facebook functionality will probably not work correctly.");
            string FacebookDisplayName = GetParamOrConfigString(FacebookDisplayNameFlag, "Your Facebook Display Name hasn't been set!  Facebook functionality will probably not work correctly.");

            List <string> BuildProducts = IgorCore.GetModuleProducts();

            if (IgorAssert.EnsureTrue(this, BuildProducts.Count > 0, "Attempting to update the XCode project, but one was not generated in the build phase!"))
            {
                string ProjectPath = Path.Combine(BuildProducts[0], "Unity-IPhone.xcodeproj");

                string FacebookIntegrationGUID = IgorXCodeProjUtils.AddNewFileReference(this, ProjectPath, "FacebookIntegration.h", TreeEnum.GROUP);

                IgorXCodeProjUtils.SortGUIDIntoGroup(this, ProjectPath, FacebookIntegrationGUID, "Libraries");

                IgorXCodeProjUtils.AddFramework(this, ProjectPath, "FacebookSDK.framework", TreeEnum.GROUP, "Libraries/FacebookSDK.framework", -1, "wrapper.framework", "FacebookSDK.framework");

                IgorXCodeProjUtils.AddFrameworkSearchPath(this, ProjectPath, "$(SRCROOT)/Libraries");

                string PlistPath = Path.Combine(BuildProducts[0], "Info.plist");

                IgorPlistUtils.SetStringValue(this, PlistPath, "FacebookAppID", FacebookID);

                IgorPlistUtils.SetStringValue(this, PlistPath, "FacebookDisplayName", FacebookDisplayName);

                IgorPlistUtils.AddBundleURLType(this, PlistPath, "fb" + FacebookID);

                IgorZip.UnzipArchiveCrossPlatform(this, Path.Combine(Path.GetFullPath("."), Path.Combine("Assets", Path.Combine("Plugins", Path.Combine("iOS", Path.Combine("FacebookSDK", "FacebookSDK.framework.zip"))))), Path.Combine(BuildProducts[0], "Libraries"));

                IgoriOSSourceUtils.AddHeaderToAppControllerSource(this, BuildProducts[0], "../Libraries/FacebookIntegration.h");

                IgoriOSSourceUtils.AddFunctionToAppControllerSource(this, BuildProducts[0], "/* Pre iOS 4.2 support */\n- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\n{\n\treturn [FBSession.activeSession handleOpenURL:url];\n}\n");

                IgorUtils.ReplaceStringsInFile(this, Path.Combine(BuildProducts[0], Path.Combine("Classes", "UnityAppController.mm")), "AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);\n\treturn YES;", "AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData); return [FBSession.activeSession handleOpenURL:url];");

                IgoriOSSourceUtils.AddSourceToApplicationDidBecomeActive(this, BuildProducts[0], "[FBSession.activeSession handleDidBecomeActive];");
            }

            return(true);
        }
Пример #2
0
        public virtual bool CreateWebDeployFiles()
        {
            List <string> BuiltProducts = IgorCore.GetModuleProducts();

            string FileToCopy           = "";
            string RootProjectDirectory = "";
            string WebDeployTempDir     = Path.Combine(Path.GetFullPath("."), "iOSOTATemp");

            if (IgorAssert.EnsureTrue(this, BuiltProducts.Count > 1, "iOS OTA expected at least two built products, the IPA and the iOS XCode project directory."))
            {
                FileToCopy           = BuiltProducts[0];
                RootProjectDirectory = BuiltProducts[1];
            }

            if (IgorAssert.EnsureTrue(this, File.Exists(FileToCopy), "iOS OTA expected the IPA to be at " + FileToCopy + ", but it was not there.") &&
                IgorAssert.EnsureTrue(this, Directory.Exists(RootProjectDirectory), "iOS OTA expected the XCode Project folder to be at " + RootProjectDirectory + ", but it was not there."))
            {
                if (Directory.Exists(WebDeployTempDir))
                {
                    IgorRuntimeUtils.DeleteDirectory(WebDeployTempDir);
                }

                Directory.CreateDirectory(WebDeployTempDir);

                string PlistPath = Path.Combine(RootProjectDirectory, "Info.plist");

                string BundleIdentifier = PlayerSettings.bundleIdentifier;
                string BundleVersion    = IgorPlistUtils.GetStringValue(this, PlistPath, "CFBundleVersion");
                string DisplayName      = IgorPlistUtils.GetStringValue(this, PlistPath, "CFBundleDisplayName");

                string OTAManifestPath = GetParamOrConfigString(OTAPlistNameFlag, "", "Application", false);

                if (!OTAManifestPath.EndsWith(".plist"))
                {
                    OTAManifestPath += ".plist";
                }

                OTAManifestPath = Path.Combine(WebDeployTempDir, OTAManifestPath);

                string FullIconName = Path.Combine(RootProjectDirectory, Path.Combine("Unity-iPhone", Path.Combine("Images.xcassets", Path.Combine("AppIcon.appiconset", "Icon.png"))));

                string IPAName  = Path.GetFileName(FileToCopy);
                string IconName = Path.GetFileName(FullIconName);

                GenerateAndSavePlist(OTAManifestPath, IPAName, IconName, BundleIdentifier, BundleVersion, DisplayName);

                string IPADeployName  = Path.Combine(WebDeployTempDir, IPAName);
                string IconDeployName = Path.Combine(WebDeployTempDir, IconName);

                IgorRuntimeUtils.CopyFile(FileToCopy, IPADeployName);
                IgorRuntimeUtils.CopyFile(FullIconName, IconDeployName);

                List <string> NewBuiltProducts = new List <string>();

                NewBuiltProducts.Add(OTAManifestPath);
                NewBuiltProducts.Add(IPADeployName);
                NewBuiltProducts.Add(IconDeployName);

                IgorCore.SetNewModuleProducts(NewBuiltProducts);

                Log("iOS OTA files successfully generated.");
            }

            return(true);
        }