Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.meta
*.meta
.DS_Store
.gitignore
18 changes: 16 additions & 2 deletions Mods/StoreKit.projmods
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
{
"group": "Store",
"libs": [],
"frameworks": ["StoreKit.framework"],
"frameworks": [],
"headerpaths": [],
"files": ["iOS/Store/libStoreKit.a"],
"files": [],
"folders": [],
"excludes": ["^.*.meta$", "^.*.mdown$", "^.*.pdf$"],
"compiler_flags": [],
"linker_flags": []
"plist": {
"CFBundleURLTypes" : [
{
"CFBundleTypeRole": "Editor",
"CFBundleURLName" : "wechat",
"CFBundleURLSchemes":["wxyz123456789"]
},
{
"CFBundleURLName" : "twitter",
"CFBundleURLSchemes":["www1234566"]
}
],
"LSApplicationQueriesSchemes":["fbapi222"]
}
}
38 changes: 34 additions & 4 deletions Plist/Plist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ private static object readBinary(byte[] data)
private static Dictionary<string, object> parseDictionary(XmlNode node)
{
XmlNodeList children = node.ChildNodes;
//检验了一下key/value是否成对,不成对抛出异常
if (children.Count % 2 != 0)
{
throw new DataMisalignedException("Dictionary elements must have an even number of child nodes");
Expand Down Expand Up @@ -307,6 +308,26 @@ private static void composeArray(List<object> value, XmlWriter writer)
}
writer.WriteEndElement();
}
private static void composeArrayList(ArrayList value, XmlWriter writer)
{
writer.WriteStartElement("array");
foreach (object obj in value)
{
compose(obj, writer);
}
writer.WriteEndElement();
}
private static void composeHashtable(Hashtable value, XmlWriter writer)
{

writer.WriteStartElement("dict");
foreach (DictionaryEntry entry in value)
{
writer.WriteElementString("key", entry.Key.ToString());
compose(entry.Value, writer);
}
writer.WriteEndElement();
}

private static object parse(XmlNode node)
{
Expand Down Expand Up @@ -388,10 +409,19 @@ private static void compose(object value, XmlWriter writer)
{
writer.WriteElementString(value.ToString().ToLower(), "");
}
else
{
throw new Exception(String.Format("Value type '{0}' is unhandled", value.GetType().ToString()));
}
else if (value is ArrayList)
{
composeArrayList((ArrayList)value, writer);
}
else if (value is Hashtable)
{
composeHashtable((Hashtable)value, writer);
}
else
{
throw new Exception(String.Format("Value type '{0}' is unhandled", value.GetType().ToString()));
}

}

private static void writeDictionaryValues(Dictionary<string, object> dictionary, XmlWriter writer)
Expand Down
109 changes: 109 additions & 0 deletions Plist/XCPlistDocument.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using UnityEngine;
using System.Collections;

using System.Collections.Generic;

namespace PlistCS{

public class XCPlistDocument {

//私有变量
private string pathForPlist=null;
private Dictionary<string, object> root=null;

//初始化的类方法
public static XCPlistDocument createWithPlistPath (string path){
if (string.IsNullOrEmpty (path)) {
Debug.Log ("XCPlistDocument.createWithPlistPath parameter is unexcept!");
return null;
}
XCPlistDocument plist = new XCPlistDocument ();
plist.pathForPlist = path;
try{
plist.root = (Dictionary<string, object>)PlistCS.Plist.readPlist(path);
}catch(System.Exception e){
Debug.LogWarning (e.ToString());
}
return plist;
}
//对外接口函数
public void setBool (string key,bool value){

if (string.IsNullOrEmpty (key)) {
Debug.Log ("XCPlistDocument.setBool parameter is unexcept!");;
return;
}
if(root == null){
Debug.Log ("XCPlistDocument.root is null");
return;
}
add (key,value);
}
public void setString (string key,string value){
if(string.IsNullOrEmpty(key)){
Debug.Log ("XCPlistDocument.setString parameter is unexcept!");
}
if(root == null){
Debug.Log ("XCPlistDocument.root is null");
return;
}
add (key,value);
}
public void setObject (string key, object value){
if (string.IsNullOrEmpty (key)) {
Debug.Log ("XCPlistDocument.setObject parameter is unexcept");
}
if(root == null){
Debug.Log ("XCPlistDocument.root is null");
return;
}
add (key, value);
}
public void setDictionary (string key,Dictionary<string,object> value){
if(string.IsNullOrEmpty(key)){
Debug.Log ("XCPlitDocument.setDictionary is unpty");
}
if(root == null){
Debug.Log ("XCPlistDocument.root is null");
return;
}
add (key,value);
}
//将更改写入磁盘
public void synchronize(){
if(root == null){
Debug.Log ("XCPlistDocument.root is null");
return;
}
if(string.IsNullOrEmpty(pathForPlist)){
Debug.Log ("XCPlistDocument.pathForPlist is null");
}
try{
PlistCS.Plist.writeXml(root, pathForPlist);
}
catch(System.Exception e){
Debug.Log (e.ToString());
}
}
//utility
//fix key exist throw exception
private void add(string key,object value){
if (string.IsNullOrEmpty (key)) {
Debug.Log ("XCPlistDocument.add key parameter is unexcept");
return;
}
if(value == null){
Debug.Log ("XCPlistDocument.add value parameter is unexcept");
return;
}
Debug.Log ("XCPlistDocument.key:"+key);
Debug.Log ("XCPlistDocument.value:"+value.ToString());
if (root.ContainsKey (key)) {
root [key] = value;
} else {
root.Add (key,value);
}
}
}
}

113 changes: 113 additions & 0 deletions XCPRojectSystemCapabilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using UnityEngine;
using System.Collections;


namespace UnityEditor.XCodeEditor{


// com.apple.ApplePay
// com.apple.ApplicationGroups.iOS
// com.apple.BackgroundModes
// com.apple.DataProtection
// com.apple.GameCenter
// com.apple.HealthKit
// com.apple.HomeKit
// com.apple.InAppPurchase
// com.apple.InterAppAudio
// com.apple.Keychain
// com.apple.Maps.iOS
// com.apple.Push
// com.apple.SafariKeychain
// com.apple.Siri
// com.apple.VPNLite
// com.apple.WAC
// com.apple.Wallet
// com.apple.iCloud


public enum XCProjectSystemCapabilitiesType
{
XCProjectSystemCapabilitiesTypeApplePay,
XCProjectSystemCapabilitiesTypeApplePush,
XCProjectSystemCapabilitiesTypeAppleiCloud

};

public class XCProjectSystemCapabilities {


public static XCProjectSystemCapabilities createWithProject(PBXProject project){

XCProjectSystemCapabilities systemCapabilities = new XCProjectSystemCapabilities ();
systemCapabilities.weakProject = project;
return systemCapabilities;
}
public static string getEnumType(XCProjectSystemCapabilitiesType type){

string result=null;
switch (type) {
case XCProjectSystemCapabilitiesType.XCProjectSystemCapabilitiesTypeApplePay:
result="com.apple.ApplePay";
break;
case XCProjectSystemCapabilitiesType.XCProjectSystemCapabilitiesTypeApplePush:
result = "com.apple.Push";
break;
case XCProjectSystemCapabilitiesType.XCProjectSystemCapabilitiesTypeAppleiCloud:
result = "com.apple.iCloud";
break;
}
return result;
}

public PBXProject weakProject;

public void visitAddSystemCapabilities (XCProjectSystemCapabilitiesType type, bool enabled){

if (weakProject == null) {
Debug.Log ("weakProject must not be null");
return;
}
string destributeType = getEnumType (type);
Debug.Log ("Add System Capabilities "+destributeType);

PBXDictionary _Attributes = (PBXDictionary)weakProject.data ["attributes"];
PBXDictionary _TargetAttributes = (PBXDictionary)_Attributes ["TargetAttributes"];
PBXList _targets = (PBXList)weakProject.data ["targets"];
PBXDictionary targetDict = null;
if (_TargetAttributes.ContainsKey ((string)_targets [0])) {
targetDict = (PBXDictionary)_TargetAttributes [(string)_targets [0]];
} else {
//不会发生
//return;
targetDict = new PBXDictionary();
}
// Debug.Log ("targetDict:" + targetDict);

PBXDictionary SystemCapabilities = null;
if (targetDict != null && targetDict.ContainsKey ("SystemCapabilities")) {
// Debug.Log ("xxxxxxxxxxxxxxxxxxx");
SystemCapabilities = (PBXDictionary)targetDict ["SystemCapabilities"];
} else {
SystemCapabilities = new PBXDictionary();
}

Debug.Log ("before SystemCapabilities:" + SystemCapabilities);
if (SystemCapabilities!=null && SystemCapabilities.ContainsKey (destributeType)) {
SystemCapabilities.Remove (destributeType);
}
Debug.Log ("after SystemCapabilities:" + SystemCapabilities);
PBXDictionary enableDict = new PBXDictionary ();
enableDict.Add ("enabled", enabled?"1":"0");
SystemCapabilities.Add (destributeType, enableDict);

if (!targetDict.ContainsKey ("SystemCapabilities")) {
targetDict.Add("SystemCapabilities",SystemCapabilities);
}
if (!_TargetAttributes.ContainsKey ((string)_targets [0])) {
_TargetAttributes.Add((string)_targets [0],targetDict);
}

}
}

}
20 changes: 11 additions & 9 deletions XCPlist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ public static Dictionary<K,V> HashtableToDictionary<K,V> (Hashtable table)
public void AddPlistItems(string key, object value, Dictionary<string, object> dict)
{
Debug.Log ("AddPlistItems: key=" + key);

if (key.CompareTo(PlistUrlType) == 0)
{
processUrlTypes((ArrayList)value, dict);
}
else
{
dict[key] = HashtableToDictionary<string, object>((Hashtable)value);
Debug.Log ("AddPlistItems: value=" + value.ToString());


// if (key.CompareTo(PlistUrlType) == 0)
// {
// processUrlTypes((ArrayList)value, dict);
// }
// else
// {
dict[key] = value;
plistModified = true;
}
// }
}

private void processUrlTypes(ArrayList urltypes, Dictionary<string, object> dict)
Expand Down
11 changes: 9 additions & 2 deletions XCProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public partial class XCProject : System.IDisposable
private PBXSortedDictionary<XCConfigurationList> _configurationLists;

private PBXProject _project;



#endregion


Expand Down Expand Up @@ -333,7 +334,13 @@ public object GetObject( string guid )
{
return _objects[guid];
}


public void AddSystemCapabilities (XCProjectSystemCapabilitiesType type, bool enabled){

XCProjectSystemCapabilities systemCapabilities=XCProjectSystemCapabilities.createWithProject(_project);
systemCapabilities.visitAddSystemCapabilities (type,enabled);

}
public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false )
{
//Debug.Log("AddFile " + filePath + ", " + parent + ", " + tree + ", " + (createBuildFiles? "TRUE":"FALSE") + ", " + (weak? "TRUE":"FALSE") );
Expand Down
2 changes: 1 addition & 1 deletion XCodePostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class XCodePostProcess
[PostProcessBuild(999)]
public static void OnPostProcessBuild( BuildTarget target, string pathToBuiltProject )
{
if (target != BuildTarget.iPhone) {
if (target != BuildTarget.iOS) {
Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
return;
}
Expand Down