반응형
iOS 플러그인
iOS 빌드의 특징 :
컴파일 방식의 차이때문에 XCode 빌드를 거쳐야 앱 완성
iOS 플러그인
Objective-C++ 파일로 개발 : Assets/Plugins/iOS에 저장
mm 파일은 Xcode project Libraries에 저장
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
//UnityiOSPlugin.mm
@implementation UnityiOSPlugin
+ (id)sharedManager {
static dispatch_once_t pred;
static UnityiOSPlugin *shared = nil;
dispatch_once(&pred, ^{
shared = [[UnityiOSPlugin alloc] init];
});
return shared;
}
- (void)init {
}
- (void)openNativeWebViewWithURL:(NSString *aURL) {
// WebView Open 방법은 Apple 문서를 참고하세요.
}
@end
#pragma mark - extern
extern "C"
{
void openNativeWebViewWithURL(const char* aParam) {
[[UnityiOSPlugin sharedManager] openNativeWebViewWithURL:[NSString stringWithUTF8String:aParam]];
}
}
|
cs |
UnityEditor iOS 플러그인
import
Project - Edit Reference - .NET Assembly 탭 - Browse - UnityEditor.iOS.Extensions.Xcode.dll 추가
Xcode 자동 설정 (Plugin/iOS/Editor/XcodeSettingsPostProcesser.cs)
using System.Collections;
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
public class XcodeSettingsPostProcesser
{
[PostProcessBuildAttribute (0)]
public static void OnPostprocessBuild (BuildTarget buildTarget, string pathToBuiltProject)
{
// iOS 이외의 플랫폼 return
if (buildTarget != BuildTarget.iOS)
return;
// PbxProject 초기화
var projectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject pbxProject = new PBXProject ();
pbxProject.ReadFromFile (projectPath);
string targetGuid = pbxProject.TargetGuidByName ("Unity-iPhone");
// Sample of adding build property (빌드 설정 추가)
pbxProject.AddBuildProperty(targetGuid, "OTHER_LDFLAGS", "-all_load");
// Sample of setting build property (빌드 설정 변경)
pbxProject.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
// Sample of update build property (빌드 설정 3번째 추가, 4번째 삭제)
//pbxProject.UpdateBuildProperty(targetGuid, "OTHER_LDFLAGS", new string[]{"-ObjC"}, new string[]{"-weak_framework"});
// Sample of adding REQUIRED framework (필수 프레임 워크 추가)
//pbxProject.AddFrameworkToProject(targetGuid, "Security.framework", false);
// Sample of adding OPTIONAL framework (선택 프레임 워크 추가)
//pbxProject.AddFrameworkToProject(targetGuid, "SafariServices.framework", true);
pbxProject.AddFrameworkToProject(targetGuid, "ImageIO.framework", true);
pbxProject.AddFrameworkToProject(targetGuid, "StorKit.framework", true);
// Sample of setting compile flags (keyboard.mm -fno-objc-arc" 설정)
//var guid = pbxProject.FindFileGuidByProjectPath("Classes/UI/Keyboard.mm");
//var flags = pbxProject.GetCompileFlagsForFile(targetGuid, guid);
//flags.Add("-fno-objc-arc");
//pbxProject.SetCompileFlagsForFile(targetGuid, guid, flags);
// Apply settings (설정 반영)
File.WriteAllText (projectPath, pbxProject.WriteToString ());
// Samlpe of editing Info.plist (Info.plist 설정)
//var plistPath = Path.Combine (pathToBuiltProject, "Info.plist");
//var plist = new PlistDocument ();
//plist.ReadFromFile (plistPath);
// Add string setting
//plist.root.SetString ("hogehogeId", "dummyid");
// Add URL Scheme (URL 스키마 추가)
//var array = plist.root.CreateArray ("CFBundleURLTypes");
//var urlDict = array.AddDict ();
//urlDict.SetString ("CFBundleURLName", "hogehogeName");
//var urlInnerArray = urlDict.CreateArray ("CFBundleURLSchemes");
//urlInnerArray.AddString ("hogehogeValue");
// Apply editing settings to Info.plist (설정 반영)
//plist.WriteToFile (plistPath);
}
}
|
cs |
UNITY 에서 XCODE의 INFO.PLIST 설정 스크립트 예제
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
38
39
40
41
42
43
44
45
46
47
|
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
public static class XcodeOption
{
[PostProcessBuild(999)]
public static void OnPostProcessBuild( BuildTarget buildTarget, string path)
{
if(buildTarget == BuildTarget.iOS)
{
{
string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject pbxProject = new PBXProject();
pbxProject.ReadFromFile(projectPath);
string target = pbxProject.TargetGuidByName("Unity-iPhone");
pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
pbxProject.WriteToFile (projectPath);
}
{
string infoPlistPath = path + "/Info.plist";
PlistDocument plistDoc = new PlistDocument();
plistDoc.ReadFromFile(infoPlistPath);
if (plistDoc.root != null) {
plistDoc.root.SetBoolean("ITSAppUsesNonExemptEncryption", false);
plistDoc.root.SetString("CFBundleDisplayName", "MY APP NAME");
plistDoc.WriteToFile(infoPlistPath);
}
else {
Debug.LogError("ERROR: Can't open " + infoPlistPath);
}
}
//ITSAppUsesNonExemptEncryption
}
}
}
|
cs |
반응형
'모바일 개발 > 유니티' 카테고리의 다른 글
유니티 팁과 단축키 (0) | 2020.04.24 |
---|---|
유니티플러그인 | Facebook SDK Graph API (0) | 2020.03.12 |
유니티 | Unity Interface 개발 (0) | 2020.03.11 |
유니티 | AOS 플러그인 (0) | 2020.03.11 |
유니티 | WebView (2) | 2020.03.10 |
유니티 | 플러그인의 이해 (0) | 2020.03.10 |
유니티 | Spine2D (0) | 2020.03.10 |
유니티 | UnityAds 설치 (1) | 2020.03.10 |
댓글