internal static void ReadConfigInternal(bool errorOnNoConfig, string filename = null)
        {
            XcodeProjectPatcher.configValues = new Dictionary <string, string>();
            XcodeProjectPatcher.configFile   = (filename ?? XcodeProjectPatcher.FindConfig(errorOnNoConfig));
            if (XcodeProjectPatcher.configFile == null)
            {
                return;
            }
            PlistDocument plistDocument = new PlistDocument();

            plistDocument.ReadFromString(File.ReadAllText(XcodeProjectPatcher.configFile));
            PlistElementDict root = plistDocument.root;

            string[] pROJECT_KEYS = XcodeProjectPatcher.PROJECT_KEYS;
            for (int i = 0; i < pROJECT_KEYS.Length; i++)
            {
                string       text         = pROJECT_KEYS[i];
                PlistElement plistElement = root[text];
                if (plistElement != null)
                {
                    XcodeProjectPatcher.configValues[text] = plistElement.AsString();
                    if (object.Equals(text, "BUNDLE_ID"))
                    {
                        XcodeProjectPatcher.allBundleIds.Add(plistElement.AsString());
                    }
                }
            }
        }
Exemple #2
0
        public static void OnPostprocessBuild(BuildTarget buildTarget, string buildPath)
        {
            if (buildTarget != BuildTarget.iOS)
            {
                return;
            }

            PrepareProject(buildPath);

            // Make sure that the proper location usage string is in Info.plist

            const string locationKey = "NSLocationWhenInUseUsageDescription";

            var plistPath = Path.Combine(buildPath, "Info.plist");
            var plist     = new PlistDocument();

            plist.ReadFromFile(plistPath);
            PlistElement element = plist.root[locationKey];
            var          usage   = MoPubConsent.LocationAwarenessUsageDescription;

            // Add or overwrite the key in the info.plist file if necessary.
            // (Note:  does not overwrite if the string has been manually changed in the Xcode project and our string is just the default.)
            if (element == null || usage != element.AsString() && usage != MoPubConsent.DefaultLocationAwarenessUsage)
            {
                plist.root.SetString(locationKey, usage);
                plist.WriteToFile(plistPath);
            }
        }