forked from miyabi/unity-swift
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PostProcessor.cs
37 lines (33 loc) · 1.52 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
35
36
37
#if UNITY_IOS
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.SetBuildProperty(targetGuid, "SWIFT_VERSION", "5.0");
proj.WriteToFile(projPath);
}
}
}
}
#endif