private static void BuildSetting_IOS(BuildConfig.IOSSetting pSetting)
        {
            if (string.IsNullOrEmpty(pSetting.strBundle_Identifier) == false)
            {
                PlayerSettings.applicationIdentifier = pSetting.strBundle_Identifier;
            }

            string strVersion_FromCommandLine = GetCommandLineArg(mapCommandLine[ECommandLineList.ios_version]);

            if (string.IsNullOrEmpty(strVersion_FromCommandLine) == false)
            {
                PlayerSettings.bundleVersion = strVersion_FromCommandLine;
            }
            else if (string.IsNullOrEmpty(pSetting.strBuildVersion) == false)
            {
                PlayerSettings.bundleVersion = pSetting.strBuildVersion;
            }


            string strBuildNumber_FromCommandLine = GetCommandLineArg(mapCommandLine[ECommandLineList.ios_buildnumber]);

            if (string.IsNullOrEmpty(strBuildNumber_FromCommandLine) == false)
            {
                PlayerSettings.iOS.buildNumber = strBuildNumber_FromCommandLine;
            }
            else if (string.IsNullOrEmpty(pSetting.strBuildNumber) == false)
            {
                PlayerSettings.iOS.buildNumber = pSetting.strBuildNumber;
            }


            Debug.Log(const_strPrefix_ForDebugLog +
                      $" Build Setting [IOS]\n" +
                      $"applicationIdentifier : {PlayerSettings.applicationIdentifier}\n" +
                      $"PlayerSettings.bundleVersion : {PlayerSettings.bundleVersion}\n" +
                      $"buildNumber : {PlayerSettings.iOS.buildNumber}"
                      );
        }
예제 #2
0
        private static void BuildSetting_IOS(BuildConfig.IOSSetting pSetting)
        {
            if (string.IsNullOrEmpty(pSetting.strBundle_Identifier) == false)
            {
                PlayerSettings.applicationIdentifier = pSetting.strBundle_Identifier;
            }

            string strVersion_FromCommandLine = GetCommandLineArg(const_mapCommandLine[ECommandLineList.ios_version]);

            if (string.IsNullOrEmpty(strVersion_FromCommandLine) == false)
            {
                PlayerSettings.iOS.buildNumber = strVersion_FromCommandLine;
            }
            else
            {
                PlayerSettings.iOS.buildNumber = pSetting.strBuildNumber;
            }

            Debug.LogFormat(const_strPrefix_ForDebugLog + " Build Setting [IOS]\n" +
                            "strPackageName : {0}\n" +
                            "strBuildNumber : {1}",
                            PlayerSettings.applicationIdentifier, PlayerSettings.iOS.buildNumber
                            );
        }
        // ReSharper disable once UnusedParameter.Local
        private static void Setup_XCodePlist(string strXCodeProjectPath)
        {
#if UNITY_IOS
            Debug.Log($"{const_strPrefix_ForDebugLog} {nameof(Setup_XCodePlist)} Start - {nameof(strXCodeProjectPath)} : {strXCodeProjectPath}");
            BuildConfig.IOSSetting pIOSSetting = g_pLastConfig.pIOSSetting;

            // Property List(.plist) Default Name
            const string strInfoPlistName = "Info.plist";

            var str_plistPath   = Path.Combine(strXCodeProjectPath, strInfoPlistName);
            var p_plistDocument = new PlistDocument();
            p_plistDocument.ReadFromFile(str_plistPath);



            // 해당 키는 IOS 업로드 시 해당 키는 지원하지 않는다는 에러 발생으로 인해 제거
            const string strExitsOnSuspendKey = "UIApplicationExitsOnSuspend";
            var          arrRootValues        = p_plistDocument.root.values;
            if (arrRootValues.ContainsKey(strExitsOnSuspendKey))
            {
                arrRootValues.Remove(strExitsOnSuspendKey);
            }

            foreach (var pProperty in pIOSSetting.arrAddPlist)
            {
                Debug.Log($"{const_strPrefix_ForDebugLog} Add Property - Key : \"{pProperty.strKey}\" Value : {pProperty.strValue}");

                if (arrRootValues.ContainsKey(pProperty.strKey))
                {
                    arrRootValues[pProperty.strKey] = new PlistElementString(pProperty.strValue);
                }
                else
                {
                    arrRootValues.Add(pProperty.strKey, new PlistElementString(pProperty.strValue));
                }
            }

            foreach (string strRemovePropertyKey in pIOSSetting.arrRemovePlistKey)
            {
                if (arrRootValues.ContainsKey(strRemovePropertyKey))
                {
                    arrRootValues.Remove(strRemovePropertyKey);
                    Debug.Log($"{const_strPrefix_ForDebugLog} Contains & Removed Key.Length : {strRemovePropertyKey}");
                }
            }

            Debug.Log($"{const_strPrefix_ForDebugLog} pIOSSetting.arrHTTPAddress.Length : \"{pIOSSetting.arrHTTPAddress.Length}\"");

            // HTTP 주소는 Plist에 추가해야 접근 가능..
            if (pIOSSetting.arrHTTPAddress.Length != 0)
            {
                PlistElementDict pTransportDict        = Get_Or_Add_PlistDict(arrRootValues, "NSAppTransportSecurity");
                PlistElementDict pExceptionDomainsDict = Get_Or_Add_PlistDict(pTransportDict.values, "NSExceptionDomains");

                foreach (string strAddress in pIOSSetting.arrHTTPAddress)
                {
                    Debug.Log($"{const_strPrefix_ForDebugLog} Add HTTPAddress : \"{strAddress}\"");

                    PlistElementDict pTransportDomain = Get_Or_Add_PlistDict(pExceptionDomainsDict.values, strAddress);
                    const string     strNSAllowInsecureHTTPLoadsKey = "NSExceptionAllowsInsecureHTTPLoads";
                    const string     strNSIncludesSubdomains        = "NSIncludesSubdomains";


                    if (pTransportDomain.values.ContainsKey(strNSAllowInsecureHTTPLoadsKey) == false)
                    {
                        pTransportDomain.values.Add(strNSAllowInsecureHTTPLoadsKey, new PlistElementBoolean(true));
                    }

                    if (pTransportDomain.values.ContainsKey(strNSIncludesSubdomains) == false)
                    {
                        pTransportDomain.values.Add(strNSIncludesSubdomains, new PlistElementBoolean(true));
                    }
                }
            }

            // Apply editing settings to Info.plist
            p_plistDocument.WriteToFile(str_plistPath);
            Debug.Log($"{const_strPrefix_ForDebugLog} {nameof(Setup_XCodePlist)} - WriteToFile {str_plistPath}");
#else
            Debug.Log($"{const_strPrefix_ForDebugLog} {nameof(Setup_XCodePlist)} - Not Define Symbol is Not IOS");
#endif
        }
        // ==============================================================================================

        /// <summary>
        /// IOS용 XCode Initialize
        /// </summary>
        // ReSharper disable once UnusedParameter.Local
        private static void Init_XCodeProject(string strXCodeProjectPath)
        {
#if UNITY_IOS
            BuildConfig.IOSSetting pIOSSetting = g_pLastConfig.pIOSSetting;
            var projectPath = strXCodeProjectPath + "/Unity-iPhone.xcodeproj/project.pbxproj";

            Debug.Log($"{const_strPrefix_ForDebugLog} {nameof(Init_XCodeProject)} Start - {nameof(strXCodeProjectPath)} : {strXCodeProjectPath}\n" +
                      $"projectPath : {projectPath}");

            PBXProject pPBXProject = new PBXProject();
            pPBXProject.ReadFromFile(projectPath);

            string strTargetGuid = pPBXProject.TargetGuidByName("Unity-iPhone");


            // Set Apple Team ID
            pPBXProject.SetTeamId(strTargetGuid, pIOSSetting.strAppleTeamID);

            // Copy File Asset To XCode Project
            foreach (var strFilePath in pIOSSetting.arrCopy_AssetFilePath_To_XCodeProjectPath)
            {
                CopyFile_Asset_To_XCode(strXCodeProjectPath, strFilePath);
            }


            // Add XCode Framework
            foreach (string strFramework in pIOSSetting.arrXCode_Framework_Add)
            {
                pPBXProject.AddFrameworkToProject(strTargetGuid, strFramework, false);
                Debug.Log($"{const_strPrefix_ForDebugLog} Add Framework \"{strFramework}\" to XCode Project");
            }


            // Remove XCode Framework
            foreach (string strFramework in pIOSSetting.arrXCode_Framework_Remove)
            {
                pPBXProject.RemoveFrameworkFromProject(strTargetGuid, strFramework);
                Debug.Log($"{const_strPrefix_ForDebugLog} Remove Framework \"{strFramework}\" to XCode Project");
            }


            // Set XCode OTHER_LDFLAGS
            pPBXProject.UpdateBuildProperty(strTargetGuid, "OTHER_LDFLAGS", pIOSSetting.arrXCode_OTHER_LDFLAGS_Add, pIOSSetting.arrXCode_OTHER_LDFLAGS_Remove);

            #region Sample
            // // Sample of setting build property
            // project.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");

            // Sample of setting compile flags
            // var guid = pbxProject.FindFileGuidByProjectPath("Classes/UI/Keyboard.mm");
            // var flags = pbxProject.GetCompileFlagsForFile(targetGuid, guid);
            // flags.Add("-fno-objc-arc");
            // pbxProject.SetCompileFlagsForFile(targetGuid, guid, flags);
            #endregion Sample

            string strTargetEntitlementsFilePath = strXCodeProjectPath + "/" + pIOSSetting.strEntitlementsFileName_Without_ExtensionName + ".entitlements";
            pPBXProject.AddCapability(strTargetGuid, PBXCapabilityType.PushNotifications, strTargetEntitlementsFilePath, true);
            pPBXProject.AddCapability(strTargetGuid, PBXCapabilityType.InAppPurchase, null, true);
            pPBXProject.AddCapability(strTargetGuid, PBXCapabilityType.GameCenter, null, true);

            pPBXProject.AddBuildProperty(strTargetGuid, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)");

            SetIOS_AuthToken(pPBXProject, strTargetGuid);

            // Apply settings
            File.WriteAllText(projectPath, pPBXProject.WriteToString());
#else
            Debug.Log($"{const_strPrefix_ForDebugLog} {nameof(Init_XCodeProject)} - Define Symbol is Not IOS");
#endif
        }