-
Notifications
You must be signed in to change notification settings - Fork 26
/
PostProcessor.cs
34 lines (30 loc) · 1.43 KB
/
PostProcessor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace UnitySwift {
public static class PostProcessor {
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget buildTarget, string buildPath) {
if(buildTarget == BuildTarget.iOS) {
// So PBXProject.GetPBXProjectPath returns wrong path, we need to construct path by ourselves instead
// var projPath = PBXProject.GetPBXProjectPath(buildPath);
var projPath = buildPath + "/Unity-iPhone.xcodeproj/project.pbxproj";
var proj = new PBXProject();
proj.ReadFromFile(projPath);
var targetGuid = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
//// Configure build settings
proj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
proj.SetBuildProperty(targetGuid, "SWIFT_OBJC_BRIDGING_HEADER", "Libraries/UnitySwift/UnitySwift-Bridging-Header.h");
proj.SetBuildProperty(targetGuid, "SWIFT_OBJC_INTERFACE_HEADER_NAME", "unityswift-Swift.h");
proj.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");
proj.WriteToFile(projPath);
}
}
}
}