示例#1
0
        public static void PostprocessBuild(BuildTarget buildTarget, string buildPath)
        {
            if (IdfaAuthorizationUtils.IsAttEnabled())
            {
                if (buildTarget != BuildTarget.iOS)
                {
                    return;
                }


                var plistPath = Path.Combine(buildPath, "Info.plist");
                var plist     = new PlistDocument();
                plist.ReadFromFile(plistPath);
                PlistElement element = plist.root[UserTrackingUsageDescriptionKey];


                PlistElementArray skAdNetworks = plist.root.CreateArray("SKAdNetworkItems");

                PlistElementDict fbSkanId = skAdNetworks.AddDict();
                fbSkanId.SetString("SKAdNetworkIdentifier", "v9wttpbfk9.skadnetwork");
                PlistElementDict fbSkanSecondaryId = skAdNetworks.AddDict();
                fbSkanSecondaryId.SetString("SKAdNetworkIdentifier", "n38lu8286q.skadnetwork");
                PlistElementDict snapSkanId = skAdNetworks.AddDict();
                snapSkanId.SetString("SKAdNetworkIdentifier", "424m5254lk.skadnetwork");


                plist.root.SetString(UserTrackingUsageDescriptionKey, IdfaAuthorizationConstants.UserTrackingUsageDescription);
                plist.WriteToFile(plistPath);
            }
        }
示例#2
0
    public static void AddURLSchemeToPlist(PlistDocument plist, string urlSchemeToAdd)
    {
        // Get/create array of URL types
        PlistElementArray urlTypesArray = null;

        if (!plist.root.values.ContainsKey("CFBundleURLTypes"))
        {
            urlTypesArray = plist.root.CreateArray("CFBundleURLTypes");
        }
        else
        {
            urlTypesArray = plist.root.values["CFBundleURLTypes"].AsArray();
        }
        if (urlTypesArray == null)
        {
            urlTypesArray = plist.root.CreateArray("CFBundleURLTypes");
        }

        // Get/create an entry in the array
        PlistElementDict urlTypesItems = null;

        if (urlTypesArray.values.Count == 0)
        {
            urlTypesItems = urlTypesArray.AddDict();
        }
        else
        {
            urlTypesItems = urlTypesArray.values[0].AsDict();

            if (urlTypesItems == null)
            {
                urlTypesItems = urlTypesArray.AddDict();
            }
        }

        // Get/create array of URL schemes
        PlistElementArray urlSchemesArray = null;

        if (!urlTypesItems.values.ContainsKey("CFBundleURLSchemes"))
        {
            urlSchemesArray = urlTypesItems.CreateArray("CFBundleURLSchemes");
        }
        else
        {
            urlSchemesArray = urlTypesItems.values["CFBundleURLSchemes"].AsArray();

            if (urlSchemesArray == null)
            {
                urlSchemesArray = urlTypesItems.CreateArray("CFBundleURLSchemes");
            }
        }

        // Add URL scheme
        if (!urlSchemesArray.ContainsElement(urlSchemeToAdd))
        {
            urlSchemesArray.Add(urlSchemeToAdd);
        }
    }
        static void ModifyPlist(string path)
        {
            // Info.plist
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();

            plist.ReadFromString(File.ReadAllText(path: plistPath));

            // ROOT
            PlistElementDict  rootDict = plist.root;
            PlistElementArray urlTypes = rootDict.CreateArray("CFBundleURLTypes");

            // Add URLScheme For Wechat
            PlistElementDict wxUrl = urlTypes.AddDict();

            wxUrl.SetString("CFBundleTypeRole", "Editor");
            wxUrl.SetString("CFBundleURLName", "weixin");
            wxUrl.SetString("CFBundleURLSchemes", val: Config.wechatAppId);
            PlistElementArray wxUrlScheme = wxUrl.CreateArray("CFBundleURLSchemes");

            wxUrlScheme.AddString(val: Config.wechatAppId);

            // Add URLScheme For jiguang
            PlistElementDict jgUrl = urlTypes.AddDict();

            jgUrl.SetString("CFBundleTypeRole", "Editor");
            jgUrl.SetString("CFBundleURLName", "jiguang");
            jgUrl.SetString("CFBundleURLSchemes", val: "jiguang-" + Config.jgAppKey);
            PlistElementArray jgUrlScheme = jgUrl.CreateArray("CFBundleURLSchemes");

            jgUrlScheme.AddString(val: "jiguang-" + Config.jgAppKey);

            // 白名单 for wechat
            PlistElementArray queriesSchemes = rootDict.CreateArray("LSApplicationQueriesSchemes");

            queriesSchemes.AddString("wechat");
            queriesSchemes.AddString("weixin");
            queriesSchemes.AddString(val: Config.wechatAppId);

            // HTTP 设置
            const string     atsKey  = "NSAppTransportSecurity";
            PlistElementDict dictTmp = rootDict.CreateDict(key: atsKey);

            dictTmp.SetBoolean("NSAllowsArbitraryLoads", true);

            PlistElementArray backModes = rootDict.CreateArray("UIBackgroundModes");

            backModes.AddString("remote-notification");

            // 出口合规信息
            rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);

            // 写入
            File.WriteAllText(path: plistPath, plist.WriteToString());
        }
示例#4
0
        public void PlistContainsAdNetworkId(string adNetworkId, bool expectedValue)
        {
            var plistArray = new PlistElementArray();

            plistArray.AddDict().SetString("SKAdNetworkIdentifier", "4DZT52R2T5.skadnetwork");
            Assert.That(PostProcessBuildPlist.PlistContainsAdNetworkId(plistArray, adNetworkId), Is.EqualTo(expectedValue));
        }
示例#5
0
    //设置info.plist文件
    void SetInfo(string pathToBuildProject)
    {
        string        plistPath = pathToBuildProject + "/Info.plist";
        PlistDocument plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));
        PlistElementDict plistRoot = plist.root;

        //指定打包时使用的ProvisioningProfile
        PlistElementDict dict = plistRoot.CreateDict("provisioningProfiles");

        dict.SetString(PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS), PlayerSettings.iOS.iOSManualProvisioningProfileID);
        plistRoot.SetString("method", PlayerSettings.iOS.iOSManualProvisioningProfileType == ProvisioningProfileType.Development ? "development" : "app-store");

        plistRoot.SetString("NSCameraUsageDescription", "需要使用相机");
        plistRoot.SetString("NSCalendarsUsageDescription", "需要使用日历");
        plistRoot.SetString("NSPhotoLibraryUsageDescription", "需要使用相册");
        plistRoot.SetString("NSLocationWhenInUseUsageDescription", "需要访问地理位置");

        //龙图SDK设置URL Schemes
        PlistElementArray URLArray    = plistRoot.CreateArray("CFBundleURLTypes");
        PlistElementDict  elementDict = URLArray.AddDict();;

        elementDict.SetString("CFBundleURLName", "GoogleID");
        elementDict.CreateArray("CFBundleURLSchemes").AddString("com.googleusercontent.apps.837194912770-vt71nif9hiifrdb2hcg2l2ejc94rnloq");
        File.WriteAllText(plistPath, plist.WriteToString());
    }
示例#6
0
        public static void SetupXcodeSettingsForToriki(BuildTarget buildTarget, string pathToBuiltProject)
        {
            if (buildTarget == BuildTarget.iOS)
            {
                // Get plist
                string        plistPath = pathToBuiltProject + "/Info.plist";
                PlistDocument plist     = new PlistDocument();
                plist.ReadFromString(File.ReadAllText(plistPath));

                // Get root
                PlistElementDict rootDict = plist.root;

                // Modify Info.Plist for Twitter Kit (https://dev.twitter.com/twitterkit/ios/installation)
                PlistElementArray bundleURLTypesArray = rootDict[URL_TYPES] as PlistElementArray;
                if (bundleURLTypesArray == null)
                {
                    bundleURLTypesArray = rootDict.CreateArray(URL_TYPES);
                }
                PlistElementDict  dict = bundleURLTypesArray.AddDict();
                PlistElementArray bundleURLSchemesArray = dict.CreateArray(URL_SCHEMES);
                bundleURLSchemesArray.AddString("twitterkit-" + TwitterSettings.ConsumerKey);
                PlistElementArray queriesSchemesArray = rootDict[APPLICATION_QUERIES_SCHEMES] as PlistElementArray;
                if (queriesSchemesArray == null)
                {
                    queriesSchemesArray = rootDict.CreateArray(APPLICATION_QUERIES_SCHEMES);
                }
                queriesSchemesArray.AddString("twitter");
                queriesSchemesArray.AddString("twitterauth");

                // Write to file
                File.WriteAllText(plistPath, plist.WriteToString());
            }
        }
示例#7
0
    private static void AddImportedType(PlistElementArray importedTypesArray,
                                        string description, string uti, string conforms,
                                        string[] extensions, string[] mimeTypes)
    {
        var declarationDict = importedTypesArray.AddDict();

        declarationDict.SetString("UTTypeIdentifier", uti);
        declarationDict.SetString("UTTypeDescription", description);
        var conformsToArray = declarationDict.CreateArray("UTTypeConformsTo");

        conformsToArray.AddString(conforms);
        var tagSpecificationsDict = declarationDict.CreateDict("UTTypeTagSpecification");
        var extensionsArray       = tagSpecificationsDict.CreateArray("public.filename-extension");

        foreach (string ext in extensions)
        {
            extensionsArray.AddString(ext);
        }
        var mimeTypesArray = tagSpecificationsDict.CreateArray("public.mime-type");

        foreach (string mime in mimeTypes)
        {
            mimeTypesArray.AddString(mime);
        }
    }
        private static void OnPostprocessBuild(BuildTarget buildTarget, string buildPath)
        {
            if (buildTarget != BuildTarget.iOS)
            {
                return;
            }
            if (LineLoginSetting.IsValid() == false)
            {
                Debug.LogErrorFormat("no LineLoginSetting Asset In Resources or Invalid");
            }
            if (string.IsNullOrEmpty(LineLoginSetting.ChannelID))
            {
                Debug.LogAssertion("channelId is INVALID! please set channelID use [Tools/Line Login]");
            }
            string        plistPath = LineLoginSetting.GetInfoPlistPath(buildPath);
            PlistDocument plist     = new PlistDocument();

            plist.ReadFromFile(plistPath);
            string     pbxProjPath = PBXProject.GetPBXProjectPath(buildPath);
            PBXProject pbxProject  = new PBXProject();

            pbxProject.ReadFromString(File.ReadAllText(pbxProjPath));

            string targetGuid = pbxProject.TargetGuidByName(PBXProject.GetUnityTargetName());

            pbxProject.UpdateBuildProperty(targetGuid, "OTHER_LDFLAGS", new string[] { "-ObjC" }, null);

            File.WriteAllText(pbxProjPath, pbxProject.WriteToString());

            if (plist.root.values.ContainsKey("LineSDKConfig"))
            {
                plist.root.values.Remove("LineSDKConfig");
            }
            if (plist.root.values.ContainsKey("CFBundleURLTypes"))
            {
                plist.root.values.Remove("CFBundleURLTypes");
            }
            if (plist.root.values.ContainsKey("LSApplicationQueriesSchemes"))
            {
                plist.root.values.Remove("LSApplicationQueriesSchemes");
            }
            plist.root.CreateDict("LineSDKConfig").SetString("ChannelID", LineLoginSetting.ChannelID);

            PlistElementArray CFBundleURLTypes     = plist.root.CreateArray("CFBundleURLTypes");
            PlistElementDict  CFBundleURLTypesDict = CFBundleURLTypes.AddDict();

            CFBundleURLTypesDict.SetString("CFBundleTypeRole", "Editor");
            CFBundleURLTypesDict.SetString("CFBundleTypeName", "linelogin");
            //$(PRODUCT_BUNDLE_IDENTIFIER) dosen't works for CFBundleTypeSchemes?
            //CFBundleURLTypesDict.CreateArray("CFBundleURLSchemes").AddString("line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)");
            CFBundleURLTypesDict.CreateArray("CFBundleURLSchemes").AddString("line3rdp." + Application.identifier);
            PlistElementArray arr = plist.root.CreateArray("LSApplicationQueriesSchemes");

            arr.AddString("lineauth");
            arr.AddString("line3rdp." + Application.identifier);
            plist.WriteToFile(LineLoginSetting.GetInfoPlistPath(buildPath));
            Debug.Log("iOS Line Login Post Process done. with ChannelID:" + LineLoginSetting.ChannelID);
        }
示例#9
0
    public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            // Get plist
            string        plistPath = pathToBuiltProject + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            // Get root
            PlistElementDict rootDict = plist.root;

            // Remote notifications (Megacool sdk, etc)
            var buildKey = "UIBackgroundModes";
            rootDict.CreateArray(buildKey).AddString("remote-notification");

            //
            PlistElementArray queriesSchemes = rootDict.CreateArray("LSApplicationQueriesSchemes");
            queriesSchemes.AddString("fb");
            queriesSchemes.AddString("instagram");
            queriesSchemes.AddString("tumblr");
            queriesSchemes.AddString("twitter");

            rootDict.CreateDict("NSCalendarsUsageDescription");
            rootDict.SetString("NSCalendarsUsageDescription", "Adding events");

            rootDict.CreateDict("NSPhotoLibraryUsageDescription");
            rootDict.SetString("NSPhotoLibraryUsageDescription", "Taking selfies");

            rootDict.CreateDict("NSCameraUsageDescription");
            rootDict.SetString("NSCameraUsageDescription", "Taking selfies");

            rootDict.CreateDict("NSMotionUsageDescription");
            rootDict.SetString("NSMotionUsageDescription", "Interactive ad controls");

            rootDict.CreateDict("NSBluetoothPeripheralUsageDescription");
            rootDict.SetString("NSBluetoothPeripheralUsageDescription", "Advertisement would like to use bluetooth.");

            PlistElementArray bundleURLTypes    = rootDict.CreateArray("CFBundleURLTypes");
            PlistElementDict  bundleURLTypesDic = bundleURLTypes.AddDict();
            PlistElementArray bundleURLSchemes  = bundleURLTypesDic.CreateArray("CFBundleURLSchemes");
            bundleURLSchemes.AddString("fbYOUR-FB-ID");

            rootDict.CreateDict("FacebookAppID");
            rootDict.SetString("FacebookAppID", "YOUR-FB-ID");

            rootDict.CreateDict("FacebookDisplayName");
            rootDict.SetString("FacebookDisplayName", "Nuumbers");

            rootDict.CreateDict("AppLovinSdkKey");
            rootDict.SetString("AppLovinSdkKey", "YOUR-SDK-KEY");

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
示例#10
0
        /// <summary>
        /// 添加URLSchemes
        /// </summary>
        /// <param name="identifier">Identifier.</param>
        /// <param name="urlScheme">URL scheme.</param>
        public void AddUrlScheme(string identifier, string urlScheme)
        {
            const string KEY            = "CFBundleURLTypes";
            const string IDENTIFIER_KEY = "CFBundleURLName";
            const string URLSCHEMES_KEY = "CFBundleURLSchemes";

            PlistElementDict  root        = _plist.root;
            PlistElementArray urlTypeList = root[KEY] as PlistElementArray;

            if (null == urlTypeList)
            {
                urlTypeList = root.CreateArray(KEY);
            }

            PlistElementDict urlType = null;

            foreach (PlistElementDict item in urlTypeList.values)
            {
                if (item[IDENTIFIER_KEY].AsString() == identifier)
                {
                    urlType = item;
                    break;
                }
            }

            if (null == urlType)
            {
                urlType = urlTypeList.AddDict();
            }

            urlType.SetString(IDENTIFIER_KEY, identifier);

            PlistElementArray urlSchemes = urlType[URLSCHEMES_KEY] as PlistElementArray;

            if (null == urlSchemes)
            {
                urlSchemes = urlType.CreateArray(URLSCHEMES_KEY);
            }

            bool isInclude = false;

            foreach (PlistElement item in urlSchemes.values)
            {
                if (item.AsString() == urlScheme)
                {
                    isInclude = true;
                    break;
                }
            }

            if (false == isInclude)
            {
                urlSchemes.AddString(urlScheme);
            }
        }
示例#11
0
    private static void AddDocumentType(PlistElementArray documentTypesArray, string name, string uti)
    {
        var docTypeDict = documentTypesArray.AddDict();

        docTypeDict.CreateArray("CFBundleTypeIconFiles");
        docTypeDict.SetString("CFBundleTypeName", name);
        docTypeDict.SetString("LSHandlerRank", "Alternate"); // this app is a secondary viewer of JSON files
        var contentTypesArray = docTypeDict.CreateArray("LSItemContentTypes");

        contentTypesArray.AddString(uti);
    }
示例#12
0
        static void SetupURLScheme(PlistElementDict rootDict)
        {
            PlistElementArray array = GetOrCreateArray(rootDict, "CFBundleURLTypes");
            var lineURLScheme       = array.AddDict();

            lineURLScheme.SetString("CFBundleTypeRole", "Editor");
            lineURLScheme.SetString("CFBundleURLName", "LINE SDK");
            var schemes = lineURLScheme.CreateArray("CFBundleURLSchemes");

            schemes.AddString("line3rdp." + rootDict["CFBundleIdentifier"].AsString());
        }
示例#13
0
        public static void OnPostProcessBuild(BuildTarget buildTarget, string buildPath)
        {
            if (buildTarget == BuildTarget.iOS)
            {
                // var projPath = PBXProject.GetPBXProjectPath(buildPath);
                var projPath = buildPath + "/Unity-iPhone.xcodeproj/project.pbxproj";
                var proj     = new PBXProject();
                proj.ReadFromFile(projPath);

                string targetGuid = proj.TargetGuidByName(PBXProject.GetUnityTargetName());

                //// Configure build settings
                proj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
                proj.SetBuildProperty(targetGuid, "SWIFT_OBJC_BRIDGING_HEADER", "Libraries/LoomSDK/ios/LoomSDKSwift-Bridging-Header.h");
                proj.SetBuildProperty(targetGuid, "SWIFT_OBJC_INTERFACE_HEADER_NAME", "LoomSDKSwift.h");
                proj.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");
                proj.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Libraries/LoomSDK/Frameworks");
                proj.SetBuildProperty(targetGuid, "SWIFT_VERSION", "3.0");

                //frameworks
                DirectoryInfo projectParent     = Directory.GetParent(Application.dataPath);
                char          divider           = Path.DirectorySeparatorChar;
                DirectoryInfo destinationFolder =
                    new DirectoryInfo(buildPath + divider + "Frameworks/LoomSDK/Frameworks");

                foreach (DirectoryInfo file in destinationFolder.GetDirectories())
                {
                    string filePath = "Frameworks/LoomSDK/Frameworks/" + file.Name;
                    //proj.AddFile(filePath, filePath, PBXSourceTree.Source);
                    string fileGuid = proj.AddFile(filePath, filePath, PBXSourceTree.Source);
                    proj.AddFrameworkToProject(targetGuid, file.Name, false);

                    PBXProjectExtensions.AddFileToEmbedFrameworks(proj, targetGuid, fileGuid);
                }
                proj.WriteToFile(projPath);

                //info.plist
                var plistPath = buildPath + "/Info.plist";
                var plist     = new PlistDocument();
                plist.ReadFromFile(plistPath);
                // Update value
                PlistElementDict rootDict = plist.root;
                //rootDict.SetString("CFBundleIdentifier","$(PRODUCT_BUNDLE_IDENTIFIER)");
                PlistElementArray urls   = rootDict.CreateArray("CFBundleURLTypes");
                PlistElementDict  dic    = urls.AddDict();
                PlistElementArray scheme = dic.CreateArray("CFBundleURLSchemes");
                scheme.AddString(PlayerSettings.applicationIdentifier);
                dic.SetString("CFBundleURLName", "auth0");
                // Write plist
                File.WriteAllText(plistPath, plist.WriteToString());
            }
        }
示例#14
0
        static void ChangePlist(string pathToBuildProject)
        {
            string        path = string.Format("{0}/Info.plist", pathToBuildProject);
            PlistDocument doc  = new PlistDocument();

            doc.ReadFromString(File.ReadAllText(path));
            PlistElementDict root = doc.root;

            // 对iOS9的影响
            {
                PlistElementDict security = root.CreateDict("NSAppTransportSecurity");
                security.SetBoolean("NSAllowsArbitraryLoads", true);
            }

            // 合规证明
            {
                root.SetBoolean("ITSAppUsesNonExemptEncryption", false);
            }

            // 添加Scheme白名单
            {
                PlistElementArray schemes = root.CreateArray("LSApplicationQueriesSchemes");
                schemes.AddString("fbapi");
                schemes.AddString("fbauth2");
                schemes.AddString("fb-messenger-api");
            }

            // fb
            {
                string idFacebook = "212915212149962";

                root.SetString("FacebookAppID", idFacebook);
                root.SetString("FacebookDisplayName", PlayerSettings.productName);

                PlistElementArray types = root.CreateArray("CFBundleURLTypes");

                PlistElementDict dict = types.AddDict();
                dict.SetString("CFBundleTypeRole", "Editor");

                PlistElementArray schemes = dict.CreateArray("CFBundleURLSchemes");
                schemes.AddString("fb" + idFacebook);
            }

            // 权限
            {
                root.SetString("NSPhotoLibraryUsageDescription", "使用相册");
                root.SetString("NSCameraUsageDescription", "使用相机");
            }

            File.WriteAllText(path, doc.WriteToString());
        }
    private static void SetPListProperties(string pathToBuiltProject)
    {
        var plistPath = pathToBuiltProject + "/Info.plist";
        var plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));
        var rootDict = plist.root;

        foreach (TDNetwork network in TDNetwork.AllNetworks)
        {
            if (network.name == "AdColony" && network.iOSEnabled)
            {
                rootDict.SetString("NSMotionUsageDescription", "Some ad content may require access to accelerometer for interactive ad experience.");
                rootDict.SetString("NSPhotoLibraryUsageDescription", "Some ad content may require access to the photo library.");
                rootDict.SetString("NSCalendarsUsageDescription", "Some ad content may create a calendar event.");
                rootDict.SetString("NSCameraUsageDescription", "Some ad content may access camera to take picture.");
            }
        }

        var transportSecurityKey = "NSAppTransportSecurity";

        if (rootDict [transportSecurityKey] == null)
        {
            rootDict.CreateDict(transportSecurityKey);
        }

        var appTransportSecurity = rootDict [transportSecurityKey].AsDict();

        appTransportSecurity.SetBoolean("NSAllowsArbitraryLoads", true);

        if (TDSettings.getInstance().admob_appid_ios.Length > 0)
        {
            rootDict.SetString("GADApplicationIdentifier", TDSettings.getInstance().admob_appid_ios);
        }

        //SKAdNetworkIds
        List <TDKeyValuePair> skAdNetworkIds = TDSettings.getInstance().skAdNetworkIds;

        if (skAdNetworkIds.Count > 0)
        {
            PlistElementArray skAdNetworkItemsArray = rootDict.CreateArray("SKAdNetworkItems");
            foreach (TDKeyValuePair pair in skAdNetworkIds)
            {
                PlistElementDict itemDict = skAdNetworkItemsArray.AddDict();
                itemDict.SetString("SKAdNetworkIdentifier", pair.getValue());
            }
        }

        // Write to file
        File.WriteAllText(plistPath, plist.WriteToString());
    }
    private static void generatePlistFile(PlistElementDict rootDict, string path)
    {
        rootDict.SetString("CFBundleIdentifier", "com.gekko.rok");
        rootDict.SetString("CFBundleDisplayName", "Rage of Kings");
        //rootDict.SetString("CFBundleVersion", GetVer());
        rootDict.SetString("NSPhotoLibraryUsageDescription", "Use Photo");
        rootDict.SetString("NSCameraUsageDescription", "Use Camera");
        //rootDict.SetString("CFBundleShortVersionString", GKVersion.GAME_VERSION);
        rootDict.SetString("ITSAppUsesNonExemptEncryption", "false");
        rootDict.SetString("LSHasLocalizedDisplayName", "true");

        //weixin scheme
        PlistElementArray urlArray = null;

        if (!rootDict.values.ContainsKey("CFBundleURLTypes"))
        {
            urlArray = rootDict.CreateArray("CFBundleURLTypes");
        }
        else
        {
            urlArray = rootDict.values["CFBundleURLTypes"].AsArray();
        }
        var urlTypeDict = urlArray.AddDict();

        urlTypeDict.SetString("CFBundleURLName", "weixin");
        var urlScheme = urlTypeDict.CreateArray("CFBundleURLSchemes");

        urlScheme.AddString("weixin_id");

        if (!rootDict.values.ContainsKey("LSApplicationQueriesSchemes"))
        {
            urlArray = rootDict.CreateArray("LSApplicationQueriesSchemes");
        }
        else
        {
            urlArray = rootDict["LSApplicationQueriesSchemes"].AsArray();
        }
        urlArray.AddString("weixin");

        //Gamecenter
        if (rootDict.values.ContainsKey("UIRequiredDeviceCapabilities"))
        {
            rootDict.values.Remove("UIRequiredDeviceCapabilities");
        }
        var arr = rootDict.CreateArray("UIRequiredDeviceCapabilities");

        arr.AddString("armv7");
        arr.AddString("gamekit");
    }
示例#17
0
 //在info.plist中添加 URLSchemes
 private static void AddURLSchemes(MOBXCodeEditorModel xcodeModel,PlistElementDict plistElements)
 {
     ArrayList URLSchemes = xcodeModel.URLSchemes;
     PlistElementArray elementArray = plistElements.CreateArray ("CFBundleURLTypes");
     foreach (Hashtable scheme in URLSchemes)
     {
         PlistElementDict dict = elementArray.AddDict ();
         dict.SetString ("CFBundleURLName",(string)scheme["CFBundleURLName"]);
         PlistElementArray urlArray = dict.CreateArray ("CFBundleURLSchemes");
         ArrayList schemes = (ArrayList)scheme ["CFBundleURLSchemes"];
         foreach (string schemeStr in schemes)
         {
             urlArray.AddString (schemeStr);
         }
     }
 }
        public static void SetiOSUrlId(string urlId, PlistElementDict rootDict)
        {

            PlistElementArray urlTypesArray =
                rootDict["CFBundleURLTypes"] != null ? rootDict["CFBundleURLTypes"].AsArray()
                                                                                   : rootDict.CreateArray("CFBundleURLTypes");


            PlistElementDict urlTypes = urlTypesArray.AddDict();

            urlTypes.SetString("CFBundleTypeRole", "Editor");
            urlTypes.SetString("CFBundleURLName", urlId);

            PlistElementArray urlSchemes = urlTypes.CreateArray("CFBundleURLSchemes");
            urlSchemes.AddString(urlId);
		}
    public static void ModifyFrameworkAndInfoList(BuildTarget BuildTarget, string path)
    {
        if (BuildTarget == BuildTarget.iOS)
        {
            string     projPath = PBXProject.GetPBXProjectPath(path);
            PBXProject proj     = new PBXProject();

            proj.ReadFromString(File.ReadAllText(projPath));
            string xtarget = proj.TargetGuidByName("Unity-iPhone");

            // add extra framework(s)
            proj.AddFrameworkToProject(xtarget, "AssetsLibrary.framework", false);

            // set code sign identity & provisioning profile
            proj.SetBuildProperty(xtarget, "CODE_SIGN_IDENTITY", "iPhone Distribution: _______________");
            proj.SetBuildProperty(xtarget, "PROVISIONING_PROFILE", "********-****-****-****-************");

            // rewrite to file
            File.WriteAllText(projPath, proj.WriteToString());

            // 由于我的开发机是英文系统,但游戏需要设置为中文;
            // 需要在修改 Info.plist 中的 CFBundleDevelopmentRegion 字段为 zh_CN

            // Get plist
            string        plistPath = path + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            // Get root
            PlistElementDict rootDict = plist.root;

            // Change value of CFBundleDevelopmentRegion in Xcode plist
            rootDict.SetString("CFBundleDevelopmentRegion", "zh_CN");

            PlistElementArray urlTypes = rootDict.CreateArray("CFBundleURLTypes");

            // add weixin url scheme
            PlistElementDict wxUrl = urlTypes.AddDict();
            wxUrl.SetString("CFBundleTypeRole", "Editor");
            wxUrl.SetString("CFBundleURLName", "weixin");
            PlistElementArray wxUrlScheme = wxUrl.CreateArray("CFBundleURLSchemes");
            wxUrlScheme.AddString("____________");

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
    }
    private static void PostProcessBuild(string path)
    {
        #region pbxproj
        string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

        // PBXProject class represents a project build settings file,
        // here is how to read that in.
        PBXProject proj = new PBXProject();
        proj.ReadFromFile(projPath);

        // This is the Xcode target in the generated project
        string target = proj.TargetGuidByName("Unity-iPhone");

        // Write PBXProject object back to the file
        //proj.AddBuildProperty(target, "ENABLE_BITCODE", "NO");

        proj.AddFrameworkToProject(target, "VideoToolbox.framework", false);
        proj.AddFrameworkToProject(target, "libz.tbd", false);
        proj.AddFrameworkToProject(target, "libbz2.tbd", false);
        proj.AddFrameworkToProject(target, "libiconv.tbd", false);

        proj.WriteToFile(projPath);
        #endregion

#if PLIST_CHANGE
        #region info plist
        string plistPath = path + "/Info.plist";

        PlistDocument plist = new PlistDocument();
        plist.ReadFromFile(plistPath);
        #region QueriesSchemes
        PlistElementArray queriesSchemesArray = plist.root.CreateArray("LSApplicationQueriesSchemes");
        queriesSchemesArray.AddString("project");
        #endregion

        #region own URLScheme
        PlistElementArray urlTypesArray = plist.root.CreateArray("URL types");
        PlistElementDict  dict          = urlTypesArray.AddDict();
        dict.SetString("URL identifier", "com.compsany.project");
        PlistElementArray urlSchemesArray = dict.CreateArray("URL Schemes");
        urlSchemesArray.AddString("project");
        #endregion

        plist.WriteToFile(plistPath);
        #endregion
#endif
    }
        public static void SetApplicationQueriesSchemes(BuildTarget buildTarget, string pathToBuiltProject)
        {
            // This is needed only for iOS
            if (buildTarget == BuildTarget.iOS)
            {
                // Map application bundle IDs with URL schemes
                Dictionary <string, string> applicationBundlesMap = new Dictionary <string, string>();
                applicationBundlesMap.Add("com.poisins.App1", "cp.app1");
                applicationBundlesMap.Add("com.poisins.App2", "cp.app2");

                // Get plist
                string        plistPath = pathToBuiltProject + "/Info.plist";
                PlistDocument plist     = new PlistDocument();
                plist.ReadFromString(File.ReadAllText(plistPath));

                // Get root
                PlistElementDict rootDict = plist.root;

                // Set URL schemes app is able to respond
                PlistElementArray bundleUrlTypes   = rootDict.CreateArray("CFBundleURLTypes");       // create dictionary of Types
                PlistElementDict  urlTypesDict     = bundleUrlTypes.AddDict();
                PlistElementArray bundleUrlSchemes = urlTypesDict.CreateArray("CFBundleURLSchemes"); // create URL schemes in Types dictionary

                // Set URL schemes app is allowed to query
                PlistElementArray appQuerySchemes = rootDict.CreateArray("LSApplicationQueriesSchemes");

                // Process all schemes
                foreach (KeyValuePair <string, string> pair in applicationBundlesMap)
                {
                    // if current project, then add to CFBundleURLSchemes array
                    if (pair.Key == Application.bundleIdentifier)
                    {
                        bundleUrlSchemes.AddString(pair.Value);
                    }
                    //else LSApplicationQueriesSchemes array
                    else
                    {
                        appQuerySchemes.AddString(pair.Value);
                    }
                }

                // Write to file
                File.WriteAllText(plistPath, plist.WriteToString());
            }
        }
示例#22
0
        /// <summary>
        /// URLスキームを追加します
        /// </summary>
        /// <param name="path"> 出力先のパス </param>
        public static void AddIOSUrlScheme(string path)
        {
#if UNITY_IOS
            string        plistPath = Path.Combine(path, "Info.plist");
            PlistDocument plist     = new PlistDocument();

            // 読み込み
            plist.ReadFromFile(plistPath);

            PlistElementArray urlTypeArray   = plist.root.CreateArray("CFBundleURLTypes");
            PlistElementDict  urlTypeDict    = urlTypeArray.AddDict();
            PlistElementArray urlSchemeArray = urlTypeDict.CreateArray("CFBundleURLSchemes");

            SDKConfiguration sdkConfiguration = UrlSchemeEditTool.LoadSDKConfiguration();
            if (sdkConfiguration == null)
            {
                return;
            }

            var urlScheme = sdkConfiguration.IOSUrlScheme;
            var Validator = new UriSchemeValidator(urlScheme);
            if (!Validator.Validate())
            {
                Debug.LogError("iOSのURLスキーマが不正なのでURLスキーマの追加処理をスキップしました");
                return;
            }

            Uri uri;
            try
            {
                uri = new Uri(urlScheme);
            }
            catch (UriFormatException)
            {
                return;
            }

            // URLスキームを追加
            urlSchemeArray.AddString(uri.Scheme);

            // 書き込み
            plist.WriteToFile(plistPath);
#endif
        }
    public static void UpdateXCodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
                #if UNITY_IOS
        if (buildTarget == BuildTarget.iOS)
        {
            // Check Consumer Key
            if (string.IsNullOrEmpty(TwitterSettings.ConsumerKey))
            {
                TwitterKit.Internal.Utils.LogError(TwitterSettings.API_KEY_NOT_SET);
                return;
            }

            // Get plist
            string        plistPath = pathToBuiltProject + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            // Get root
            PlistElementDict rootDict = plist.root;

            // Modify Info.Plist for Twitter Kit (https://dev.twitter.com/twitterkit/ios/installation)
            PlistElementArray bundleURLTypesArray = rootDict[URL_TYPES] as PlistElementArray;
            if (bundleURLTypesArray == null)
            {
                bundleURLTypesArray = rootDict.CreateArray(URL_TYPES);
            }
            PlistElementDict  dict = bundleURLTypesArray.AddDict();
            PlistElementArray bundleURLSchemesArray = dict.CreateArray(URL_SCHEMES);
            bundleURLSchemesArray.AddString("twitterkit-" + TwitterSettings.ConsumerKey);
            PlistElementArray queriesSchemesArray = rootDict[APPLICATION_QUERIES_SCHEMES] as PlistElementArray;
            if (queriesSchemesArray == null)
            {
                queriesSchemesArray = rootDict.CreateArray(APPLICATION_QUERIES_SCHEMES);
            }
            queriesSchemesArray.AddString("twitter");
            queriesSchemesArray.AddString("twitterauth");

            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
                #endif
    }
示例#24
0
 private void AddArrayData(PlistElementArray elementArray, ICollection data)
 {
     foreach (var o in data)
     {
         if (o is ArrayList arrayList)
         {
             PlistElementArray array = elementArray.AddArray();
             AddArrayData(array, arrayList);
         }
         else if (o is IDictionary dictionary)
         {
             PlistElementDict dic = elementArray.AddDict();
             AddDictionaryData(dic, dictionary);
         }
         else
         {
             AddDataToArray(o, elementArray);
         }
     }
 }
    private static void AddSKAdNetworkIdentifier(PlistDocument document, List <string> skAdNetworkIds)
    {
        PlistElementArray array = GetSKAdNetworkItemsArray(document);

        if (array != null)
        {
            foreach (string id in skAdNetworkIds)
            {
                if (!ContainsSKAdNetworkIdentifier(array, id))
                {
                    PlistElementDict added = array.AddDict();
                    added.SetString(KEY_SK_ADNETWORK_ID, id);
                }
            }
        }
        else
        {
            NotifyBuildFailure("SKAdNetworkItems element already exists in Info.plist, but is not an array.", false);
        }
    }
示例#26
0
    public static void CreatePlist(TextureInfo[] texturesInfo, Rect[] rects, string plistOutPath)
    {
        var plist = new PlistDocument();

        plist.Create();
        PlistElementDict  rootDict   = plist.root;
        PlistElementArray plistArray = rootDict.CreateArray("texturesInfo");

        for (int i = 0; i < texturesInfo.Length; i++)
        {
            PlistElementDict dict = plistArray.AddDict();
            dict.SetString("name", texturesInfo[i].name);
            dict.SetInteger("x", (int)texturesInfo[i].x);
            dict.SetInteger("y", (int)texturesInfo[i].y);
            dict.SetInteger("width", (int)texturesInfo[i].width);
            dict.SetInteger("height", (int)texturesInfo[i].height);
        }
        File.WriteAllText(plistOutPath, plist.WriteToString());
        AssetDatabase.Refresh();
    }
示例#27
0
    public void OnPostprocessBuild(BuildTarget target, string path)
    {
        // iOS and OSX share same info.plist entries to support Custom URI Schemes
        if (target == BuildTarget.StandaloneOSX || target == BuildTarget.iOS)
        {
            Debug.Log("InfoPlistPostProcessBuild.OnPostprocessBuild for target " + target + " at path " + path);
            var plistPath = string.Empty;
            if (target == BuildTarget.StandaloneOSX)
            {
                plistPath = $"{path}/Contents/Info.plist";
            }
            if (target == BuildTarget.iOS)
            {
                plistPath = $"{path}/Info.plist";
            }

            if (File.Exists(plistPath))
            {
                var plistDocument = new PlistDocument();
                plistDocument.ReadFromFile(plistPath);
                var rootDict = plistDocument.root;
                if (!rootDict.values.ContainsKey("CFBundleURLTypes"))
                {
                    // Create Custom URI Scheme entry
                    var urlTypeArray  = new PlistElementArray();
                    var urlDict       = urlTypeArray.AddDict();
                    var urlBundleName = new PlistElementString("Unity Reflect");
                    urlDict.values.Add("CFBundleURLName", urlBundleName);
                    var urlBundleSchemes = new PlistElementArray();
                    urlBundleSchemes.AddString("reflect");
                    urlDict.values.Add("CFBundleURLSchemes", urlBundleSchemes);
                    rootDict.values.Add("CFBundleURLTypes", urlTypeArray);

                    // Write back our changes to Info.plist
                    File.WriteAllText(plistPath, plistDocument.WriteToString());
                }
            }
        }
    }
示例#28
0
    public static void OnPostprocessingBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
#if UNITY_IOS
            string     projPath = PBXProject.GetPBXProjectPath(path);
            PBXProject proj     = new PBXProject();
            proj.ReadFromFile(projPath);
            string target = proj.GetUnityMainTargetGuid();
            proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
            proj.AddFrameworkToProject(target, "StoreKit.framework", true);
            proj.AddFrameworkToProject(target, "AdSupport.framework", true);
            proj.AddCapability(target, PBXCapabilityType.InAppPurchase, null, true);
            //proj.AddCapability(target, PBXCapabilityType.ApplePay, entitlementsFilePath, true);
            proj.WriteToFile(projPath);

            // 修改Info.plist文件
            string        plistPath = Path.Combine(path, "Info.plist");
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromFile(plistPath);
            PlistElementDict dict = plist.root.CreateDict("NSAppTransportSecurity");
            dict.SetBoolean("NSAllowsArbitraryLoads", true);

            plist.root.SetString("GADApplicationIdentifier", "ca-app-pub-3041081834653045~6836057851");
            plist.root.SetBoolean("GADIsAdManagerApp", true);
            plist.root.SetBoolean("ITSAppUsesNonExemptEncryption", false);
            plist.root.SetString("FirebaseMessagingAutoInitEnabled", "NO");
            //IronSource需求
            PlistElementArray a = plist.root.CreateArray("SKAdNetworkItems");
            PlistElementDict  b = a.AddDict();
            b.SetString("SKAdNetworkIdentifier", "SU67R6K2V3.skadnetwork");


            plist.WriteToFile(plistPath);
            Debug.Log("post build ios success");
#endif
        }
    }
示例#29
0
        // Takes the build path where Info.plist is located
        // and a Dictionary<string, PlistElementDict> (kitsInfo) where
        // key: the KitName and
        // value: a PlistElementDict containing the KitInfo
        protected static void AddFabricKitsToPlist(string buildPath, Dictionary <string, PlistElementDict> kitsInfo)
        {
            Utils.Log("Preparing Info.plist");

            //Settings settings = Settings.Instance;
            string plistPath = Path.Combine(buildPath, "Info.plist");

            PlistDocument plist = new PlistDocument();

            plist.ReadFromFile(plistPath);

            PlistElementDict rootDict = plist.root.AsDict();
            PlistElementDict fabricEl = (PlistElementDict)rootDict["Fabric"];

            if (fabricEl == null)
            {
                fabricEl = plist.root.CreateDict("Fabric");
            }
            fabricEl.SetString("APIKey", FabricManager.ApiKey);

            PlistElementArray fabricKits = (PlistElementArray)fabricEl["Kits"];

            if (fabricKits == null)
            {
                fabricKits = fabricEl.CreateArray("Kits");
            }

            foreach (KeyValuePair <string, PlistElementDict> entry in kitsInfo)
            {
                Utils.Log("Adding kit {0} to Info.plist", entry.Key);

                PlistElementDict kitDict = fabricKits.AddDict();
                kitDict.SetString("KitName", entry.Key);
                kitDict["KitInfo"] = entry.Value;
            }

            plist.WriteToFile(plistPath);
        }
示例#30
0
 private static void AddConfig(PlistElementArray ary, List <object> values)
 {
     foreach (var v in values)
     {
         if (v is int)
         {
             ary.AddInteger((int)v);
         }
         else if (v is string)
         {
             ary.AddString((string)v);
         }
         else if (v is bool)
         {
             ary.AddBoolean((bool)v);
         }
         else if (v is Dictionary <string, object> )
         {
             var parent = ary.AddDict();
             AddConfig(parent, (Dictionary <string, object>)v);
         }
     }
 }