コード例 #1
0
        static void AddLanguage(string path, params string[] languages)
        {
            var plistPath = Path.Combine (path, "Info.plist");
            var plist = new PlistDocument ();

            plist.ReadFromFile (plistPath);

            var localizationKey = "CFBundleLocalizations";

            var localizations = plist.root.values
            .Where (kv => kv.Key == localizationKey)
            .Select (kv => kv.Value)
            .Cast<PlistElementArray> ()
            .FirstOrDefault ();

            if (localizations == null)
                localizations = plist.root.CreateArray (localizationKey);

            foreach (var language in languages) {
                if (localizations.values.Select (el => el.AsString ()).Contains (language) == false)
                    localizations.AddString (language);
            }

            plist.WriteToFile (plistPath);
        }
コード例 #2
0
    [PostProcessBuildAttribute(0)] // Configures this this post process to run first
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
#if UNITY_IOS
        var infoPlist     = new UnityEditor.iOS.Xcode.PlistDocument();
        var infoPlistPath = pathToBuiltProject + "/Info.plist";
        infoPlist.ReadFromFile(infoPlistPath);

        // Register ios URL scheme for external apps to launch this app.
        var urlTypeDict = infoPlist.root.CreateArray("CFBundleURLTypes").AddDict();
        urlTypeDict.SetString("CFBundleURLName", "org.identitymodel.unityclient");
        var urlSchemes = urlTypeDict.CreateArray("CFBundleURLSchemes");
        urlSchemes.AddString("io.identitymodel.native");

        infoPlist.WriteToFile(infoPlistPath);
#endif
    }
コード例 #3
0
        private PlistDocument GetOrCreateInfoDoc()
        {
            if (m_InfoPlist == null)
            {
                m_InfoPlist = new PlistDocument();
                string[] infoFiles = Directory.GetFiles(m_BuildPath + "/", "Info.plist");
                if (infoFiles.Length > 0)
                {
                    m_InfoPlist.ReadFromFile(infoFiles[0]);
                }
                else
                {
                    m_InfoPlist.Create();
                }
            }

            return(m_InfoPlist);
        }
コード例 #4
0
        private PlistDocument GetOrCreateEntitlementDoc()
        {
            if (m_Entitlements == null)
            {
                m_Entitlements = new PlistDocument();
                string[] entitlementsFiles = Directory.GetFiles(m_BuildPath, m_EntitlementFilePath);
                if (entitlementsFiles.Length > 0)
                {
                    m_Entitlements.ReadFromFile(entitlementsFiles[0]);
                }
                else
                {
                    m_Entitlements.Create();
                }
            }

            return(m_Entitlements);
        }
コード例 #5
0
        static void AddPermissions(string path , params KeyValuePair<string,string>[] permissions)
        {
            var plistPath = Path.Combine (path, "Info.plist");
            var plist = new PlistDocument ();

            plist.ReadFromFile (plistPath);
            foreach(var permission in permissions){

                var count = plist.root.values
                    .Where (kv => kv.Key == permission.Key)
                    .Select (kv => kv.Value)
                    .Count();

                if(count == 0){
                    plist.root.SetString(permission.Key,permission.Value);
                }
            }

            plist.WriteToFile (plistPath);
        }
コード例 #6
0
    //info.plistを取得
    private static PlistDocument GetInfoPlist(string buildPath)
    {
        string plistPath = GetInfoPlistPath(buildPath);
        PlistDocument plist = new PlistDocument();
        plist.ReadFromFile(plistPath);

        return plist;
    }
コード例 #7
0
ファイル: Builder.cs プロジェクト: DengWang/Unity_RongCloud
	public static void OnPostProcessBuild (BuildTarget buildTarget, string path)
	{
		#if UNITY_ANDROID

		#elif UNITY_IPHONE
		string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
		PBXProject pbxProj = new PBXProject ();
		pbxProj.ReadFromFile (projPath);
		string target = pbxProj.TargetGuidByName (PBXProject.GetUnityTargetName ());

		pbxProj.AddFrameworkToProject (target, "AssetsLibrary.framework", false);
		pbxProj.AddFrameworkToProject (target, "AudioToolbox.framework", false);
		pbxProj.AddFrameworkToProject (target, "AVFoundation.framework", false);
		pbxProj.AddFrameworkToProject (target, "CFNetwork.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreAudio.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreLocation.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreMedia.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreTelephony.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreVideo.framework", false);
		pbxProj.AddFrameworkToProject (target, "CoreGraphics.framework", false);
		pbxProj.AddFrameworkToProject (target, "ImageIO.framework", false);

		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libc++.dylib", "Frameworks/libc++.dylib", PBXSourceTree.Sdk));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libc++abi.dylib", "Frameworks/libc++abi.dylib", PBXSourceTree.Sdk));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libsqlite3.dylib", "Frameworks/libsqlite3.dylib", PBXSourceTree.Sdk));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libstdc++.dylib", "Frameworks/libstdc++.dylib", PBXSourceTree.Sdk));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libxml2.dylib", "Frameworks/libxml2.dylib", PBXSourceTree.Sdk));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libz.dylib", "Frameworks/libz.dylib", PBXSourceTree.Sdk));

		pbxProj.AddFrameworkToProject (target, "MapKit.framework", false);
		pbxProj.AddFrameworkToProject (target, "OpenGLES.framework", false);
		pbxProj.AddFrameworkToProject (target, "QuartzCore.framework", false);
		pbxProj.AddFrameworkToProject (target, "SystemConfiguration.framework", false);
		pbxProj.AddFrameworkToProject (target, "UIKit.framework", false);

		DirectoryInfo di = new DirectoryInfo (Application.dataPath);
		string rongCloudLibFloder = Path.Combine (di.Parent.FullName, "RongCloudLib");




		CopyAndReplaceDirectory(Path.Combine (rongCloudLibFloder, "RongIMLib.framework"), Path.Combine(path, "Frameworks/RongIMLib.framework"));
		pbxProj.AddFileToBuild(target, pbxProj.AddFile("Frameworks/RongIMLib.framework", "Frameworks/RongIMLib.framework", PBXSourceTree.Source));


//		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (rongCloudLibFloder, "RongIMLib.framework"), "Frameworks/RongIMLib.framework", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/RongCloudBinding.m"), "Libraries/RongCloudBinding.m", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/RongCloudManager.m"), "Libraries/RongCloudManager.m", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/RongCloudManager.h"), "Libraries/RongCloudManager.h", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupOperationMessage.h"), "Libraries/GroupOperationMessage.h", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupOperationMessage.m"), "Libraries/GroupOperationMessage.m", PBXSourceTree.Absolute));

		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupRequestMessage.h"), "Libraries/GroupRequestMessage.h", PBXSourceTree.Absolute));
		pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupRequestMessage.m"), "Libraries/GroupRequestMessage.m", PBXSourceTree.Absolute));



		pbxProj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)");
		pbxProj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks");

		pbxProj.WriteToFile (projPath);
		PlistDocument plist = new PlistDocument ();
		string plistPath = Path.Combine (path, "Info.plist");
		plist.ReadFromFile (plistPath);
		var deviceCapabilities = plist.root ["UIRequiredDeviceCapabilities"].AsArray ();
		deviceCapabilities.AddString ("front-facing-camera");
		deviceCapabilities.AddString ("video-camera");
//		plist.root.SetBoolean ("LSHasLocalizedDisplayName", true);

		plist.WriteToFile (plistPath);
		#endif

	}
コード例 #8
0
	public static void PatchInfoPlist(string pathToBuiltProject)
	{
		string plistPath = Path.Combine(pathToBuiltProject, "Info.plist");
		
		PlistDocument plist = new PlistDocument();
		plist.ReadFromFile(plistPath);
		
		
		// =================================
		// We must do this here instead of passing the plist to
		//  a useful helper function because Unity refuses to build functions
		//  where a variable of type PlistDocument is passed.
		
		string key = "UISupportedExternalAccessoryProtocols";
		string[] values = new string[3]
		{
			"io.structure.control",
			"io.structure.depth",
			"io.structure.infrared"
		};
		
		if (plist.root.values.ContainsKey(key))
			return;
		
		PlistElementArray array = new PlistElementArray();
		foreach (string value in values)
			array.AddString(value);
		
		plist.root.values.Add (new PlistEntry(key, array));
		// =================================
		
		
		plist.root.values.Add( new PlistEntry("UIFileSharingEnabled", new PlistElementBoolean(true) ) );
		
		
		plist.WriteToFile(plistPath);
	}
コード例 #9
0
    static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget != BuildTarget.iOS) return;

        /*------------------------------------------------------*/
        // for frameworks

        string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
        Debug.Log("Build iOS. path: " + projPath);

        PBXProject proj = new PBXProject();
        proj.ReadFromString(File.ReadAllText(projPath));

        string target = proj.TargetGuidByName("Unity-iPhone");
        //		string debugConfig = proj.BuildConfigByName(target, "Debug");
        //		string releaseConfig = proj.BuildConfigByName(target, "Release");

        // Add custom system frameworks. Duplicate frameworks are ignored.
        // needed by our native plugin in Assets/Plugins/iOS
        //		proj.AddFrameworkToProject(target, ".framework", false /*not weak*/);

        // Add usr/lib
        string framenwork1 = "libz.dylib";
        string framenwork2 = "libsqlite3.0.dylib";
        string fileGuid1 = proj.AddFile ("usr/lib/"+framenwork1, "Frameworks/"+framenwork1, PBXSourceTree.Sdk);
        string fileGuid2 = proj.AddFile ("usr/lib/"+framenwork2, "Frameworks/"+framenwork2, PBXSourceTree.Sdk);
        proj.AddFileToBuild (target, fileGuid1);
        proj.AddFileToBuild (target, fileGuid2);

        // Add our framework directory to the framework include path
        proj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)");
        proj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks");
        //		proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
        proj.AddBuildProperty(target, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");

        File.WriteAllText(projPath, proj.WriteToString());

        /*------------------------------------------------------*/
        // for Info.plist

        // PlistDocument
        // http://docs.unity3d.com/ScriptReference/iOS.Xcode.PlistDocument.html

        // Get plist
        var plistPath = Path.Combine(path, "Info.plist");
        var plist = new PlistDocument();
        plist.ReadFromFile(plistPath);

        // Get root
        PlistElementDict rootDict = plist.root;

        // Create URL types
        string identifier = PlayerPrefs.GetString ("identifier");
        string scheme = PlayerPrefs.GetString ("scheme");

        PlistElementArray urlTypesArray = rootDict.CreateArray ("CFBundleURLTypes");
        PlistElementDict dict = urlTypesArray.AddDict ();
        dict.SetString ("CFBundleURLName", identifier);
        PlistElementArray schemesArray = dict.CreateArray ("CFBundleURLSchemes");
        schemesArray.AddString (scheme);

        //		PlistElementArray urlTypesArray = rootDict.CreateArray ("CFBundleURLTypes");
        //		PlistElementDict dict = urlTypesArray.AddDict ();
        //		dict.SetString ("CFBundleURLName", "com.unitybuild.test");
        //		PlistElementArray schemesArray = dict.CreateArray ("CFBundleURLSchemes");
        //		schemesArray.AddString ("myscheme");

        // Write to file
        File.WriteAllText(plistPath, plist.WriteToString());
    }