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); } }
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; case XCProjectSystemCapabilitiesType.XCProjectSystemCapabilitiesTypeInAppPurchase: result = "com.apple.InAppPurchase"; break; case XCProjectSystemCapabilitiesType.XCProjectSystemCapabilitiesTypeGameCenter: result = "com.apple.GameCenter"; break; } return(result); }
public void AddSystemCapabilities(XCProjectSystemCapabilitiesType type, bool enabled) { XCProjectSystemCapabilities systemCapabilities = XCProjectSystemCapabilities.createWithProject(_project); systemCapabilities.visitAddSystemCapabilities(type, enabled); }