|
| 1 | +// |
| 2 | +// UnityProjectScript.swift |
| 3 | +// UnityBuildKitPackageDescription |
| 4 | +// |
| 5 | +// Copyright (c) 2017 Handsome |
| 6 | +// |
| 7 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | +// of this software and associated documentation files (the "Software"), to deal |
| 9 | +// in the Software without restriction, including without limitation the rights |
| 10 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | +// copies of the Software, and to permit persons to whom the Software is |
| 12 | +// furnished to do so, subject to the following conditions: |
| 13 | +// |
| 14 | +// The above copyright notice and this permission notice shall be included in all |
| 15 | +// copies or substantial portions of the Software. |
| 16 | +// |
| 17 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | +// SOFTWARE. |
| 24 | + |
| 25 | +import Foundation |
| 26 | + |
| 27 | +extension File { |
| 28 | + |
| 29 | + class func unityFrameworksScriptFile(projectName: String, iOSProjectPath: String) -> Data? { |
| 30 | + let file = """ |
| 31 | + using System.Collections; |
| 32 | + using System.IO; |
| 33 | + using UnityEngine; |
| 34 | + using UnityEditor; |
| 35 | + using UnityEditor.SceneManagement; |
| 36 | + using UnityEngine.SceneManagement; |
| 37 | + using UnityEditor.iOS.Xcode; |
| 38 | +
|
| 39 | + public class XcodeFrameworks: MonoBehaviour { |
| 40 | +
|
| 41 | + private const string iOSProjectRoot = \"\(iOSProjectPath)\"; |
| 42 | + private const string iOSProjectName = \"\(projectName)\"; |
| 43 | + private const string PbxFilePath = iOSProjectName + ".xcodeproj/project.pbxproj"; |
| 44 | +
|
| 45 | + public static void Perform () { |
| 46 | + var pbx = new PBXProject(); |
| 47 | + var pbxPath = Path.Combine(iOSProjectRoot, PbxFilePath); |
| 48 | + pbx.ReadFromFile(pbxPath); |
| 49 | +
|
| 50 | + var targetGuid = pbx.TargetGuidByName(iOSProjectName); |
| 51 | + pbx.AddFrameworkToProject(targetGuid, "GameKit.framework", true); |
| 52 | + pbx.AddFrameworkToProject(targetGuid, "CoreGraphics.framework", false); |
| 53 | + pbx.AddFrameworkToProject(targetGuid, "AVFoundation.framework", false); |
| 54 | + pbx.AddFrameworkToProject(targetGuid, "CoreVideo.framework", false); |
| 55 | + pbx.AddFrameworkToProject(targetGuid, "CoreMedia.framework", false); |
| 56 | + pbx.AddFrameworkToProject(targetGuid, "SystemConfiguration.framework", false); |
| 57 | + pbx.AddFrameworkToProject(targetGuid, "CoreLocation.framework", false); |
| 58 | + pbx.AddFrameworkToProject(targetGuid, "MediaPlayer.framework", false); |
| 59 | + pbx.AddFrameworkToProject(targetGuid, "CFNetwork.framework", false); |
| 60 | + pbx.AddFrameworkToProject(targetGuid, "AudioToolbox.framework", false); |
| 61 | + pbx.AddFrameworkToProject(targetGuid, "OpenAL.framework", false); |
| 62 | + pbx.AddFrameworkToProject(targetGuid, "QuartzCore.framework", false); |
| 63 | + pbx.AddFrameworkToProject(targetGuid, "Foundation.framework", false); |
| 64 | + pbx.AddFrameworkToProject(targetGuid, "MediaToolbox.framework", false); |
| 65 | +
|
| 66 | + pbx.WriteToFile(pbxPath); |
| 67 | + } |
| 68 | + } |
| 69 | + """.data(using: .utf8) |
| 70 | + return file |
| 71 | + } |
| 72 | +} |
0 commit comments