AddFrameworkToProject() 공개 메소드

public AddFrameworkToProject ( string targetGuid, string framework, bool weak ) : void
targetGuid string
framework string
weak bool
리턴 void
예제 #1
1
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            string projPath = PBXProject.GetPBXProjectPath(path);
            PBXProject proj = new PBXProject();

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

            // システムのフレームワークを追加
            proj.AddFrameworkToProject(target, "AssetsLibrary.framework", false);

            // 自前のフレームワークを追加
            CopyAndReplaceDirectory("Assets/Lib/mylib.framework", Path.Combine(path, "Frameworks/mylib.framework"));
            proj.AddFileToBuild(target, proj.AddFile("Frameworks/mylib.framework", "Frameworks/mylib.framework", PBXSourceTree.Source));

            // ファイルを追加
            var fileName = "my_file.xml";
            var filePath = Path.Combine("Assets/Lib", fileName);
            File.Copy(filePath, Path.Combine(path, fileName));
            proj.AddFileToBuild(target, proj.AddFile(fileName, fileName, PBXSourceTree.Source));

            // Yosemiteでipaが書き出せないエラーに対応するための設定
            proj.SetBuildProperty(target, "CODE_SIGN_RESOURCE_RULES_PATH", "$(SDKROOT)/ResourceRules.plist");

            // フレームワークの検索パスを設定・追加
            proj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)");
            proj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks");

            // 書き出し
            File.WriteAllText(projPath, proj.WriteToString());
        }
    }
예제 #2
0
    public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
    {
        Debug.LogWarning("IphoneX Fiter");
        if (target != BuildTarget.iOS)
        {
            Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
            return;
        }
        // Create a new project object from build target
        UnityEditor.iOS.Xcode.PBXProject project = new UnityEditor.iOS.Xcode.PBXProject();
        string configFilePath = UnityEditor.iOS.Xcode.PBXProject.GetPBXProjectPath(pathToBuiltProject);

        project.ReadFromFile(configFilePath);
        string targetGuid = project.TargetGuidByName("Unity-iPhone");
        string debug      = project.BuildConfigByName(targetGuid, "Debug");
        string release    = project.BuildConfigByName(targetGuid, "Release");

        project.AddBuildPropertyForConfig(debug, "CODE_SIGN_RESOURCE_RULES_PATH", "$(SDKROOT)/ResourceRules.plist");
        project.AddBuildPropertyForConfig(release, "CODE_SIGN_RESOURCE_RULES_PATH", "$(SDKROOT)/ResourceRules.plist");

        project.AddFrameworkToProject(targetGuid, "SystemConfiguration.framework", true);
        project.AddFrameworkToProject(targetGuid, "Security.framework", true);
        project.AddFrameworkToProject(targetGuid, "libz.tbd", true);
        project.AddFrameworkToProject(targetGuid, "libc++.tbd", true);

        project.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");

        project.WriteToFile(configFilePath);

        EditSuitIpXCode(pathToBuiltProject);
    }
 private static void EditXcodeProject(string buildFolder)
 {
     PBXProject project = new PBXProject();
     string path = Path.Combine(buildFolder, FileUtil.NiceWinPath("Unity-iPhone.xcodeproj/project.pbxproj"));
     project.ReadFromFile(path);
     string targetGuid = project.TargetGuidByName(PBXProject.GetUnityTargetName());
     if (AdvertisementSettings.enabled && AdvertisementSettings.IsPlatformEnabled(RuntimePlatform.IPhonePlayer))
     {
         string target = Path.Combine(buildFolder, Path.Combine("UnityAds", "UnityAds.framework"));
         FileUtil.CopyDirectoryRecursive(Path.Combine(extensionPath, FileUtil.NiceWinPath("Editor/Resources/iOS/builds/UnityAds.framework")), target, true);
         project.AddFileToBuild(targetGuid, project.AddFile(Path.Combine("UnityAds", "UnityAds.framework"), "Frameworks/UnityAds.framework", PBXSourceTree.Source));
         project.AddBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", "$(SRCROOT)/UnityAds");
         project.AddFrameworkToProject(targetGuid, "AdSupport.framework", true);
         project.AddFrameworkToProject(targetGuid, "StoreKit.framework", false);
         project.AddFrameworkToProject(targetGuid, "CoreTelephony.framework", false);
     }
     else
     {
         project.RemoveFile(project.FindFileGuidByRealPath(Path.Combine("UnityAds", "UnityAds.framework")));
         string[] removeValues = new string[] { "$(SRCROOT)/UnityAds" };
         project.UpdateBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", null, removeValues);
         string str5 = Path.Combine(buildFolder, "UnityAds");
         if (Directory.Exists(str5))
         {
             Directory.Delete(str5, true);
         }
     }
     project.AddFileToBuild(targetGuid, project.AddFile("UnityAdsConfig.h", "Classes/UnityAds/UnityAdsConfig.h"));
     project.WriteToFile(path);
 }
	public static void OnPostProcessBuild(BuildTarget target, string path)
	{

		if (target == BuildTarget.iOS)
		{
			// Get target for Xcode project
			string projPath = PBXProject.GetPBXProjectPath(path);
			PBXProject proj = new PBXProject();
			proj.ReadFromString(File.ReadAllText(projPath));

			string targetName = PBXProject.GetUnityTargetName();
			string projectTarget = proj.TargetGuidByName(targetName);

			// Add dependencies
			proj.AddFrameworkToProject(projectTarget, "AssetsLibrary.framework", false);
			proj.AddFrameworkToProject(projectTarget, "CoreText.framework", false);
			proj.AddFrameworkToProject(projectTarget, "MobileCoreServices.framework", false);
			proj.AddFrameworkToProject(projectTarget, "QuickLook.framework", false);
			proj.AddFrameworkToProject(projectTarget, "Security.framework", false);

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

			InsertAuthCodeIntoControllerClass(path);
			InsertUILoadedCallbackIntoControllerClass(path);
		}
	}
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        #if UNITY_5
        var expectedTarget = BuildTarget.iOS;
        #else
        var expectedTarget = BuildTarget.iPhone;
        #endif
        if (buildTarget == expectedTarget) {
            var projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            var project = new PBXProject();
            project.ReadFromString(File.ReadAllText(projectPath));

            var target = project.TargetGuidByName("Unity-iPhone");

            foreach (var frameworkName in StrongFrameworks) {
                project.AddFrameworkToProject(target, frameworkName + ".framework", false);
            }
            foreach (var frameworkName in WeakFrameworks) {
                project.AddFrameworkToProject(target, frameworkName + ".framework", true);
            }
            foreach (var flag in LDFlags) {
                project.AddBuildProperty(target, "OTHER_LDFLAGS", flag);
            }
            foreach (var libraryName in Libraries) {
                project.AddBuildProperty(target, "OTHER_LDFLAGS", "-l" + libraryName);
            }

            File.WriteAllText(projectPath, project.WriteToString());
        }
    }
예제 #6
0
    private static void PostProcessIosBuild(string pathToBuiltProject)
    {
        UnityEditor.iOS.Xcode.PBXProject project = new UnityEditor.iOS.Xcode.PBXProject();
        string pbxPath = UnityEditor.iOS.Xcode.PBXProject.GetPBXProjectPath(pathToBuiltProject);

        project.ReadFromFile(pbxPath);

#if UNITY_2019_3_OR_NEWER
        string targetId = project.GetUnityFrameworkTargetGuid();
#else
        string targetId = project.TargetGuidByName(UnityEditor.iOS.Xcode.PBXProject.GetUnityTargetName());
#endif

        project.AddFrameworkToProject(targetId, "AdSupport.framework", false);
        project.AddFrameworkToProject(targetId, "CoreTelephony.framework", false);
        project.AddFrameworkToProject(targetId, "StoreKit.framework", false);
        project.AddFrameworkToProject(targetId, "WebKit.framework", false);

        project.AddFileToBuild(targetId, project.AddFile("usr/lib/libsqlite3.dylib", "Frameworks/libsqlite3.dylib", UnityEditor.iOS.Xcode.PBXSourceTree.Sdk));
        project.AddFileToBuild(targetId, project.AddFile("usr/lib/libz.1.1.3.dylib", "Frameworks/libz.1.1.3.dylib", UnityEditor.iOS.Xcode.PBXSourceTree.Sdk));

        project.AddBuildProperty(targetId, "OTHER_LDFLAGS", "-ObjC");

        project.WriteToFile(pbxPath);

        Debug.Log("Vungle iOS post processor completed.");
    }
    private static void AddGrowthbeatDependencyFramework(string path)
    {
        string projectPath = PBXProject.GetPBXProjectPath(path);
        PBXProject pbxProject = new PBXProject();

        pbxProject.ReadFromString(File.ReadAllText(projectPath));
        string target = pbxProject.TargetGuidByName("Unity-iPhone");

        pbxProject.AddFrameworkToProject(target, "AdSupport.framework", false);
        pbxProject.AddFrameworkToProject(target, "SafariServices.framework", false);
        pbxProject.AddFrameworkToProject(target, "Security.framework", false);

        File.WriteAllText(projectPath, pbxProject.WriteToString());
    }
	private static void onPostProcessBuildPlayer(BuildTarget target, string pathToBuiltProject) {
#if UNITY_4_X
		if (target == BuildTarget.iPhone) {
#else
		if (target == BuildTarget.iOS) {
#endif

#if UNITY_EDITOR_OSX
			UnityEngine.Debug.Log ("Path to built project: " + pathToBuiltProject);

			string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
			UnityEngine.Debug.Log ("Project Path: " + projPath);

			PBXProject proj = new PBXProject();
			proj.ReadFromString(File.ReadAllText(projPath));
			string projTarget = proj.TargetGuidByName("Unity-iPhone");
			UnityEngine.Debug.Log ("Project Target: " + projTarget);

			proj.AddFrameworkToProject(projTarget, "Security.framework", false);
			proj.AddBuildProperty(projTarget, "OTHER_LDFLAGS", "-ObjC -lz -lstdc++");

			File.WriteAllText(projPath, proj.WriteToString());
#endif
		}
		
		if (target == BuildTarget.WP8Player) {
			postProcessWP8Build(pathToBuiltProject);
		}
	}
예제 #9
0
    private static void OnPostprocessBuildIOS(string pathToBuiltProject)
    {
        // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module
                #if UNITY_IOS
        string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";

        UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject();
        proj.ReadFromString(File.ReadAllText(projPath));
        proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "ARKit.framework", false);
        string target = proj.TargetGuidByName("Unity-iPhone");
        proj.SetBuildProperty(target, "DEVELOPMENT_TEAM", "Z6SFPV59E3");
        Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Unity"));

        string[] filesToCopy = new string[]
        {
        };

        for (int i = 0; i < filesToCopy.Length; ++i)
        {
            var srcPath      = Path.Combine("../PluginSource/source", filesToCopy[i]);
            var dstLocalPath = "Libraries/" + filesToCopy[i];
            var dstPath      = Path.Combine(pathToBuiltProject, dstLocalPath);
            File.Copy(srcPath, dstPath, true);
            proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath));
        }

        File.WriteAllText(projPath, proj.WriteToString());
                #endif // #if UNITY_IOS
    }
예제 #10
0
    private static void OnPostprocessBuildIOS(string pathToBuiltProject)
    {
        // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module
#if UNITY_IOS
        //Handle plist
        string        plistPath = pathToBuiltProject + "/Info.plist";
        PlistDocument plist     = new PlistDocument();
        plist.ReadFromString(File.ReadAllText(plistPath));
        PlistElementDict rootDict = plist.root;

        rootDict.SetString("CFBundleVersion", "1.0.67");
        rootDict.SetString("NSPhotoLibraryUsageDescription", "Use Photo");
        rootDict.SetString("NSPhotoLibraryAddUsageDescription", "Use Photo 11");
        rootDict.SetString("NSCameraUsageDescription", "Use Camera");

        File.WriteAllText(plistPath, plist.WriteToString());

        string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";

        UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject();
        proj.ReadFromString(File.ReadAllText(projPath));
        proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "CoreImage.framework", false);
        proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "Accelerate.framework", false);
        string target = proj.TargetGuidByName("Unity-iPhone");
        Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Unity"));

        string[] filesToCopy = new string[]
        {
        };

        for (int i = 0; i < filesToCopy.Length; ++i)
        {
            var srcPath      = Path.Combine("../PluginSource/source", filesToCopy[i]);
            var dstLocalPath = "Libraries/" + filesToCopy[i];
            var dstPath      = Path.Combine(pathToBuiltProject, dstLocalPath);
            File.Copy(srcPath, dstPath, true);
            proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath));
        }

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

        CopyFile("GestureFile/libpaddle_capi_layers.a", "libpaddle_capi_layers.a", pathToBuiltProject);
        CopyFile("pose/pose.bin", "pose.bin", pathToBuiltProject);
        //  CopyFile("pose/opencv2.framework.zip", "opencv2.framework.zip", pathToBuiltProject);
        // CopyFile("IOS_Pose/libpaddle_capi_layers.a" ,pathToBuiltProject);
#endif
    }
    private static void OnPostprocessBuildIOS(string pathToBuiltProject)
    {
        // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module
                #if UNITY_IOS
        string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";

        UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject();
        proj.ReadFromString(File.ReadAllText(projPath));
        proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "ARKit.framework", false);
        string target = proj.TargetGuidByName("Unity-iPhone");
        Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Unity"));

        //check UnityARKitPluginSettings
        UnityARKitPluginSettings ps = LoadSettings();
        if (ps.AppRequiresARKit)
        {
            //add plist entry
            string        plistPath = Path.Combine(pathToBuiltProject, "Info.plist");
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            PlistElementDict rootDict = plist.root;

            const string      capsKey = "UIRequiredDeviceCapabilities";
            PlistElementArray capsArray;
            PlistElement      pel;
            if (rootDict.values.TryGetValue(capsKey, out pel))
            {
                capsArray = pel.AsArray();
            }
            else
            {
                capsArray = rootDict.CreateArray(capsKey);
            }
            capsArray.AddString("arkit");
            File.WriteAllText(plistPath, plist.WriteToString());
        }

        //add or replace define for facetracking
        UpdateDefinesInFile(pathToBuiltProject + "/Classes/Preprocessor.h", new Dictionary <string, bool>()
        {
            { "ARKIT_USES_FACETRACKING", ps.m_ARKitUsesFacetracking }
        });

        string[] filesToCopy = new string[]
        {
        };

        for (int i = 0; i < filesToCopy.Length; ++i)
        {
            var srcPath      = Path.Combine("../PluginSource/source", filesToCopy[i]);
            var dstLocalPath = "Libraries/" + filesToCopy[i];
            var dstPath      = Path.Combine(pathToBuiltProject, dstLocalPath);
            File.Copy(srcPath, dstPath, true);
            proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath));
        }

        File.WriteAllText(projPath, proj.WriteToString());
                #endif // #if UNITY_IOS
    }
    public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuiltProject) {
      if (buildTarget != BuildTarget.iOS) {
        return;
      }

      PBXProject project = new PBXProject();
      string pbxProjectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
      project.ReadFromString(File.ReadAllText(pbxProjectPath));

      string target = project.TargetGuidByName(PBXProject.GetUnityTargetName());
      string testTarget = project.TargetGuidByName(PBXProject.GetUnityTestTargetName());

      // Linker flags.
      project.SetBuildProperty(target, "ARCHS", "$(ARCHS_STANDARD)");
      project.SetBuildProperty(testTarget, "ARCHS", "$(ARCHS_STANDARD)");
      project.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
      project.AddBuildProperty(testTarget, "OTHER_LDFLAGS", "-ObjC");
      project.AddBuildProperty(target, "OTHER_LDFLAGS", "-lz");
      project.AddBuildProperty(testTarget, "OTHER_LDFLAGS", "-lz");

      // Search paths.
      project.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)");
      project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks");

      // Framework dependencies.
      project.AddFrameworkToProject(target, "AVFoundation.framework", true);
      project.AddFrameworkToProject(target, "Accelerate.framework", true);
      project.AddFrameworkToProject(target, "CFNetwork.framework", true);
      project.AddFrameworkToProject(target, "CoreBluetooth.framework", true);
      project.AddFrameworkToProject(target, "CoreText.framework", true);
      project.AddFrameworkToProject(target, "MediaPlayer.framework", true);
      project.AddFrameworkToProject(target, "MediaToolbox.framework", true);
      project.AddFrameworkToProject(target, "Metal.framework", true);
      project.AddFrameworkToProject(target, "Security.framework", true);
      project.AddFrameworkToProject(target, "SystemConfiguration.framework", true);

      // Dynamic library dependencies.
      string sqlite3dylibGuid = project.AddFile("usr/lib/libsqlite3.dylib",
                                                "usr/lib/libsqlite3.dylib", PBXSourceTree.Sdk);
      project.AddFileToBuild(target, sqlite3dylibGuid);
      string libCppdylibGuid = project.AddFile("usr/lib/libc++.dylib",
                                               "usr/lib/libc++.dylib", PBXSourceTree.Sdk);
      project.AddFileToBuild(target, libCppdylibGuid);

      File.WriteAllText(pbxProjectPath, project.WriteToString());
    }
예제 #13
0
    //设置Capabilities
    void SetCapabilities(string pathToBuildProject)
    {
        string projPath = pathToBuildProject + "/Unity-iPhone.xcodeproj/project.pbxproj";  //项目路径,这个路径在mac上默认是不显示的,需要右键->显示包内容才能看到。unity到处的名字就是这个。

        UnityEditor.iOS.Xcode.PBXProject pbxProj = new UnityEditor.iOS.Xcode.PBXProject(); //创建xcode project类
        pbxProj.ReadFromString(File.ReadAllText(projPath));                                //xcode project读入
        string targetGuid = pbxProj.TargetGuidByName(PBXProject.GetUnityTargetName());     //获得Target名

        //设置BuildSetting
        pbxProj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
        pbxProj.AddBuildProperty(targetGuid, "OTHER_LDFLAGS", "-ObjC");
        pbxProj.SetBuildProperty(targetGuid, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym"); //定位崩溃bug
        pbxProj.SetBuildProperty(targetGuid, "EXCLUDED_ARCHS", "armv7");

        pbxProj.AddFrameworkToProject(targetGuid, "MediaPlayer.framework", false);
        pbxProj.AddFrameworkToProject(targetGuid, "AdSupport.framework", true);
        //添加资源
        pbxProj.AddFileToBuild(targetGuid, pbxProj.AddFile(System.Environment.CurrentDirectory + "/LTBaseSDK_Oversea/ltgame.cfg", "Resource/ltgame.cfg", PBXSourceTree.Source));

        //修改编译方式
        string mmfile = pbxProj.FindFileGuidByProjectPath("Classes/UnityAppController.mm");
        var    flags  = pbxProj.GetCompileFlagsForFile(targetGuid, mmfile);

        flags.Add("-fno-objc-arc");
        pbxProj.SetCompileFlagsForFile(targetGuid, mmfile, flags);
        mmfile = pbxProj.FindFileGuidByProjectPath("Libraries/Plugins/IOS/LTSDK/LTSDKNPC.mm");
        flags  = pbxProj.GetCompileFlagsForFile(targetGuid, mmfile);
        flags.Add("-fno-objc-arc");
        pbxProj.SetCompileFlagsForFile(targetGuid, mmfile, flags);
        pbxProj.WriteToFile(projPath);

        string[] splits     = PlayerSettings.applicationIdentifier.Split('.');
        var      capManager = new ProjectCapabilityManager(projPath, splits[splits.Length - 1] + ".entitlements", PBXProject.GetUnityTargetName());//创建设置Capability类

        if (PlayerSettings.applicationIdentifier.Equals("com.longtugame.dzyz.longtu"))
        {
            //正式包,增加计费
            capManager.AddInAppPurchase();
        }
        capManager.AddAssociatedDomains(new[]
        {
            "applinks:dy.longtugame.com"
        });
        capManager.WriteToFile();//写入文件保存
    }
 public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
 {
     if (buildTarget == BuildTarget.iOS) {
         string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
         PBXProject proj = new PBXProject();
         proj.ReadFromString(File.ReadAllText(projPath));
         string target = proj.TargetGuidByName("Unity-iPhone");
         proj.AddFrameworkToProject(target, "WebKit.framework", false);
         File.WriteAllText(projPath, proj.WriteToString());
     }
 }
    private static void OnPostprocessBuildIOS(string pathToBuiltProject)
    {
        // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module
                #if UNITY_IOS
        string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";

        UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject();
        proj.ReadFromString(File.ReadAllText(projPath));
        proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "opencv2.framework", false);

        File.WriteAllText(projPath, proj.WriteToString());
                #endif // #if UNITY_IOS
    }
예제 #16
0
    static void _AddDeviceCapabilities(string path)
    {
        string pbxprojPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
        
        PBXProject project = new PBXProject();
        project.ReadFromString(File.ReadAllText(pbxprojPath));
        string target = project.TargetGuidByName("Unity-iPhone");

        project.AddFrameworkToProject(target, "AdSupport.framework", false);
        project.AddFrameworkToProject(target, "AudioToolbox.framework", false);
        project.AddFrameworkToProject(target, "AVFoundation.framework", false);
        project.AddFrameworkToProject(target, "CoreGraphics.framework", false);
        project.AddFrameworkToProject(target, "CoreTelephony.framework", false);
        project.AddFrameworkToProject(target, "EventKit.framework", false);
        project.AddFrameworkToProject(target, "EventKitUI.framework", false);
        project.AddFrameworkToProject(target, "MessageUI.framework", false);
        project.AddFrameworkToProject(target, "StoreKit.framework", false);
        project.AddFrameworkToProject(target, "SystemConfiguration.framework", false);

        project.SetBuildProperty(target, "CLANG_ENABLE_MODULES", "YES");

        File.WriteAllText(pbxprojPath, project.WriteToString());

        string infoPlistPath = Path.Combine(path, "./Info.plist");
        PlistDocument plist = new PlistDocument();
        plist.ReadFromString(File.ReadAllText(infoPlistPath));

        PlistElementDict rootDict = plist.root;
        PlistElementArray deviceCapabilityArray = rootDict.CreateArray("UIRequiredDeviceCapabilities");
        deviceCapabilityArray.AddString("armv7");
        deviceCapabilityArray.AddString("gamekit"); 

        rootDict.SetBoolean("UIRequiresFullScreen", true);

        File.WriteAllText(infoPlistPath, plist.WriteToString());
    }
예제 #17
0
        private static void UpdatePbxProject(string projectPath, string buildPath)
        {
            PBXProject proj = new PBXProject();
            proj.ReadFromString(File.ReadAllText(projectPath));

            string[] frameworks = {
                "CFNetwork.framework",
                "CoreGraphics.framework",
                "Foundation.framework",
                "MobileCoreServices.framework",
                "Security.framework",
                "SystemConfiguration.framework",
                "UIKit.framework",
                "CoreTelephony.framework",
                "CoreLocation.framework",
                "CoreData.framework",
                "UserNotifications.framework"
            };

            string[] targets = {
                proj.TargetGuidByName(PBXProject.GetUnityTargetName()),
                proj.TargetGuidByName(PBXProject.GetUnityTestTargetName())
            };

            string airshipConfig = Path.Combine(buildPath, "AirshipConfig.plist");
            if (File.Exists(airshipConfig)) {
                File.Delete(airshipConfig);
            }

            File.Copy(Path.Combine(Application.dataPath, "Plugins/iOS/AirshipConfig.plist"), airshipConfig);
            string airshipGUID = proj.AddFile("AirshipConfig.plist", "AirshipConfig.plist", PBXSourceTree.Source);

            foreach (string target in targets)
            {
                proj.AddBuildProperty(target, "OTHER_LDFLAGS", "$(inherited)");
                proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC -lz -lsqlite3");
                proj.AddFileToBuild(target, airshipGUID);

                foreach (string framework in frameworks)
                {
                    proj.AddFrameworkToProject(target, framework, false);
                    UnityEngine.Debug.Log ("Adding framework: " + framework);

                }
            }

            File.WriteAllText(projectPath, proj.WriteToString());
        }
예제 #18
0
    private static void OnPostprocessBuildIOS(string pathToBuiltProject)
    {
        // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module
                #if UNITY_IOS
        string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";

        UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject();
        proj.ReadFromString(File.ReadAllText(projPath));
        proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "AssetsLibrary.framework", false);
        string target = proj.TargetGuidByName("Unity-iPhone");

        Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Sturfee/Plugins/iOS/Shared"));

        string[] sturGLoaderfilesToCopy = new string[]
        {
            "PlatformBase.hpp",
            "UnityInterface.hpp",
        };

        string[] sharedFilesToCopy = new string[]
        {
            "SturgProcesser.hpp",
            "SFDataStream.hpp",
            "SFLogger.hpp",
        };

        for (int i = 0; i < sturGLoaderfilesToCopy.Length; ++i)
        {
            var srcPath      = Path.Combine(Path.Combine(Application.dataPath, "Sturfee/Plugins/iOS/SturGLoader/Include"), sturGLoaderfilesToCopy[i]);
            var dstLocalPath = "Libraries/Sturfee/Plugins/iOS/SturGLoader/Include/" + sturGLoaderfilesToCopy[i];
            var dstPath      = Path.Combine(pathToBuiltProject, dstLocalPath);
            File.Copy(srcPath, dstPath, true);
            proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath));
        }

        for (int i = 0; i < sharedFilesToCopy.Length; ++i)
        {
            var srcPath      = Path.Combine(Path.Combine(Application.dataPath, "Sturfee/Plugins/iOS/Shared"), sharedFilesToCopy[i]);
            var dstLocalPath = "Libraries/Sturfee/Plugins/iOS/Shared/" + sharedFilesToCopy[i];
            var dstPath      = Path.Combine(pathToBuiltProject, dstLocalPath);
            File.Copy(srcPath, dstPath, true);
            proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath));
        }

        File.WriteAllText(projPath, proj.WriteToString());
                #endif // #if UNITY_IOS
    }
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        #if UNITY_5
        if (buildTarget == BuildTarget.iOS)
        #else
        if (buildTarget == BuildTarget.iPhone)
        #endif
        {
            string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject proj = new PBXProject();

            proj.ReadFromString(File.ReadAllText(projPath));

            string target = proj.TargetGuidByName("Unity-iPhone");

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

            proj.AddFrameworkToProject(target, "libc++.dylib", false /*not weak*/);

            // 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");

            // Set a custom link flag
            proj.AddBuildProperty(target, "GCC_PREPROCESSOR_DEFINITIONS", "$(CONFIGURATION) $(inherited)");
            proj.AddBuildProperty(target, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");

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

        // edit Info.plist
        /*var plistPath = Path.Combine(path, "Info.plist");

        var plist = new PlistDocument();

        plist.ReadFromFile(plistPath);

        plist.root.SetString("UIBackgroundModes", "voip");

        plist.WriteToFile(plistPath);*/
    }
    public static void OnPostProcessBuildIOS(string pathToBuiltProject)
    {
#if UNITY_IOS
        string     projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
        PBXProject proj     = new UnityEditor.iOS.Xcode.PBXProject();
        proj.ReadFromString(File.ReadAllText(projPath));
        proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "Photos.framework", false);
        File.WriteAllText(projPath, proj.WriteToString());

        string plistPath = Path.Combine(pathToBuiltProject, "Info.plist");
        var    plist     = new PlistDocument();
        plist.ReadFromFile(plistPath);

        const string key         = "NSPhotoLibraryUsageDescription";
        const string description = "Camera roll access permission is necessary for saving an image.";
        plist.root.SetString(key, description);

        plist.WriteToFile(plistPath);
#endif //UNITY_IOS
    }
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
        #if UNITY_IPHONE
            if (target != BuildTarget.iOS) return;

            string buildName = Path.GetFileNameWithoutExtension(path);
            string pbxprojPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject proj = new PBXProject();

            proj.ReadFromString(File.ReadAllText(pbxprojPath));

            string buildTarget = proj.TargetGuidByName("Unity-iPhone");

            DirectoryInfo projectParent = Directory.GetParent(Application.dataPath);

            char divider = Path.DirectorySeparatorChar;

            DirectoryInfo destinationFolder =
                new DirectoryInfo(path + divider + "Frameworks");

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

            proj.SetBuildProperty(
                buildTarget, "FRAMEWORK_SEARCH_PATHS", "$(SRCROOT)/Frameworks"
            );
            proj.AddBuildProperty(
                buildTarget, "FRAMEWORK_SEARCH_PATHS", "$(inherited)"
            );
            proj.SetBuildProperty(buildTarget, "CLANG_ENABLE_MODULES", "YES");

            File.WriteAllText(pbxprojPath, proj.WriteToString());
        #endif
    }
예제 #22
0
파일: XcodeSetting.cs 프로젝트: li5414/Usdk
 //设置frameworks
 private static void SetFrameworks(PBXProject proj, Hashtable table)
 {
     if (table != null)
     {
         string    target  = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
         ArrayList addList = table["+"] as ArrayList;
         if (addList != null)
         {
             foreach (string i in addList)
             {
                 proj.AddFrameworkToProject(target, i, false);
             }
         }
         ArrayList removeList = table["-"] as ArrayList;
         if (removeList != null)
         {
             foreach (string i in removeList)
             {
                 proj.RemoveFrameworkFromProject(target, i);
             }
         }
     }
 }
예제 #23
0
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS) {
            string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

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

            string target = proj.TargetGuidByName("Unity-iPhone");

            // Add user packages to project. Most other source or resource files and packages
            // can be added the same way.
            /*
            CopyAndReplaceDirectory("NativeAssets/TestLib.bundle", Path.Combine(path, "Frameworks/TestLib.bundle"));
            proj.AddFileToBuild(target, proj.AddFile("Frameworks/TestLib.bundle",
                                                     "Frameworks/TestLib.bundle", PBXSourceTree.Source));

            CopyAndReplaceDirectory("NativeAssets/TestLib.framework", Path.Combine(path, "Frameworks/TestLib.framework"));
            proj.AddFileToBuild(target, proj.AddFile("Frameworks/TestLib.framework",
                                                     "Frameworks/TestLib.framework", PBXSourceTree.Source));
            */
            // Add custom system frameworks. Duplicate frameworks are ignored.
            // needed by our native plugin in Assets/Plugins/iOS

            proj.AddFrameworkToProject(target, "MessageUI.framework", false /*not weak*/);

            // 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");

            // Set a custom link flag
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

            File.WriteAllText(projPath, proj.WriteToString());
        }
    }
예제 #24
0
    public static void OnPostProcessBuildFirst(BuildTarget bt, string path)
    {
        if(bt == BuildTarget.WebGL){
            moveResources("levels",false);
        }else{
            moveResources("webLevels",false);
        }
        if(bt == BuildTarget.iOS || bt == BuildTarget.StandaloneOSXUniversal){
            moveResources("achievementIcons",false);
        }
        AssetDatabase.Refresh();
        switch(lastPlatform){
            case platform.osx:
                if(PlayerSettings.useMacAppStoreValidation){
                    runShell("/Volumes/Jesper Ext/unity/ZeGame/ZeGame_osx/fixAndSign.sh");
                }else{
                    runShell("/Volumes/Jesper Ext/unity/ZeGame/ZeGame_osx/fixSignAndOpen.sh");
                }
                break;
            case platform.ios:
                //I know I should make the paths relative but you can't tell me what to do
                runShell("/Volumes/Jesper Ext/unity/ZeGame/ZeGame_ios/build.sh");

                //find project
                string projectPath = "/Volumes/Jesper Ext/unity/ZeGame/ZeGame_ios/xcode/Unity-iPhone.xcodeproj/project.pbxproj";
                PBXProject project = new PBXProject();
                project.ReadFromFile(projectPath);
                string targetGuid = project.TargetGuidByName("Unity-iPhone");

                //add cloudkit framework (this is still easy)
                project.AddFrameworkToProject(targetGuid,"CloudKit.framework",false);

                //copy the entitlements file, you should generate this once
                //using xcode, then put it somewhere on your disk so
                //you can copy it to this location later
                File.Copy("/Volumes/Jesper Ext/unity/ZeGame/ZeGame_ios/ZeGame.entitlements","/Volumes/Jesper Ext/unity/ZeGame/ZeGame_ios/xcode/Unity-iPhone/ZeGame.entitlements");

                //now this is where it gets messy, because the PBXProject
                //class doesn't support enabling iCloud so you'll
                //have to change the string manually
                //I suggest you build your xcode project once (without
                //playing it automatically, so you'll have to remove
                // BuildOptions.AutoRunPlayer; from the buildoptions
                //then duplicate your xcode project folder and enable
                //iCloud in one of them. You can then use a site like
                //https://www.diffnow.com/ to find the difference
                //between the two projects.
                //not all differences have to be included but these are
                //the ones I found that are necessary.

                string projectString = project.WriteToString();

                //add entitlements file
                projectString = projectString.Replace("/* Begin PBXFileReference section */",
                    "/* Begin PBXFileReference section */\n\t\t244C317F1B8BE5CF00F39B20 /* ZeGame.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = ZeGame.entitlements; path = \"Unity-iPhone/ZeGame.entitlements\"; sourceTree = \"<group>\"; };");

                //add entitlements file (again)
                projectString = projectString.Replace("/* CustomTemplate */ = {\n			isa = PBXGroup;\n			children = (",
                    "/* CustomTemplate */ = {\n			isa = PBXGroup;\n			children = (\n				244C317F1B8BE5CF00F39B20 /* ZeGame.entitlements */,");

                //add some kind of entitlements command
                projectString = projectString.Replace("CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;",
                    "CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCODE_SIGN_ENTITLEMENTS = \"Unity-iPhone/ZeGame.entitlements\";");

                //add development team you'll have to replace ****
                //with your own development string, which you can find
                //in your project.pbxproj file after enabling icloud
                projectString = projectString.Replace("TargetAttributes = {",
                    "TargetAttributes = {\n					1D6058900D05DD3D006BFB54 = {\n						DevelopmentTeam = ******;\n					};");

                //save the file
                File.WriteAllText(projectPath, projectString);

                break;
            case platform.windows:
                lastPlatform = platform.windows64;
                buildLast();
                break;
            case platform.windows64:
                lastPlatform = platform.windows;
                File.Delete("/Volumes/Jesper Ext/unity/ZeGame/ZeGame_windows/64/player_win_x64_s.pdb");
                File.Delete("/Volumes/Jesper Ext/unity/ZeGame/ZeGame_windows/64/player_win_x64.pdb");
                File.Delete("/Volumes/Jesper Ext/unity/ZeGame/ZeGame_windows/32/player_win_x86_s.pdb");
                File.Delete("/Volumes/Jesper Ext/unity/ZeGame/ZeGame_windows/32/player_win_x86.pdb");
                break;
            case platform.linux:
                runShell("/Volumes/Jesper Ext/unity/ZeGame/ZeGame_linux/build.sh");
                break;
        }
    }
    private static void OnPostprocessBuild(BuildTarget buildTarget, string buildPath)
    {
        //iOS以外にビルドしている場合は更新処理を行わないように
        if (buildTarget != BuildTarget.iOS){
            return;
        }

        //Xcodeの設定データを読み込む
        XcodeProjectSetting setting = Resources.Load<XcodeProjectSetting>(SETTING_DATA_PATH);
        if(setting == null){
            Debug.Log ("Resources/" + SETTING_DATA_PATH + "がありません!");
            return;
        }

        //Xcodeプロジェクトの読み込み
        string pbxProjPath = PBXProject.GetPBXProjectPath(buildPath);
        PBXProject pbxProject = new PBXProject();
        pbxProject.ReadFromString(File.ReadAllText(pbxProjPath));

        //ターゲットのID取得
        string targetGuid = pbxProject.TargetGuidByName(PBXProject.GetUnityTargetName());

        //指定ディレクトリ内のファイルを全てコピーする
        if(!string.IsNullOrEmpty(setting.CopyDirectoryPath)){
            DirectoryProcessor.CopyAndAddBuildToXcode (pbxProject, targetGuid, setting.CopyDirectoryPath, buildPath, "");
        }

        //コンパイラフラグの設定
        foreach (XcodeProjectSetting.CompilerFlagsSet compilerFlagsSet in setting.CompilerFlagsSetList) {

            foreach (string targetPath in compilerFlagsSet.TargetPathList) {
                if(!pbxProject.ContainsFileByProjectPath(targetPath)){
                    Debug.Log (targetPath + "が無いのでコンパイラフラグが設定できませんでした");
                    continue;
                }

                string fileGuid        = pbxProject.FindFileGuidByProjectPath(targetPath);
                List<string> flagsList = pbxProject.GetCompileFlagsForFile(targetGuid, fileGuid);

                flagsList.Add(compilerFlagsSet.Flags);
                pbxProject.SetCompileFlagsForFile(targetGuid, fileGuid, flagsList);
            }

        }

        //システムのフレームワークを追加
        foreach (string framework in setting.FrameworkList) {
            pbxProject.AddFrameworkToProject(targetGuid, framework, false);
        }

        //Linker Flagの設定
        pbxProject.UpdateBuildProperty(targetGuid, XcodeProjectSetting.LINKER_FLAG_KEY, setting.LinkerFlagArray, null);

        //フレームワークがあるディレクトリへのパス設定
        pbxProject.UpdateBuildProperty(targetGuid, XcodeProjectSetting.FRAMEWORK_SEARCH_PATHS_KEY, setting.FrameworkSearchPathArray, null);

        //BitCodeの設定
        pbxProject.SetBuildProperty(targetGuid, XcodeProjectSetting.ENABLE_BITCODE_KEY, setting.EnableBitCode ? "YES" : "NO");

        //プロジェクトファイル書き出し
        File.WriteAllText(pbxProjPath, pbxProject.WriteToString());

        //URLスキームの設定
        List<string> urlSchemeList = new List<string>(setting.URLSchemeList);
        InfoPlistProcessor.SetURLSchemes (buildPath, setting.URLIdentifier, urlSchemeList);

        //デフォルトで設定されているスプラッシュ画像の設定を消す
        if(setting.NeedToDeleteLaunchiImagesKey){
            InfoPlistProcessor.DeleteLaunchiImagesKey (buildPath);
        }

        //ATSの設定
        InfoPlistProcessor.SetATS (buildPath, setting.EnableATS);

        //ステータスバーの設定
        InfoPlistProcessor.SetStatusBar (buildPath, setting.EnableStatusBar);
    }
    private static void OnPostprocessBuildIOS(string pathToBuiltProject)
    {
        // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module
                #if UNITY_IOS
        string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";

        UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject();
        proj.ReadFromString(File.ReadAllText(projPath));
        proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "ARKit.framework", false);
        string target = proj.TargetGuidByName("Unity-iPhone");
        Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Unity"));

        // Check UnityARKitPluginSettings
        UnityARKitPluginSettings ps = LoadSettings();
        string        plistPath     = Path.Combine(pathToBuiltProject, "Info.plist");
        PlistDocument plist         = new PlistDocument();
        plist.ReadFromString(File.ReadAllText(plistPath));
        PlistElementDict rootDict = plist.root;

        // Get or create array to manage device capabilities
        const string      capsKey = "UIRequiredDeviceCapabilities";
        PlistElementArray capsArray;
        PlistElement      pel;
        if (rootDict.values.TryGetValue(capsKey, out pel))
        {
            capsArray = pel.AsArray();
        }
        else
        {
            capsArray = rootDict.CreateArray(capsKey);
        }
        // Remove any existing "arkit" plist entries
        const string arkitStr = "arkit";
        capsArray.values.RemoveAll(x => arkitStr.Equals(x.AsString()));
        if (ps.AppRequiresARKit)
        {
            // Add "arkit" plist entry
            capsArray.AddString(arkitStr);
        }
        File.WriteAllText(plistPath, plist.WriteToString());

        foreach (ARReferenceImagesSet ar in imageSets)
        {
            AddReferenceImagesSetToAssetCatalog(ar, pathToBuiltProject, proj);
        }

        //TODO: remove this when XCode actool is able to handles ARResources despite deployment target
        if (imageSets.Count > 0)
        {
            proj.SetBuildProperty(target, "IPHONEOS_DEPLOYMENT_TARGET", "11.3");
        }

        // Add or replace define for facetracking
        UpdateDefinesInFile(pathToBuiltProject + "/Classes/Preprocessor.h", new Dictionary <string, bool>()
        {
            { "ARKIT_USES_FACETRACKING", ps.m_ARKitUsesFacetracking }
        });

        string[] filesToCopy = new string[]
        {
        };

        for (int i = 0; i < filesToCopy.Length; ++i)
        {
            var srcPath      = Path.Combine("../PluginSource/source", filesToCopy[i]);
            var dstLocalPath = "Libraries/" + filesToCopy[i];
            var dstPath      = Path.Combine(pathToBuiltProject, dstLocalPath);
            File.Copy(srcPath, dstPath, true);
            proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath));
        }

        File.WriteAllText(projPath, proj.WriteToString());
                #endif // #if UNITY_IOS
    }
예제 #27
0
 public static void OnPostProcessBuild(BuildTarget platform, string projectPath)
 {
     if (platform != BuildTarget.iOS) {
       return;
     }
     string pbxFile = PBXProject.GetPBXProjectPath(projectPath);
     PBXProject pbxProject = new PBXProject();
     pbxProject.ReadFromFile(pbxFile);
     string target = pbxProject.TargetGuidByName(PBXProject.GetUnityTargetName());
     pbxProject.AddFrameworkToProject(target, "Security.framework", false);
     pbxProject.AddFrameworkToProject(target, "GLKit.framework", false);
     pbxProject.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
     pbxProject.WriteToFile(pbxFile);
 }
예제 #28
0
    static void AddFrameworks(UnityEditor.iOS.Xcode.PBXProject project, string targetGUID)
    {
        project.AddFrameworkToProject(targetGUID, "AVFoundation.framework", true);
        project.AddFrameworkToProject(targetGUID, "Accelerate.framework", true);
        project.AddFrameworkToProject(targetGUID, "AdSupport.framework", true);
        project.AddFrameworkToProject(targetGUID, "AudioToolbox.framework", true);

        project.AddFrameworkToProject(targetGUID, "CoreLocation.framework", false);
        project.AddFrameworkToProject(targetGUID, "CoreMedia.framework", false);
        project.AddFrameworkToProject(targetGUID, "CoreMotion.framework", false);
        project.AddFrameworkToProject(targetGUID, "CoreTelephony.framework", false);

        project.AddFrameworkToProject(targetGUID, "MessageUI.framework", false);
        project.AddFrameworkToProject(targetGUID, "MobileCoreServices.framework", false);

        project.AddFrameworkToProject(targetGUID, "SafariServices.framework", false);
        project.AddFrameworkToProject(targetGUID, "StoreKit.framework", false);
        project.AddFrameworkToProject(targetGUID, "SystemConfiguration.framework", false);

        project.AddFrameworkToProject(targetGUID, "VideoToolbox.framework", false);

        project.AddFrameworkToProject(targetGUID, "WebKit.framework", false);

        project.AddFrameworkToProject(targetGUID, "libbz2.tbd", false);
        project.AddFrameworkToProject(targetGUID, "libc++.tbd", false);
        project.AddFrameworkToProject(targetGUID, "libresolv.9.tbd", false);
        project.AddFrameworkToProject(targetGUID, "libsqlite3.tbd", false);
        project.AddFrameworkToProject(targetGUID, "libxml2.tbd", false);
        project.AddFrameworkToProject(targetGUID, "libz.tbd", false);
    }
예제 #29
0
		static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
		{
			#if UNITY_5
			if (target == BuildTarget.WSAPlayer || target == BuildTarget.WP8Player)
			#else
			if (target == BuildTarget.MetroPlayer || target == BuildTarget.WP8Player)
			#endif
			{
				#if UNITY_WP8 || UNITY_5
				var productName = PlayerSettings.productName.Replace(" ", "").Replace("_", "");
				#else
				var productName = PlayerSettings.productName;
				#endif
				
				#if UNITY_5
				if (EditorUserBuildSettings.wsaSDK == WSASDK.UniversalSDK81 && EditorUserBuildSettings.activeBuildTarget != BuildTarget.WP8Player)
				#else
				if (EditorUserBuildSettings.metroSDK == MetroSDK.UniversalSDK81 && EditorUserBuildSettings.activeBuildTarget != BuildTarget.WP8Player)
				#endif
				{
					var projPath = string.Format("{0}/{1}/{1}.Shared/{1}.Shared.projItems", pathToBuiltProject, productName);
					Debug.Log("Modifying Proj: " + projPath);
					var doc = XDocument.Load(projPath);
					addPostProjectReferences(doc, pathToBuiltProject, string.Format("/{0}.Shared", productName), productName, "$(MSBuildThisFileDirectory)");
					doc.Save(projPath);

					projPath = string.Format("{0}/{1}/{1}.Windows/{1}.Windows.csproj", pathToBuiltProject, productName);
					Debug.Log("Modifying Proj: " + projPath);
					doc = XDocument.Load(projPath);
					addPostProjectCompilerDirectives(doc);
					doc.Save(projPath);

					projPath = string.Format("{0}/{1}/{1}.WindowsPhone/{1}.WindowsPhone.csproj", pathToBuiltProject, productName);
					Debug.Log("Modifying Proj: " + projPath);
					doc = XDocument.Load(projPath);
					addPostProjectCompilerDirectives(doc);
					doc.Save(projPath);
				}
				else
				{
					var projPath = string.Format("{0}/{1}/{1}.csproj", pathToBuiltProject, productName);
					Debug.Log("Modifying Proj: " + projPath);

					var doc = XDocument.Load(projPath);
					addPostProjectCompilerDirectives(doc);
					addPostProjectReferences(doc, pathToBuiltProject, "", productName, "");
					doc.Save(projPath);
				}
			}
			#if UNITY_IOS && UNITY_5
			else if (target == BuildTarget.iOS)
			{
				string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";

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

				string targetID = proj.TargetGuidByName ("Unity-iPhone");

				// set custom link flags
				proj.AddBuildProperty (targetID, "OTHER_LDFLAGS", "-all_load");
				proj.AddBuildProperty (targetID, "OTHER_LDFLAGS", "-ObjC");

				// add frameworks
				proj.AddFrameworkToProject(targetID, "AdSupport.framework", true);
				proj.AddFrameworkToProject(targetID, "CoreTelephony.framework", true);
				proj.AddFrameworkToProject(targetID, "EventKit.framework", true);
				proj.AddFrameworkToProject(targetID, "EventKitUI.framework", true);
				proj.AddFrameworkToProject(targetID, "iAd.framework", true);
				proj.AddFrameworkToProject(targetID, "MessageUI.framework", true);
				proj.AddFrameworkToProject(targetID, "StoreKit.framework", true);
				proj.AddFrameworkToProject(targetID, "Security.framework", true);
				proj.AddFrameworkToProject(targetID, "GameKit.framework", true);
				proj.AddFrameworkToProject(targetID, "GoogleMobileAds.framework", false);

				// change GoogleMobileAds to use reletive path
				string projData = proj.WriteToString();
				projData = projData.Replace
				(
					@"/* GoogleMobileAds.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GoogleMobileAds.framework; path = System/Library/Frameworks/GoogleMobileAds.framework; sourceTree = SDKROOT; };",
					@"/* GoogleMobileAds.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GoogleMobileAds.framework; path = Frameworks/GoogleMobileAds.framework; sourceTree = ""<group>""; };"
					//@"/* GoogleMobileAds.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GoogleMobileAds.framework; path = """ + pathToBuiltProject+"/Frameworks/GoogleMobileAds.framework" + @"""; sourceTree = ""<absolute>""; };"
				);

				// change framework search path to include local framework directory
				projData = projData.Replace
				(
					@"FRAMEWORK_SEARCH_PATHS = ""$(inherited)"";",
					@"FRAMEWORK_SEARCH_PATHS = (""$(inherited)"", ""$(PROJECT_DIR)/Frameworks"",);"
				);

				// save proj data
				File.WriteAllText(projPath, projData);

				// create Frameworks folder if one doesn't exists
				if (!Directory.Exists(pathToBuiltProject+"/Frameworks/")) Directory.CreateDirectory(pathToBuiltProject+"/Frameworks/");

				// extract GoogleMobileAds.framework.zip to xcode framework path
				if (!Directory.Exists(pathToBuiltProject+"/Frameworks/GoogleMobileAds.framework/"))
				{
					var startInfo = new System.Diagnostics.ProcessStartInfo();
					startInfo.Arguments = @"""" + Application.dataPath+"/Plugins/IOS/GoogleMobileAds.framework.zip" + @""" -d """ + pathToBuiltProject+@"/Frameworks/""";
					startInfo.FileName = "unzip";
					startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
					startInfo.CreateNoWindow = true;
					using (var process = System.Diagnostics.Process.Start(startInfo))
					{
						process.WaitForExit();
						int exitCode = process.ExitCode;
						if (exitCode != 0) Debug.LogError("Failed to unzip GoogleMobileAds.framework.zip with ErrorCode: " + exitCode);
					}
				}
			}
			#endif
    	}
	private static void ProcessPostBuild (BuildTarget buildTarget, string path)
	{
    string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

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

    string target = proj.TargetGuidByName("Unity-iPhone");
    //
    //Required Frameworks
    proj.AddFrameworkToProject(target, "AudioToolbox.framework", false);
    proj.AddFrameworkToProject(target, "AVFoundation.framework", false);
    proj.AddFrameworkToProject(target, "CoreGraphics.framework", false);
    proj.AddFrameworkToProject(target, "CoreTelephony.framework", false);
    proj.AddFrameworkToProject(target, "CoreMedia.framework", false);
    proj.AddFrameworkToProject(target, "EventKit.framework", false);
    proj.AddFrameworkToProject(target, "EventKitUI.framework", false);
    proj.AddFrameworkToProject(target, "MediaPlayer.framework", false);
    proj.AddFrameworkToProject(target, "MessageUI.framework", false);
    proj.AddFrameworkToProject(target, "QuartzCore.framework", false);
    proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);

    proj.AddFileToBuild(target, proj.AddFile("usr/lib/libz.1.2.5.dylib", "Frameworks/libz.1.2.5.dylib", PBXSourceTree.Sdk));

    //Optional Frameworks
    proj.AddFrameworkToProject(target, "AdSupport.framework", true);
    proj.AddFrameworkToProject(target, "Social.framework", true);
    proj.AddFrameworkToProject(target, "StoreKit.framework", true);
    proj.AddFrameworkToProject(target, "Webkit.framework", true);

    File.WriteAllText(projPath, proj.WriteToString());
	}
예제 #31
0
        private static void ModifyProject(string projectPath)
        {
            // Create PBXProject
              PBXProject project = new PBXProject();
              project.ReadFromString(File.ReadAllText(projectPath));

              if (!AppboyConfig.IOSAutomatesIntegration) {
            // Remove AppboyAppDelegate.mm from PBXProject
            Debug.Log("Removing AppboyAppDelegate.mm from " + AppboyAppDelegatePath);
            string appboyAppDelegateGuid = project.FindFileGuidByProjectPath(AppboyAppDelegatePath);
            project.RemoveFile(appboyAppDelegateGuid);
              } else {
            // Get project targets using Unity's default app target names
            string[] targets = {
              project.TargetGuidByName(PBXProject.GetUnityTargetName()),
              project.TargetGuidByName(PBXProject.GetUnityTestTargetName())
            };

            string[] requiredFrameworks = {
              "SystemConfiguration.framework",
              "QuartzCore.framework",
              "libz.tbd",
              "CoreImage.framework",
              "CoreText.framework"
            };

            string[] optionalFrameworks = {
              "CoreTelephony.framework",
              "Social.framework",
              "Accounts.framework",
              "AdSupport.framework",
              "StoreKit.framework",
              "CoreLocation.framework", // optional for location tracking
              "ImageIO.framework" // required by SDWebImage
            };

            foreach (string target in targets) {
              // Modify build properties
              project.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
              project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "./Frameworks/Plugins/iOS");
              project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "./Libraries/Plugins/iOS");
              project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "./Libraries");

              // Add required frameworks
              // Note: Unity's documentation for PBXProject.AddFrameworkToProject says that the boolean parameter
              // should be true if required and false if optional, but actual behavior appears to be the exact opposite.
              foreach (string framework in requiredFrameworks) {
            project.AddFrameworkToProject(target, framework, false);
              }

              foreach (string framework in optionalFrameworks) {
            project.AddFrameworkToProject(target, framework, true);
              }
            }
              }

              // Write changes to XCode project
              File.WriteAllText(projectPath, project.WriteToString());
        }
예제 #32
0
	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

	}
	public static void PatchXcodeProject (string pathToBuiltProject)
	{
		PBXProject project = new PBXProject();
		
		string projectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);

		projectPath = checkPBXProjectPath(projectPath);

		project.ReadFromFile(projectPath);
		
		string guid = project.TargetGuidByName("Unity-iPhone");
		project.AddFrameworkToProject(guid, "ExternalAccessory.framework", false);
		
		// The following settings lead to a quicker build
		string releaseConfig = project.BuildConfigByName(guid, "Release");
		project.SetBuildPropertyForConfig(releaseConfig, "DEBUG_INFORMATION_FORMAT", "dwarf");
		project.SetBuildPropertyForConfig(releaseConfig, "ONLY_ACTIVE_ARCH", "YES");
		// XCode7 enables BitCode for all projects by default.  Neither the Structure SDK nor Unity support BitCode at this time
		project.SetBuildPropertyForConfig(releaseConfig, "ENABLE_BITCODE", "NO");
		string debugConfig = project.BuildConfigByName(guid, "Debug");
		project.SetBuildPropertyForConfig(debugConfig, "ENABLE_BITCODE", "NO"); 
		project.WriteToFile(projectPath);
	}