feat:update upm

3.18.6
ci-gitlab 2023-04-27 13:27:53 +08:00
commit 56387880e5
342 changed files with 12799 additions and 0 deletions

110
CHANGELOG.md Normal file
View File

@ -0,0 +1,110 @@
# ChangeLog
## 3.11.1
### Fixed bugs
- iOS: 修复授权模块对系统 URL 回调的使用方式
## 3.11.0
## 3.10.0
## 3.9.0
## 3.8.0
## 3.7.1
## 3.7.0
## 3.6.3
### Optimization and fixed bugs
- Android 修复特定机型上繁体中文的识别
- Android 修复初始化时未配置 TapDBConfig 会初始化失败的问题
## 3.6.1
## 3.6.0
## 3.5.2
### New Feature
- 新增多语言配置
## 3.5.0
### Optimization and fixed bugs
- 支持性更新
## 3.4.0
## 3.3.0
- Native Update
## 3.2.0
- Native Update
## 3.1.0
- Native Update
## 3.0.0
### Optimization
- Bridge 新增 Task 桥接
## 2.1.7
### None
## 2.1.6
### BreakingChanges
- 修改 **TapCommon.OpenReviewInTapGlobal()** 方法命名
## 2.1.5
### Optimization and fixed bugs
- 内部优化
## 2.1.4
### Optimization and fixed bugs
- 优化多语言相关
- 修复 JSON 解析错误
## 2.1.3
### New Feature
* iOS 新增 TapTap 以及 Tap.IO 客户端安装判断
## 2.1.2
### Optimization and fixed bugs
* 修复 iOS ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES 设置问题可能导致的 AppStore 审核无法通过
## 2.1.1
### Feature
* Android 新增 TapTap App 相关支持功能
## 2.1.0
* 新增长链接支持 TapTap.Friends
* 海内外域名切换
## 2.0.0
### Feature
* TapTap Common

3
CHANGELOG.md.meta Normal file
View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 89a2f2ba3f4d4cf0b55f2f992c6b6afb
timeCreated: 1616744142

8
Documentation.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e5655844e77cd49d8a69c4a299e31419
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

178
Documentation/Bridge.md Normal file
View File

@ -0,0 +1,178 @@
# TapCommon 用于支持 TapSDK 其他模块中 Android、iOS 与 Unity 的通信
> 目前 TapSDK 业务中Unity 业务层实现的功能不多,主要作为桥接来调用 Android、iOS SDK 中的方法。
## 一、实现 Unity 调用 Android、iOS 方法
> 为了方便 Unity 一套代码可以调用双端方法,所以定义原生接口时,需要考虑 Android、iOS 语言之间的差异。
### Android 接口定义
- 使用 `@BridgeService` 、`@BridgeMethod` 、`@BridgeParam` 注解修饰 `类`、`方法`、`参数`。
- `Activity`、`BridgeCallback` 这两个类型参数不需要 `@BridgeParam` 注解。
- `@BridgeParam` 仅支持基本数据类型(包含 `String`)。
```java
@BridgeService("TestService")
public class TestService implementation IBridgeService {
@BridgeMethod("testMethodWithCallback")
void testMethodWithCallback(BridgeCallback callback);
@BridgeMethod("testMethodWithArgsAndCallback")
void testMethodWithArgsAndCallback(Activity activity, @BridgeParam("args1") String appId, @BridgeParam("args2") int args2, BridgeCallback callback);
}
```
### Android 接口实现
```java
public class TestService implementation TestService {
@Override
public void testMethodWithCallback(BridgeCallback callback){
callback.onResult("testMethodWithCallback 回调给 Unity 的参数");
}
@Override
public void testMethodWithArgsAndCallback(Activity activity, String appId,int args2, BridgeCallback callback){
callback.onResult("testMethodWithArgsAndCallback 回调给 Unity 的参数");
}
}
```
### iOS 接口定义
> iOS 方法名通过反射获取到的为 `args1:args2:bridgeCallback` ,所以 iOS 的方法定义与 Android 略有不同。
- 类名必须同 Android `@BridgeService` 所修饰的类名一致。
- 参数名例如 `args1`、`args2` 必须同 Android `@BridgeParam` 修饰的一致,用于回调的 `iOS` 闭包的参数名必须为 `bridgeCallback`
- 当参数个数仅为 0 或者 仅为 闭包时,方法名必须同 Android `@BridgeMethod` 修饰的方法一致。
```objectivec
@interface TestService
// 匹配的是 Android 中 testMethodWithCallback 方法
+(void) testMethodWithCallback:(void (^)(NSString *result))callback;
// 匹配的是 Android 中 testMethodWithArgsAndCallback 方法
+(void) args1:(NSString*)args1 args2:(NSNumber*)args2 bridgeCallback:(void (^)(NSString *result))callback;
@end
```
### iOS 接口实现
```objectivec
@implementation TestService
+(void) testMethodWithCallback:(void (^)(NSString *result)) callback{
callback(@"testMethodWithCallback 回调给 Unity 的参数");
}
+(void) args1:(NSString*)args1 args2:(NSNumber*)args2 bridgeCallback:(void (^)(NSString *result))callback{
callback(@"testMethodWithArgsAndCallback 回调给 Unity 的参数");
}
@end
```
### Unity 调用上文中定义的 Android、iOS 接口
#### 1.初始化
```c#
// Android 初始化
//CLZ_NAME 和IMP_NAME为 接口以及实现类的全路径包名 例如com.tds.bridge.TestServicecom.tds.bridge.TestServiceImpl
EngineBridge.GetInstance().Register(CLZ_NAME, IMP_NAME);
// iOS 无需初始化
```
#### 2.调用方法
`Bridge.CallHandler` 为异步方法,执行线程的流程为:
Unity Thread -> Native MainThread -> Execute Function -> Unity Thread
所以执行 `CallHandler` 的 Thread 和 `Action<Result>` 的 Thread 都为 Unity 当前 Thread。
```c#
var command = new Command.Builder()
.Service("TestService") // @BridgeService 值以及 iOS 类名
.Method("testMethodWithArgsAndCallback") // @BridgeMethod 值 以及 iOS 方法名
.Args("args1","value") // @BridgeParam 值 以及 iOS 参数名
.Args("args2",1) // 同上
.Callback(true) // 是否需要添加 BridgeCallback
.OnceTime(true) // 当前 BridgeCallback 是否常驻内存
.CommandBuilder();
// 需要回调
EngineBridge.GetInstance().CallHandler(command,result=>{
if(EngineBridge.CheckResult(result)){
// 桥接调用成功
// 当前 Content 则为 Android、iOS 通过 BridgeCallback 传给 Unity 的值
var content = result.content;
}
});
// 不需要回调
EngineBridge.GetInstance().CallHandler(command);
```
## 二、Android 、iOS 调用 Unity
鉴于 TapSDK 3.1.+ 之后Android 与 iOS 需要同步 `TapBootstrap``TDSUser` 的部分参数,所以 `TapCommon` 在当前版本支持了原生简单的调用 Unity 接口。
以下以 Android、iOS 需要 Unity 提供 `sessionToken` 以及 `objectId` 为例
### Unity 实现 ITapPropertiesProxy 接口并注册
```c#
public class SessionTokenProxy:ITapPropertiesProxy{
public string GetProperties(){
return "sessionToken-kafjaskldfjasjdhfajkdfajdfas";
}
}
public class ObjectIdProxy:ITapPropertiesProxy {
public string GetProperties(){
return "objectId-dafasdfad";
}
}
// 通过 TapCommon 注册 Native 需要调用的接口
TapCommon.RegisterProperties("sessionToken",new SessionTokenProxy());
TapCommon.RegisterProperties("objectid",new ObjectIdProxy());
```
### Android、iOS 调用 Unity 实现的 ITapPropertiesProxy 来获取所需要的值
Android 获取 `sessionToken` 以及 `objectId`
```java
String sessionToken = TapPropertiesHolder.INSTANCE.getProperty("sessionToken");
String objectId = TapPropertiesHolder.INSTANCE.getProperty("objectId");
```
iOS 获取 `sessionToken` 以及 `objectId`
```objectivec
NSString* sessionToken = [[TapPropertiesHolder shareInstance] getProperty:@"sessionToken"];
NSString* objectId = [[TapPropertiesHolder shareInstance] getProperty:@"objectId"];
```

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c2be0874429944a43820d92aa06185f4
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

89
Documentation/README.md Normal file
View File

@ -0,0 +1,89 @@
## TapTap.Common
### 接口描述
#### 1.获取地区
```c#
TapCommon.GetRegionCode(isMainland =>
{
// true 中国大陆 false 非中国大陆
});
```
#### 2. TapTap 是否安装
```c#
TapCommon.IsTapTapInstalled(installed =>
{
// true 安装 false 未安装
});
```
#### 3. TapTap IO 是否安装
```c#
TapCommon.IsTapTapGlobalInstalled(installed =>
{
// true 安装 false 未安装
});
```
### Android 独占方法
#### 4. 在 TapTap 更新游戏
```c#
TapCommon.UpdateGameInTapTap(appId,updateSuccess =>
{
// true 更新成功 false 更新失败
});
```
#### 5. 在 TapTap IO 更新游戏
```c#
TapCommon.UpdateGameInTapGlobal(appId,updateSuccess =>
{
// true 更新成功 false 更新失败
});
```
#### 6. 在 TapTap 打开当前游戏的评论区
```c#
TapCommon.OpenReviewInTapTap(appId,openSuccess =>
{
// true 打开评论区 false 打开失败
});
```
#### 6. 在 TapTap IO 打开当前游戏的评论区
```c#
TapCommon.OpenReviewInTapGlobal(appId,openSuccess =>
{
// true 打开评论区 false 打开失败
});
```
#### 7. 唤起 TapTap 客户端更新游戏
appId: 游戏在 TapTap 商店的唯一身份标识
例如https://www.taptap.com/app/187168 ,其中 187168 是 appid.
```c#
// 在 TapTap 客户端更新游戏,失败时通过浏览器打开 Tap 网站对应的游戏页面
// 当你在国内区上架时使用
bool isSuccess = await TapCommon.UpdateGameAndFailToWebInTapTap(string appId);
// 当你在海外区上架时使用
bool isSuccess = await TapCommon.UpdateGameAndFailToWebInTapGlobal(string appId):
```
如果你需要在唤起 Tap 客户端失败时跳转到自己的网页
```c#
bool isSuccess = await TapCommon.UpdateGameAndFailToWebInTapTap(string appId, string webUrl)
bool isSuccess = await TapCommon.UpdateGameAndFailToWebInTapGlobal(string appId, string webUrl)
```

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1d7008a3a22e45a4bfe9605e6d050a29
timeCreated: 1616744132

8
Editor.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 28e2e71fed1414ad3978a4e5575065f6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,14 @@
using UnityEditor;
namespace TapTap.Common.Editor {
public static class BuildTargetUtils {
public static bool IsSupportMobile(BuildTarget platform) {
return platform == BuildTarget.iOS || platform == BuildTarget.Android;
}
public static bool IsSupportStandalone(BuildTarget platform) {
return platform == BuildTarget.StandaloneOSX ||
platform == BuildTarget.StandaloneWindows || platform == BuildTarget.StandaloneWindows64;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: da005b5e251334d388fe38e6978890cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,70 @@
using System.Collections.Generic;
using System.IO;
using System.Xml;
using UnityEngine;
using UnityEditor;
namespace TapTap.Common.Editor {
public class LinkedAssembly {
public string Fullname { get; set; }
public string[] Types { get; set; }
}
public class LinkXMLGenerator {
public static void Generate(string path, IEnumerable<LinkedAssembly> assemblies) {
DirectoryInfo parent = Directory.GetParent(path);
if (!parent.Exists) {
Directory.CreateDirectory(parent.FullName);
}
XmlDocument doc = new XmlDocument();
XmlNode rootNode = doc.CreateElement("linker");
doc.AppendChild(rootNode);
foreach (LinkedAssembly assembly in assemblies) {
XmlNode assemblyNode = doc.CreateElement("assembly");
XmlAttribute fullnameAttr = doc.CreateAttribute("fullname");
fullnameAttr.Value = assembly.Fullname;
assemblyNode.Attributes.Append(fullnameAttr);
if (assembly.Types?.Length > 0) {
foreach (string type in assembly.Types) {
XmlNode typeNode = doc.CreateElement("type");
XmlAttribute typeFullnameAttr = doc.CreateAttribute("fullname");
typeFullnameAttr.Value = type;
typeNode.Attributes.Append(typeFullnameAttr);
XmlAttribute typePreserveAttr = doc.CreateAttribute("preserve");
typePreserveAttr.Value = "all";
typeNode.Attributes.Append(typePreserveAttr);
assemblyNode.AppendChild(typeNode);
}
} else {
XmlAttribute preserveAttr = doc.CreateAttribute("preserve");
preserveAttr.Value = "all";
assemblyNode.Attributes.Append(preserveAttr);
}
rootNode.AppendChild(assemblyNode);
}
doc.Save(path);
AssetDatabase.Refresh();
Debug.Log($"Generate {path} done.");
Debug.Log(doc.OuterXml);
}
public static void Delete(string path) {
if (File.Exists(path)) {
File.Delete(path);
AssetDatabase.Refresh();
}
Debug.Log($"Delete {path} done.");
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c63ed7a6afba54761aca6c388df097e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

954
Editor/Plist.cs Normal file
View File

@ -0,0 +1,954 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
namespace TapTap.Common.Editor
{
public static class Plist
{
private static List<int> offsetTable = new List<int>();
private static List<byte> objectTable = new List<byte>();
private static int refCount;
private static int objRefSize;
private static int offsetByteSize;
private static long offsetTableOffset;
#region Public Functions
public static object readPlist(string path)
{
using (FileStream f = new FileStream(path, FileMode.Open, FileAccess.Read))
{
return readPlist(f, plistType.Auto);
}
}
public static object readPlistSource(string source)
{
return readPlist(System.Text.Encoding.UTF8.GetBytes(source));
}
public static object readPlist(byte[] data)
{
return readPlist(new MemoryStream(data), plistType.Auto);
}
public static plistType getPlistType(Stream stream)
{
byte[] magicHeader = new byte[8];
stream.Read(magicHeader, 0, 8);
if (BitConverter.ToInt64(magicHeader, 0) == 3472403351741427810)
{
return plistType.Binary;
}
else
{
return plistType.Xml;
}
}
public static object readPlist(Stream stream, plistType type)
{
if (type == plistType.Auto)
{
type = getPlistType(stream);
stream.Seek(0, SeekOrigin.Begin);
}
if (type == plistType.Binary)
{
using (BinaryReader reader = new BinaryReader(stream))
{
byte[] data = reader.ReadBytes((int) reader.BaseStream.Length);
return readBinary(data);
}
}
else
{
XmlDocument xml = new XmlDocument();
xml.XmlResolver = null;
xml.Load(stream);
return readXml(xml);
}
}
public static void writeXml(object value, string path)
{
using (StreamWriter writer = new StreamWriter(path))
{
writer.Write(writeXml(value));
}
}
public static void writeXml(object value, Stream stream)
{
using (StreamWriter writer = new StreamWriter(stream))
{
writer.Write(writeXml(value));
}
}
public static string writeXml(object value)
{
using (MemoryStream ms = new MemoryStream())
{
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
xmlWriterSettings.Encoding = new System.Text.UTF8Encoding(false);
xmlWriterSettings.ConformanceLevel = ConformanceLevel.Document;
xmlWriterSettings.Indent = true;
using (XmlWriter xmlWriter = XmlWriter.Create(ms, xmlWriterSettings))
{
xmlWriter.WriteStartDocument();
//xmlWriter.WriteComment("DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" " + "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"");
xmlWriter.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN",
"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
xmlWriter.WriteStartElement("plist");
xmlWriter.WriteAttributeString("version", "1.0");
compose(value, xmlWriter);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
xmlWriter.Close();
return System.Text.Encoding.UTF8.GetString(ms.ToArray());
}
}
}
public static void writeBinary(object value, string path)
{
using (BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.Create)))
{
writer.Write(writeBinary(value));
}
}
public static void writeBinary(object value, Stream stream)
{
using (BinaryWriter writer = new BinaryWriter(stream))
{
writer.Write(writeBinary(value));
}
}
public static byte[] writeBinary(object value)
{
offsetTable.Clear();
objectTable.Clear();
refCount = 0;
objRefSize = 0;
offsetByteSize = 0;
offsetTableOffset = 0;
//Do not count the root node, subtract by 1
int totalRefs = countObject(value) - 1;
refCount = totalRefs;
objRefSize = RegulateNullBytes(BitConverter.GetBytes(refCount)).Length;
composeBinary(value);
writeBinaryString("bplist00", false);
offsetTableOffset = (long) objectTable.Count;
offsetTable.Add(objectTable.Count - 8);
offsetByteSize = RegulateNullBytes(BitConverter.GetBytes(offsetTable[offsetTable.Count - 1])).Length;
List<byte> offsetBytes = new List<byte>();
offsetTable.Reverse();
for (int i = 0; i < offsetTable.Count; i++)
{
offsetTable[i] = objectTable.Count - offsetTable[i];
byte[] buffer = RegulateNullBytes(BitConverter.GetBytes(offsetTable[i]), offsetByteSize);
Array.Reverse(buffer);
offsetBytes.AddRange(buffer);
}
objectTable.AddRange(offsetBytes);
objectTable.AddRange(new byte[6]);
objectTable.Add(Convert.ToByte(offsetByteSize));
objectTable.Add(Convert.ToByte(objRefSize));
var a = BitConverter.GetBytes((long) totalRefs + 1);
Array.Reverse(a);
objectTable.AddRange(a);
objectTable.AddRange(BitConverter.GetBytes((long) 0));
a = BitConverter.GetBytes(offsetTableOffset);
Array.Reverse(a);
objectTable.AddRange(a);
return objectTable.ToArray();
}
#endregion
#region Private Functions
private static object readXml(XmlDocument xml)
{
XmlNode rootNode = xml.DocumentElement.ChildNodes[0];
return parse(rootNode);
}
private static object readBinary(byte[] data)
{
offsetTable.Clear();
List<byte> offsetTableBytes = new List<byte>();
objectTable.Clear();
refCount = 0;
objRefSize = 0;
offsetByteSize = 0;
offsetTableOffset = 0;
List<byte> bList = new List<byte>(data);
List<byte> trailer = bList.GetRange(bList.Count - 32, 32);
parseTrailer(trailer);
objectTable = bList.GetRange(0, (int) offsetTableOffset);
offsetTableBytes = bList.GetRange((int) offsetTableOffset, bList.Count - (int) offsetTableOffset - 32);
parseOffsetTable(offsetTableBytes);
return parseBinary(0);
}
private static Dictionary<string, object> parseDictionary(XmlNode node)
{
XmlNodeList children = node.ChildNodes;
if (children.Count % 2 != 0)
{
throw new DataMisalignedException("Dictionary elements must have an even number of child nodes");
}
Dictionary<string, object> dict = new Dictionary<string, object>();
for (int i = 0; i < children.Count; i += 2)
{
XmlNode keynode = children[i];
XmlNode valnode = children[i + 1];
if (keynode.Name != "key")
{
throw new ApplicationException("expected a key node");
}
object result = parse(valnode);
if (result != null)
{
dict.Add(keynode.InnerText, result);
}
}
return dict;
}
private static List<object> parseArray(XmlNode node)
{
List<object> array = new List<object>();
foreach (XmlNode child in node.ChildNodes)
{
object result = parse(child);
if (result != null)
{
array.Add(result);
}
}
return array;
}
private static void composeArray(List<object> value, XmlWriter writer)
{
writer.WriteStartElement("array");
foreach (object obj in value)
{
compose(obj, writer);
}
writer.WriteEndElement();
}
private static object parse(XmlNode node)
{
switch (node.Name)
{
case "dict":
return parseDictionary(node);
case "array":
return parseArray(node);
case "string":
return node.InnerText;
case "integer":
// int result;
//int.TryParse(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo, out result);
return Convert.ToInt32(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo);
case "real":
return Convert.ToDouble(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo);
case "false":
return false;
case "true":
return true;
case "null":
return null;
case "date":
return XmlConvert.ToDateTime(node.InnerText, XmlDateTimeSerializationMode.Utc);
case "data":
return Convert.FromBase64String(node.InnerText);
}
throw new ApplicationException(String.Format("Plist Node `{0}' is not supported", node.Name));
}
private static void compose(object value, XmlWriter writer)
{
if (value == null || value is string)
{
writer.WriteElementString("string", value as string);
}
else if (value is int || value is long)
{
writer.WriteElementString("integer",
((int) value).ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
}
else if (value is System.Collections.Generic.Dictionary<string, object> ||
value.GetType().ToString().StartsWith("System.Collections.Generic.Dictionary`2[System.String"))
{
//Convert to Dictionary<string, object>
Dictionary<string, object> dic = value as Dictionary<string, object>;
if (dic == null)
{
dic = new Dictionary<string, object>();
IDictionary idic = (IDictionary) value;
foreach (var key in idic.Keys)
{
dic.Add(key.ToString(), idic[key]);
}
}
writeDictionaryValues(dic, writer);
}
else if (value is List<object>)
{
composeArray((List<object>) value, writer);
}
else if (value is byte[])
{
writer.WriteElementString("data", Convert.ToBase64String((Byte[]) value));
}
else if (value is float || value is double)
{
writer.WriteElementString("real",
((double) value).ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
}
else if (value is DateTime)
{
DateTime time = (DateTime) value;
string theString = XmlConvert.ToString(time, XmlDateTimeSerializationMode.Utc);
writer.WriteElementString("date", theString); //, "yyyy-MM-ddTHH:mm:ssZ"));
}
else if (value is bool)
{
writer.WriteElementString(value.ToString().ToLower(), "");
}
else
{
throw new Exception(String.Format("Value type '{0}' is unhandled", value.GetType().ToString()));
}
}
private static void writeDictionaryValues(Dictionary<string, object> dictionary, XmlWriter writer)
{
writer.WriteStartElement("dict");
foreach (string key in dictionary.Keys)
{
object value = dictionary[key];
writer.WriteElementString("key", key);
compose(value, writer);
}
writer.WriteEndElement();
}
private static int countObject(object value)
{
int count = 0;
switch (value.GetType().ToString())
{
case "System.Collections.Generic.Dictionary`2[System.String,System.Object]":
Dictionary<string, object> dict = (Dictionary<string, object>) value;
foreach (string key in dict.Keys)
{
count += countObject(dict[key]);
}
count += dict.Keys.Count;
count++;
break;
case "System.Collections.Generic.List`1[System.Object]":
List<object> list = (List<object>) value;
foreach (object obj in list)
{
count += countObject(obj);
}
count++;
break;
default:
count++;
break;
}
return count;
}
private static byte[] writeBinaryDictionary(Dictionary<string, object> dictionary)
{
List<byte> buffer = new List<byte>();
List<byte> header = new List<byte>();
List<int> refs = new List<int>();
for (int i = dictionary.Count - 1; i >= 0; i--)
{
var o = new object[dictionary.Count];
dictionary.Values.CopyTo(o, 0);
composeBinary(o[i]);
offsetTable.Add(objectTable.Count);
refs.Add(refCount);
refCount--;
}
for (int i = dictionary.Count - 1; i >= 0; i--)
{
var o = new string[dictionary.Count];
dictionary.Keys.CopyTo(o, 0);
composeBinary(o[i]); //);
offsetTable.Add(objectTable.Count);
refs.Add(refCount);
refCount--;
}
if (dictionary.Count < 15)
{
header.Add(Convert.ToByte(0xD0 | Convert.ToByte(dictionary.Count)));
}
else
{
header.Add(0xD0 | 0xf);
header.AddRange(writeBinaryInteger(dictionary.Count, false));
}
foreach (int val in refs)
{
byte[] refBuffer = RegulateNullBytes(BitConverter.GetBytes(val), objRefSize);
Array.Reverse(refBuffer);
buffer.InsertRange(0, refBuffer);
}
buffer.InsertRange(0, header);
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] composeBinaryArray(List<object> objects)
{
List<byte> buffer = new List<byte>();
List<byte> header = new List<byte>();
List<int> refs = new List<int>();
for (int i = objects.Count - 1; i >= 0; i--)
{
composeBinary(objects[i]);
offsetTable.Add(objectTable.Count);
refs.Add(refCount);
refCount--;
}
if (objects.Count < 15)
{
header.Add(Convert.ToByte(0xA0 | Convert.ToByte(objects.Count)));
}
else
{
header.Add(0xA0 | 0xf);
header.AddRange(writeBinaryInteger(objects.Count, false));
}
foreach (int val in refs)
{
byte[] refBuffer = RegulateNullBytes(BitConverter.GetBytes(val), objRefSize);
Array.Reverse(refBuffer);
buffer.InsertRange(0, refBuffer);
}
buffer.InsertRange(0, header);
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] composeBinary(object obj)
{
byte[] value;
switch (obj.GetType().ToString())
{
case "System.Collections.Generic.Dictionary`2[System.String,System.Object]":
value = writeBinaryDictionary((Dictionary<string, object>) obj);
return value;
case "System.Collections.Generic.List`1[System.Object]":
value = composeBinaryArray((List<object>) obj);
return value;
case "System.Byte[]":
value = writeBinaryByteArray((byte[]) obj);
return value;
case "System.Double":
value = writeBinaryDouble((double) obj);
return value;
case "System.Int32":
value = writeBinaryInteger((int) obj, true);
return value;
case "System.String":
value = writeBinaryString((string) obj, true);
return value;
case "System.DateTime":
value = writeBinaryDate((DateTime) obj);
return value;
case "System.Boolean":
value = writeBinaryBool((bool) obj);
return value;
default:
return new byte[0];
}
}
public static byte[] writeBinaryDate(DateTime obj)
{
List<byte> buffer =
new List<byte>(RegulateNullBytes(BitConverter.GetBytes(PlistDateConverter.ConvertToAppleTimeStamp(obj)),
8));
buffer.Reverse();
buffer.Insert(0, 0x33);
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
public static byte[] writeBinaryBool(bool obj)
{
List<byte> buffer = new List<byte>(new byte[1] {(bool) obj ? (byte) 9 : (byte) 8});
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] writeBinaryInteger(int value, bool write)
{
List<byte> buffer = new List<byte>(BitConverter.GetBytes((long) value));
buffer = new List<byte>(RegulateNullBytes(buffer.ToArray()));
while (buffer.Count != Math.Pow(2, Math.Log(buffer.Count) / Math.Log(2)))
buffer.Add(0);
int header = 0x10 | (int) (Math.Log(buffer.Count) / Math.Log(2));
buffer.Reverse();
buffer.Insert(0, Convert.ToByte(header));
if (write)
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] writeBinaryDouble(double value)
{
List<byte> buffer = new List<byte>(RegulateNullBytes(BitConverter.GetBytes(value), 4));
while (buffer.Count != Math.Pow(2, Math.Log(buffer.Count) / Math.Log(2)))
buffer.Add(0);
int header = 0x20 | (int) (Math.Log(buffer.Count) / Math.Log(2));
buffer.Reverse();
buffer.Insert(0, Convert.ToByte(header));
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] writeBinaryByteArray(byte[] value)
{
List<byte> buffer = new List<byte>(value);
List<byte> header = new List<byte>();
if (value.Length < 15)
{
header.Add(Convert.ToByte(0x40 | Convert.ToByte(value.Length)));
}
else
{
header.Add(0x40 | 0xf);
header.AddRange(writeBinaryInteger(buffer.Count, false));
}
buffer.InsertRange(0, header);
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] writeBinaryString(string value, bool head)
{
List<byte> buffer = new List<byte>();
List<byte> header = new List<byte>();
foreach (char chr in value.ToCharArray())
buffer.Add(Convert.ToByte(chr));
if (head)
{
if (value.Length < 15)
{
header.Add(Convert.ToByte(0x50 | Convert.ToByte(value.Length)));
}
else
{
header.Add(0x50 | 0xf);
header.AddRange(writeBinaryInteger(buffer.Count, false));
}
}
buffer.InsertRange(0, header);
objectTable.InsertRange(0, buffer);
return buffer.ToArray();
}
private static byte[] RegulateNullBytes(byte[] value)
{
return RegulateNullBytes(value, 1);
}
private static byte[] RegulateNullBytes(byte[] value, int minBytes)
{
Array.Reverse(value);
List<byte> bytes = new List<byte>(value);
for (int i = 0; i < bytes.Count; i++)
{
if (bytes[i] == 0 && bytes.Count > minBytes)
{
bytes.Remove(bytes[i]);
i--;
}
else
break;
}
if (bytes.Count < minBytes)
{
int dist = minBytes - bytes.Count;
for (int i = 0; i < dist; i++)
bytes.Insert(0, 0);
}
value = bytes.ToArray();
Array.Reverse(value);
return value;
}
private static void parseTrailer(List<byte> trailer)
{
offsetByteSize = BitConverter.ToInt32(RegulateNullBytes(trailer.GetRange(6, 1).ToArray(), 4), 0);
objRefSize = BitConverter.ToInt32(RegulateNullBytes(trailer.GetRange(7, 1).ToArray(), 4), 0);
byte[] refCountBytes = trailer.GetRange(12, 4).ToArray();
Array.Reverse(refCountBytes);
refCount = BitConverter.ToInt32(refCountBytes, 0);
byte[] offsetTableOffsetBytes = trailer.GetRange(24, 8).ToArray();
Array.Reverse(offsetTableOffsetBytes);
offsetTableOffset = BitConverter.ToInt64(offsetTableOffsetBytes, 0);
}
private static void parseOffsetTable(List<byte> offsetTableBytes)
{
for (int i = 0; i < offsetTableBytes.Count; i += offsetByteSize)
{
byte[] buffer = offsetTableBytes.GetRange(i, offsetByteSize).ToArray();
Array.Reverse(buffer);
offsetTable.Add(BitConverter.ToInt32(RegulateNullBytes(buffer, 4), 0));
}
}
private static object parseBinaryDictionary(int objRef)
{
Dictionary<string, object> buffer = new Dictionary<string, object>();
List<int> refs = new List<int>();
int refCount = 0;
int refStartPosition;
refCount = getCount(offsetTable[objRef], out refStartPosition);
if (refCount < 15)
refStartPosition = offsetTable[objRef] + 1;
else
refStartPosition = offsetTable[objRef] + 2 +
RegulateNullBytes(BitConverter.GetBytes(refCount), 1).Length;
for (int i = refStartPosition; i < refStartPosition + refCount * 2 * objRefSize; i += objRefSize)
{
byte[] refBuffer = objectTable.GetRange(i, objRefSize).ToArray();
Array.Reverse(refBuffer);
refs.Add(BitConverter.ToInt32(RegulateNullBytes(refBuffer, 4), 0));
}
for (int i = 0; i < refCount; i++)
{
buffer.Add((string) parseBinary(refs[i]), parseBinary(refs[i + refCount]));
}
return buffer;
}
private static object parseBinaryArray(int objRef)
{
List<object> buffer = new List<object>();
List<int> refs = new List<int>();
int refCount = 0;
int refStartPosition;
refCount = getCount(offsetTable[objRef], out refStartPosition);
if (refCount < 15)
refStartPosition = offsetTable[objRef] + 1;
else
//The following integer has a header aswell so we increase the refStartPosition by two to account for that.
refStartPosition = offsetTable[objRef] + 2 +
RegulateNullBytes(BitConverter.GetBytes(refCount), 1).Length;
for (int i = refStartPosition; i < refStartPosition + refCount * objRefSize; i += objRefSize)
{
byte[] refBuffer = objectTable.GetRange(i, objRefSize).ToArray();
Array.Reverse(refBuffer);
refs.Add(BitConverter.ToInt32(RegulateNullBytes(refBuffer, 4), 0));
}
for (int i = 0; i < refCount; i++)
{
buffer.Add(parseBinary(refs[i]));
}
return buffer;
}
private static int getCount(int bytePosition, out int newBytePosition)
{
byte headerByte = objectTable[bytePosition];
byte headerByteTrail = Convert.ToByte(headerByte & 0xf);
int count;
if (headerByteTrail < 15)
{
count = headerByteTrail;
newBytePosition = bytePosition + 1;
}
else
count = (int) parseBinaryInt(bytePosition + 1, out newBytePosition);
return count;
}
private static object parseBinary(int objRef)
{
byte header = objectTable[offsetTable[objRef]];
switch (header & 0xF0)
{
case 0:
{
//If the byte is
//0 return null
//9 return true
//8 return false
return (objectTable[offsetTable[objRef]] == 0)
? (object) null
: ((objectTable[offsetTable[objRef]] == 9) ? true : false);
}
case 0x10:
{
return parseBinaryInt(offsetTable[objRef]);
}
case 0x20:
{
return parseBinaryReal(offsetTable[objRef]);
}
case 0x30:
{
return parseBinaryDate(offsetTable[objRef]);
}
case 0x40:
{
return parseBinaryByteArray(offsetTable[objRef]);
}
case 0x50: //String ASCII
{
return parseBinaryAsciiString(offsetTable[objRef]);
}
case 0x60: //String Unicode
{
return parseBinaryUnicodeString(offsetTable[objRef]);
}
case 0xD0:
{
return parseBinaryDictionary(objRef);
}
case 0xA0:
{
return parseBinaryArray(objRef);
}
}
throw new Exception("This type is not supported");
}
public static object parseBinaryDate(int headerPosition)
{
byte[] buffer = objectTable.GetRange(headerPosition + 1, 8).ToArray();
Array.Reverse(buffer);
double appleTime = BitConverter.ToDouble(buffer, 0);
DateTime result = PlistDateConverter.ConvertFromAppleTimeStamp(appleTime);
return result;
}
private static object parseBinaryInt(int headerPosition)
{
int output;
return parseBinaryInt(headerPosition, out output);
}
private static object parseBinaryInt(int headerPosition, out int newHeaderPosition)
{
byte header = objectTable[headerPosition];
int byteCount = (int) Math.Pow(2, header & 0xf);
byte[] buffer = objectTable.GetRange(headerPosition + 1, byteCount).ToArray();
Array.Reverse(buffer);
//Add one to account for the header byte
newHeaderPosition = headerPosition + byteCount + 1;
return BitConverter.ToInt32(RegulateNullBytes(buffer, 4), 0);
}
private static object parseBinaryReal(int headerPosition)
{
byte header = objectTable[headerPosition];
int byteCount = (int) Math.Pow(2, header & 0xf);
byte[] buffer = objectTable.GetRange(headerPosition + 1, byteCount).ToArray();
Array.Reverse(buffer);
return BitConverter.ToDouble(RegulateNullBytes(buffer, 8), 0);
}
private static object parseBinaryAsciiString(int headerPosition)
{
int charStartPosition;
int charCount = getCount(headerPosition, out charStartPosition);
var buffer = objectTable.GetRange(charStartPosition, charCount);
return buffer.Count > 0 ? Encoding.ASCII.GetString(buffer.ToArray()) : string.Empty;
}
private static object parseBinaryUnicodeString(int headerPosition)
{
int charStartPosition;
int charCount = getCount(headerPosition, out charStartPosition);
charCount = charCount * 2;
byte[] buffer = new byte[charCount];
byte one, two;
for (int i = 0; i < charCount; i += 2)
{
one = objectTable.GetRange(charStartPosition + i, 1)[0];
two = objectTable.GetRange(charStartPosition + i + 1, 1)[0];
if (BitConverter.IsLittleEndian)
{
buffer[i] = two;
buffer[i + 1] = one;
}
else
{
buffer[i] = one;
buffer[i + 1] = two;
}
}
return Encoding.Unicode.GetString(buffer);
}
private static object parseBinaryByteArray(int headerPosition)
{
int byteStartPosition;
int byteCount = getCount(headerPosition, out byteStartPosition);
return objectTable.GetRange(byteStartPosition, byteCount).ToArray();
}
#endregion
}
public enum plistType
{
Auto,
Binary,
Xml
}
public static class PlistDateConverter
{
public static long timeDifference = 978307200;
public static long GetAppleTime(long unixTime)
{
return unixTime - timeDifference;
}
public static long GetUnixTime(long appleTime)
{
return appleTime + timeDifference;
}
public static DateTime ConvertFromAppleTimeStamp(double timestamp)
{
DateTime origin = new DateTime(2001, 1, 1, 0, 0, 0, 0);
return origin.AddSeconds(timestamp);
}
public static double ConvertToAppleTimeStamp(DateTime date)
{
DateTime begin = new DateTime(2001, 1, 1, 0, 0, 0, 0);
TimeSpan diff = date - begin;
return Math.Floor(diff.TotalSeconds);
}
}
}

3
Editor/Plist.cs.meta Normal file
View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 66eefeda055244c784769597b08e679e
timeCreated: 1617120740

View File

@ -0,0 +1,119 @@
using System;
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
namespace TapTap.Common.Editor {
/// <summary>
/// 模块 SDK 生成 link.xml 构建过程
/// </summary>
public abstract class SDKLinkProcessBuild : IPreprocessBuildWithReport, IPostprocessBuildWithReport {
/// <summary>
/// 执行顺序
/// </summary>
public abstract int callbackOrder { get; }
/// <summary>
/// 生成 link.xml 路径
/// </summary>
public abstract string LinkPath { get; }
/// <summary>
/// 防止被裁剪的 Assembly
/// </summary>
public abstract LinkedAssembly[] LinkedAssemblies { get; }
/// <summary>
/// 执行平台委托
/// </summary>
public abstract Func<BuildReport, bool> IsTargetPlatform { get; }
/// <summary>
/// 构建时忽略目录,目前主要是 PC 内置浏览器 Vuplex
/// </summary>
public virtual string[] BuildingIgnorePaths => null;
/// <summary>
/// 构建前处理
/// </summary>
/// <param name="report"></param>
public void OnPreprocessBuild(BuildReport report) {
if (!IsTargetPlatform.Invoke(report)) {
return;
}
Application.logMessageReceived += OnBuildError;
IgnorePaths();
string linkPath = Path.Combine(Application.dataPath, LinkPath);
LinkXMLGenerator.Generate(linkPath, LinkedAssemblies);
}
/// <summary>
/// 构建后处理
/// </summary>
/// <param name="report"></param>
public void OnPostprocessBuild(BuildReport report) {
if (!IsTargetPlatform.Invoke(report)) {
return;
}
Application.logMessageReceived -= OnBuildError;
RecoverIgnoredPaths();
string linkPath = Path.Combine(Application.dataPath, LinkPath);
LinkXMLGenerator.Delete(linkPath);
}
/// <summary>
/// 错误日志回调
/// </summary>
/// <param name="condition"></param>
/// <param name="stacktrace"></param>
/// <param name="logType"></param>
private void OnBuildError(string condition, string stacktrace, LogType logType) {
// TRICK: 通过捕获错误日志来监听打包错误事件
if (logType == LogType.Error) {
Application.logMessageReceived -= OnBuildError;
RecoverIgnoredPaths();
}
}
/// <summary>
/// 忽略目录
/// </summary>
private void IgnorePaths() {
if (BuildingIgnorePaths == null) {
return;
}
foreach (string ignorePath in BuildingIgnorePaths) {
if (!Directory.Exists(Path.Combine(Application.dataPath, ignorePath))) {
continue;
}
string ignoreName = Path.GetFileName(ignorePath);
AssetDatabase.RenameAsset(Path.Combine("Assets", ignorePath), $"{ignoreName}~");
}
}
/// <summary>
/// 恢复目录
/// </summary>
private void RecoverIgnoredPaths() {
if (BuildingIgnorePaths == null) {
return;
}
foreach (string ignorePath in BuildingIgnorePaths) {
if (!Directory.Exists(Path.Combine(Application.dataPath, $"{ignorePath}~"))) {
continue;
}
Directory.Move(Path.Combine(Application.dataPath, $"{ignorePath}~"),
Path.Combine(Application.dataPath, $"{ignorePath}"));
AssetDatabase.ImportAsset(Path.Combine("Assets", ignorePath));
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8566d22eb15da4629a4ae0deae37b0fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

232
Editor/TapCommonCompile.cs Normal file
View File

@ -0,0 +1,232 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
namespace TapTap.Common.Editor
{
public static class TapCommonCompile
{
#if UNITY_IOS
public static string GetProjPath(string path)
{
return PBXProject.GetPBXProjectPath(path);
}
public static PBXProject ParseProjPath(string path)
{
var proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(path));
return proj;
}
public static string GetUnityFrameworkTarget(PBXProject proj)
{
#if UNITY_2019_3_OR_NEWER
string target = proj.GetUnityFrameworkTargetGuid();
return target;
#endif
var unityPhoneTarget = proj.TargetGuidByName("Unity-iPhone");
return unityPhoneTarget;
}
public static string GetUnityTarget(PBXProject proj)
{
#if UNITY_2019_3_OR_NEWER
string target = proj.GetUnityMainTargetGuid();
return target;
#endif
var unityPhoneTarget = proj.TargetGuidByName("Unity-iPhone");
return unityPhoneTarget;
}
public static bool CheckTarget(string target)
{
return string.IsNullOrEmpty(target);
}
public static bool HandlerIOSSetting(string path, string appDataPath, string resourceName,
string modulePackageName,
string moduleName, string[] bundleNames, string target, string projPath, PBXProject proj)
{
var resourcePath = Path.Combine(path, resourceName);
var parentFolder = Directory.GetParent(appDataPath).FullName;
Debug.Log($"ProjectFolder path:{parentFolder}");
if (Directory.Exists(resourcePath))
{
Directory.Delete(resourcePath, true);
}
Directory.CreateDirectory(resourcePath);
var remotePackagePath =
TapFileHelper.FilterFileByPrefix(parentFolder + "/Library/PackageCache/", $"{modulePackageName}@");
var assetLocalPackagePath = TapFileHelper.FilterFileByPrefix(parentFolder + "/Assets/TapTap/", moduleName);
var localPackagePath = TapFileHelper.FilterFileByPrefix(parentFolder, moduleName);
var tdsResourcePath = "";
if (!string.IsNullOrEmpty(remotePackagePath))
{
tdsResourcePath = remotePackagePath;
}
else if (!string.IsNullOrEmpty(assetLocalPackagePath))
{
tdsResourcePath = assetLocalPackagePath;
}
else if (!string.IsNullOrEmpty(localPackagePath))
{
tdsResourcePath = localPackagePath;
}
if (string.IsNullOrEmpty(tdsResourcePath))
{
Debug.LogError("tdsResourcePath is NUll");
return false;
}
tdsResourcePath = $"{tdsResourcePath}/Plugins/iOS/Resource";
Debug.Log($"Find {moduleName} path:{tdsResourcePath}");
if (!Directory.Exists(tdsResourcePath))
{
Debug.LogError($"Can't Find {bundleNames}");
return false;
}
TapFileHelper.CopyAndReplaceDirectory(tdsResourcePath, resourcePath);
foreach (var name in bundleNames)
{
proj.AddFileToBuild(target,
proj.AddFile(Path.Combine(resourcePath, name), Path.Combine(resourcePath, name),
PBXSourceTree.Source));
}
File.WriteAllText(projPath, proj.WriteToString());
return true;
}
public static bool HandlerPlist(string pathToBuildProject, string infoPlistPath, bool macos = false)
{
// #if UNITY_2020_1_OR_NEWER
// var macosXCodePlistPath =
// $"{pathToBuildProject}/{PlayerSettings.productName}/Info.plist";
// #elif UNITY_2019_1_OR_NEWER
// var macosXCodePlistPath =
// $"{Path.GetDirectoryName(pathToBuildProject)}/{PlayerSettings.productName}/Info.plist";
// #endif
string plistPath;
if (pathToBuildProject.EndsWith(".app"))
{
plistPath = $"{pathToBuildProject}/Contents/Info.plist";
}
else
{
var macosXCodePlistPath =
$"{Path.GetDirectoryName(pathToBuildProject)}/{PlayerSettings.productName}/Info.plist";
if (!File.Exists(macosXCodePlistPath))
{
macosXCodePlistPath = $"{pathToBuildProject}/{PlayerSettings.productName}/Info.plist";
}
plistPath = !macos
? pathToBuildProject + "/Info.plist"
: macosXCodePlistPath;
}
Debug.Log($"plist path:{plistPath}");
var plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
var rootDic = plist.root;
var items = new List<string>
{
"tapsdk",
"tapiosdk",
};
if (!(rootDic["LSApplicationQueriesSchemes"] is PlistElementArray plistElementList))
{
plistElementList = rootDic.CreateArray("LSApplicationQueriesSchemes");
}
foreach (var t in items)
{
plistElementList.AddString(t);
}
if (string.IsNullOrEmpty(infoPlistPath)) return false;
var dic = (Dictionary<string, object>) Plist.readPlist(infoPlistPath);
var taptapId = "";
foreach (var item in dic)
{
if (item.Key.Equals("taptap"))
{
var taptapDic = (Dictionary<string, object>) item.Value;
foreach (var taptapItem in taptapDic.Where(taptapItem => taptapItem.Key.Equals("client_id")))
{
taptapId = (string) taptapItem.Value;
}
}
else
{
rootDic.SetString(item.Key, item.Value.ToString());
}
}
//添加url
var dict = plist.root.AsDict();
if (!(dict["CFBundleURLTypes"] is PlistElementArray array))
{
array = dict.CreateArray("CFBundleURLTypes");
}
if (!macos)
{
var dict2 = array.AddDict();
dict2.SetString("CFBundleURLName", "TapTap");
var array2 = dict2.CreateArray("CFBundleURLSchemes");
array2.AddString($"tt{taptapId}");
}
else
{
var dict2 = array.AddDict();
dict2.SetString("CFBundleURLName", "TapWeb");
var array2 = dict2.CreateArray("CFBundleURLSchemes");
array2.AddString($"open-taptap-{taptapId}");
}
Debug.Log("TapSDK change plist Success");
File.WriteAllText(plistPath, plist.WriteToString());
return true;
}
public static string GetValueFromPlist(string infoPlistPath, string key)
{
if (infoPlistPath == null)
{
return null;
}
var dic = (Dictionary<string, object>) Plist.readPlist(infoPlistPath);
return (from item in dic where item.Key.Equals(key) select (string) item.Value).FirstOrDefault();
}
#endif
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c5475af505e04119831448fe963f9c2c
timeCreated: 1617120740

View File

@ -0,0 +1,71 @@
using System.IO;
using UnityEditor;
# if UNITY_IOS
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
#endif
using UnityEngine;
namespace TapTap.Common.Editor
{
# if UNITY_IOS
public static class TapCommonIOSProcessor
{
// 添加标签unity导出工程后自动执行该函数
[PostProcessBuild(99)]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget != BuildTarget.iOS) return;
// 获得工程路径
var projPath = TapCommonCompile.GetProjPath(path);
var proj = TapCommonCompile.ParseProjPath(projPath);
var target = TapCommonCompile.GetUnityTarget(proj);
var unityFrameworkTarget = TapCommonCompile.GetUnityFrameworkTarget(proj);
if (TapCommonCompile.CheckTarget(target))
{
Debug.LogError("Unity-iPhone is NUll");
return;
}
proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
proj.AddBuildProperty(unityFrameworkTarget, "OTHER_LDFLAGS", "-ObjC");
proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
proj.SetBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
proj.SetBuildProperty(target, "SWIFT_VERSION", "5.0");
proj.SetBuildProperty(target, "CLANG_ENABLE_MODULES", "YES");
proj.SetBuildProperty(unityFrameworkTarget, "ENABLE_BITCODE", "NO");
proj.SetBuildProperty(unityFrameworkTarget, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
proj.SetBuildProperty(unityFrameworkTarget, "SWIFT_VERSION", "5.0");
proj.SetBuildProperty(unityFrameworkTarget, "CLANG_ENABLE_MODULES", "YES");
proj.AddFrameworkToProject(unityFrameworkTarget, "MobileCoreServices.framework", false);
proj.AddFrameworkToProject(unityFrameworkTarget, "WebKit.framework", false);
proj.AddFrameworkToProject(unityFrameworkTarget, "Security.framework", false);
proj.AddFrameworkToProject(unityFrameworkTarget, "SystemConfiguration.framework", false);
proj.AddFrameworkToProject(unityFrameworkTarget, "CoreTelephony.framework", false);
proj.AddFrameworkToProject(unityFrameworkTarget, "SystemConfiguration.framework", false);
proj.AddFileToBuild(unityFrameworkTarget,
proj.AddFile("usr/lib/libc++.tbd", "libc++.tbd", PBXSourceTree.Sdk));
if (TapCommonCompile.HandlerIOSSetting(path,
Application.dataPath,
"TapCommonResource",
"com.taptap.tds.common",
"Common",
new[] {"TapCommonResource.bundle"},
target, projPath, proj))
{
Debug.Log("TapCommon add Bundle Success!");
return;
}
Debug.LogError("TapCommon add Bundle Failed!");
}
}
#endif
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 28d4870389ed406eac7c8849da60c644
timeCreated: 1617120740

168
Editor/TapFileHelper.cs Normal file
View File

@ -0,0 +1,168 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace TapTap.Common.Editor
{
public class TapFileHelper : System.IDisposable
{
private string filePath;
public TapFileHelper(string fPath)
{
filePath = fPath;
if (!System.IO.File.Exists(filePath))
{
Debug.LogError(filePath + "路径下文件不存在");
return;
}
}
public void WriteBelow(string below, string text)
{
StreamReader streamReader = new StreamReader(filePath);
string all = streamReader.ReadToEnd();
streamReader.Close();
int beginIndex = all.IndexOf(below, StringComparison.Ordinal);
if (beginIndex == -1)
{
Debug.LogError(filePath + "中没有找到字符串" + below);
return;
}
int endIndex = all.LastIndexOf("\n", beginIndex + below.Length, StringComparison.Ordinal);
all = all.Substring(0, endIndex) + "\n" + text + "\n" + all.Substring(endIndex);
StreamWriter streamWriter = new StreamWriter(filePath);
streamWriter.Write(all);
streamWriter.Close();
}
public void Replace(string below, string newText)
{
StreamReader streamReader = new StreamReader(filePath);
string all = streamReader.ReadToEnd();
streamReader.Close();
int beginIndex = all.IndexOf(below, StringComparison.Ordinal);
if (beginIndex == -1)
{
Debug.LogError(filePath + "中没有找到字符串" + below);
return;
}
all = all.Replace(below, newText);
StreamWriter streamWriter = new StreamWriter(filePath);
streamWriter.Write(all);
streamWriter.Close();
}
public void Dispose()
{
}
public static void CopyAndReplaceDirectory(string srcPath, string dstPath)
{
if (Directory.Exists(dstPath))
Directory.Delete(dstPath, true);
if (File.Exists(dstPath))
File.Delete(dstPath);
Directory.CreateDirectory(dstPath);
foreach (var file in Directory.GetFiles(srcPath))
File.Copy(file, Path.Combine(dstPath, Path.GetFileName(file)));
foreach (var dir in Directory.GetDirectories(srcPath))
CopyAndReplaceDirectory(dir, Path.Combine(dstPath, Path.GetFileName(dir)));
}
public static void DeleteFileBySuffix(string dir, string[] suffix)
{
if (!Directory.Exists(dir))
{
return;
}
foreach (var file in Directory.GetFiles(dir))
{
foreach (var suffixName in suffix)
{
if (file.Contains(suffixName))
{
File.Delete(file);
}
}
}
}
public static string FilterFileByPrefix(string srcPath, string filterName)
{
if (!Directory.Exists(srcPath))
{
return null;
}
foreach (var dir in Directory.GetDirectories(srcPath))
{
string fileName = Path.GetFileName(dir);
if (fileName.StartsWith(filterName))
{
return Path.Combine(srcPath, Path.GetFileName(dir));
}
}
return null;
}
public static string FilterFileBySuffix(string srcPath, string suffix)
{
if (!Directory.Exists(srcPath))
{
return null;
}
foreach (var dir in Directory.GetDirectories(srcPath))
{
string fileName = Path.GetFileName(dir);
if (fileName.StartsWith(suffix))
{
return Path.Combine(srcPath, Path.GetFileName(dir));
}
}
return null;
}
public static FileInfo RecursionFilterFile(string dir, string fileName)
{
List<FileInfo> fileInfoList = new List<FileInfo>();
Director(dir, fileInfoList);
foreach (FileInfo item in fileInfoList)
{
if (fileName.Equals(item.Name))
{
return item;
}
}
return null;
}
public static void Director(string dir, List<FileInfo> list)
{
DirectoryInfo d = new DirectoryInfo(dir);
FileInfo[] files = d.GetFiles();
DirectoryInfo[] directs = d.GetDirectories();
foreach (FileInfo f in files)
{
list.Add(f);
}
foreach (DirectoryInfo dd in directs)
{
Director(dd.FullName, list);
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d1556fcb81944af6a42170d3e1c99269
timeCreated: 1617120740

View File

@ -0,0 +1,18 @@
{
"name": "TapTap.Common.Editor",
"references": [
"GUID:343deaaf83e0cee4ca978e7df0b80d21",
"GUID:2bafac87e7f4b9b418d9448d219b01ab"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 616cea76def2d4f059b94440fc8cc03d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Plugins.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 72ddac62e7598413680ccc6ef4858979
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Plugins/Android.meta Normal file
View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c40d795a083b457fa3d923415533822c
timeCreated: 1616744098

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9c15be9bece843a4b6998999a603f389
timeCreated: 1616744107

Binary file not shown.

View File

@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 9de14e12ad3e145119062ae3a707b8ef
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,75 @@
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"TapTap.Common/1.0.0": {
"dependencies": {
"NETStandard.Library": "2.0.3",
"UnityEditor": "0.0.0.0",
"UnityEngine": "0.0.0.0"
},
"runtime": {
"TapTap.Common.dll": {}
}
},
"Microsoft.NETCore.Platforms/1.1.0": {},
"NETStandard.Library/2.0.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"UnityEditor/0.0.0.0": {
"runtime": {
"UnityEditor.dll": {
"assemblyVersion": "0.0.0.0",
"fileVersion": "0.0.0.0"
}
}
},
"UnityEngine/0.0.0.0": {
"runtime": {
"UnityEngine.dll": {
"assemblyVersion": "0.0.0.0",
"fileVersion": "0.0.0.0"
}
}
}
}
},
"libraries": {
"TapTap.Common/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.NETCore.Platforms/1.1.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
"path": "microsoft.netcore.platforms/1.1.0",
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
},
"NETStandard.Library/2.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"path": "netstandard.library/2.0.3",
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
},
"UnityEditor/0.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"UnityEngine/0.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 73783fbd0117e4f6088bf812d1a568b0
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Plugins/TapTap.Common.dll Normal file

Binary file not shown.

View File

@ -0,0 +1,86 @@
fileFormatVersion: 2
guid: 75f4d9bf431824223b16a7cb0de56fd3
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 0
Exclude Linux64: 0
Exclude OSXUniversal: 0
Exclude Win: 0
Exclude Win64: 0
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: x86_64
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: x86_64
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

BIN
Plugins/TapTap.Common.pdb Normal file

Binary file not shown.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0f443a727b2704d32966d84ec19ee8ee
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Plugins/iOS.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2e935f15b899147eaa8b62cdef502046
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2192f0da58ae410089b7aabfc9375ca4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,69 @@
fileFormatVersion: 2
guid: 862aa0341df21484eb4a08a6ee21f9c3
folderAsset: yes
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 0
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
{
"zh_hans":{
"network_error_click_retry":"网络异常,点击重试"
},
"en":{
"network_error_click_retry":"Network error, click to retry"
},
"zh_hant":{
"network_error_click_retry":"網路異常,點擊重試"
},
"ja":{
"network_error_click_retry":"ネットワークエラーです。もう一度やり直してください"
},
"ko":{
"network_error_click_retry":"네트워크 오류, 다시 시도하기"
},
"th":{
"network_error_click_retry":"พบข้อผิดพลาดในการเชื่อมต่อ กรุณาลองอีกครั้ง"
},
"id":{
"network_error_click_retry":"Jaringan error. Harap coba lagi."
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 79e4f9ebbd71047bb9ab9a85daeb9193
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b90cb19a0ccd14069b203014806a6748
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 19fc6b14a3c6245fb80d172e19bc459f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6b195edcbdd694b0bb422b2f2c4423b9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 21fdeeca33c2d48258227cea39860103
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2f74478f5ddcc4628ad879e8c8f1cc22
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fbf577ace10714238ac825fb2069a5f5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 269ea3a1cfd224d50bbfc20e0b529eb0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4ef285809644943588a98cc1bad12d80
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 497164c4329b345dc9fcf9a603822bd4
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6e4c19f7cee284504ba294c04ddc21ff
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 440bced484e8f4ab28accda051d448f0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
//
// TapDelegate.h
// Unity-iPhone
//
// Created by xe on 2021/7/14.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TapCommonDelegate : NSObject
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 194ed5d2453144ac9b98c5c7cf599e9c
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,33 @@
//
// TapDelegate.m
// Unity-iPhone
//
// Created by xe on 2021/7/14.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
#include "AppDelegateListener.h"
#include "LifeCycleListener.h"
#import "TapCommonDelegate.h"
#import <TapCommonSDK/TDSHandleUrl.h>
@implementation TapCommonDelegate
+(void) load{
static dispatch_once_t onceToken;
dispatch_once(&onceToken,^{
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[nc addObserverForName:kUnityOnOpenURL object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
if ([note.userInfo isKindOfClass: [NSMutableDictionary<NSString*, id> class]]) {
NSURL* url = [note.userInfo objectForKey:@"url"];
[TDSHandleUrl handleOpenURL:url];
}
}];
});
}
@end

View File

@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: 04967bfc53c484d1c81447df7cb1822b
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,69 @@
fileFormatVersion: 2
guid: 2a236b3c23efa4a80b48d344322d8741
folderAsset: yes
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 0
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 323d6713c103c4a6f9630553a66b4ed8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,20 @@
//
// ActionModel.h
// TDSCommon
//
// Created by TapTap-David on 2021/1/19.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ActionModel : NSObject
@property (nonatomic, copy) NSString *click;
@property (nonatomic, copy) NSString *like;
@property (nonatomic, copy) NSString *comment;
@property (nonatomic, copy) NSString *collect;
@property (nonatomic, copy) NSString *impression;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 803057ec5fb7e4ca39c84b8b2cd4b874
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
//
// ComponentMessageDelegate.h
// TapCommonSDK
//
// Created by Bottle K on 2021/5/11.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol ComponentMessageDelegate <NSObject>
- (void)onMessageWithCode:(NSInteger)code extras:(NSDictionary *)extras;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0cce2fde8b64941b8b65faebb23c6d8e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
//
// EngineBridgeError.h
// EngineBridge
//
// Created by xe on 2020/9/28.
// Copyright © 2020 xe. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef NSString *KLTypeStr NS_STRING_ENUM;
FOUNDATION_EXPORT KLTypeStr const COMMAND_PARSE_ERROR;
FOUNDATION_EXPORT KLTypeStr const COMMAND_SERVICE_ERROR;
FOUNDATION_EXPORT KLTypeStr const COMMAND_METHOD_ERROR;
FOUNDATION_EXPORT KLTypeStr const COMMAND_ARGS_ERROR;

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d88342ebf25084e37bfecaf7e1b22b6a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,44 @@
//
// LoginModel.h
// TapCommonSDK
//
// Created by Bottle K on 2021/6/21.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
//登录流程中触发的事件
FOUNDATION_EXPORT NSString *const LOGIN_ACTION_AUTHORIZE_START;
FOUNDATION_EXPORT NSString *const LOGIN_ACTION_TAPTAP_AUTHORIZE_OPEN;
FOUNDATION_EXPORT NSString *const LOGIN_ACTION_TAPTAP_AUTHORIZE_BACK;
FOUNDATION_EXPORT NSString *const LOGIN_ACTION_TAPTAP_AUTHORIZE_TOKEN;
FOUNDATION_EXPORT NSString *const LOGIN_ACTION_TAPTAP_AUTHORIZE_PROFILE;
FOUNDATION_EXPORT NSString *const LOGIN_ACTION_TAPTAP_AUTHORIZE_SUCCESS;
FOUNDATION_EXPORT NSString *const LOGIN_ACTION_TAPTAP_AUTHORIZE_FAIL;
FOUNDATION_EXPORT NSString *const LOGIN_ACTION_TAPTAP_AUTHORIZE_CANCEL;
//登录类型
FOUNDATION_EXPORT NSString *const LOGIN_TYPE_TAPTAP;
FOUNDATION_EXPORT NSString *const LOGIN_TYPE_WEBVIEW;
FOUNDATION_EXPORT NSString *const LOGIN_TYPE_AUTO;
@interface LoginModel : NSObject
//每次登录流程唯一ID
@property (nonatomic, copy) NSString *login_session_id;
//登录流程中触发的事件
@property (nonatomic, copy) NSString *login_action;
//登录类型
@property (nonatomic, copy, nullable) NSString *login_type;
//错误code
@property (nonatomic, copy, nullable) NSString *login_error_code;
//错误message
@property (nonatomic, copy, nullable) NSString *login_error_msg;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 38c715d8b948846a1a9038835f3c0360
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
//
// NSArray+Safe.h
// TapAchievement
//
// Created by TapTap-David on 2020/9/15.
// Copyright © 2020 taptap. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSArray (Safe)
- (void)tds_each:(void (^)(id object, NSUInteger index))block;
- (void)tds_apply:(void (^)(id object, NSUInteger index))block;
- (NSArray *)tds_map:(id (^)(id object, NSUInteger index))block;
- (id)tds_reduce:(id (^)(id accumulated, id object))block;
- (NSArray *)tds_filter:(BOOL (^)(id object, NSUInteger index))block;
- (id)tds_safeObjectAtIndex:(NSUInteger)index;
@end

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fcbc21585106644f0819169e0ec79fac
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
//
// NSBundle+Tools.h
// TDSAchievement
//
// Created by TapTap-David on 2020/8/26.
// Copyright © 2020 taptap. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NSBundle (Tools)
+ (instancetype)tds_bundleName:(NSString *)bundleName aClass:(Class)aClass;
- (NSString *)tds_localizedStringForKey:(NSString *)key value:(NSString *)value;
- (NSString *)tds_localizedStringForKey:(NSString *)key;
- (UIImage *)tds_imageName:(NSString *)imageName;
@end

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: de0ca2dc135c747a9856f17a3b121129
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
//
// NSData+JSON.h
// NativeApp
//
// Created by JiangJiahao on 2018/3/9.
// Copyright © 2018年 JiangJiahao. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSData (JSON)
- (NSArray *)tds_arrayFromJsonData;
- (NSDictionary *)tds_dictionaryFromJsonData;
- (NSString *)tds_stringFromData;
- (NSData *)tds_aes256Encrypt:(NSString *)key;
- (NSData *)tds_aes256Decrypt:(NSString *)key;
@end

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: be5a7b45391a84b6abf4865ecbd54758
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
//
// NSDictionary+JSON.h
// NativeApp
//
// Created by JiangJiahao on 2018/10/11.
// Copyright © 2018 JiangJiahao. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSDictionary (JSON)
- (NSString *)tds_jsonString;
- (NSString *)tds_jsonStringWithoutOptions:(NSJSONWritingOptions)opt;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f03fcc9619a6a40d9b41744e3dd2541f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,24 @@
//
// NSDictionary+TDSSafe.h
// TDSCommon
//
// Created by Insomnia on 2020/10/20.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSDictionary (TDSSafe)
- (BOOL)tds_boolForKey:(NSString *)key;
- (NSInteger)tds_integerForKey:(NSString *)key;
- (NSDictionary *)tds_dicForKey:(NSString *)key;
- (NSString *)tds_stringForKey:(NSString *)key;
- (NSArray *)tds_arrayForKey:(NSString *)key;
- (NSSet *)tds_setForKey:(NSString *)key;
- (NSNumber *)tds_numberForKey:(NSString *)key;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dd6243975bb9c408b9c560255633b519
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
//
// NSError+Ext.h
// TapAchievement
//
// Created by TapTap-David on 2020/9/22.
// Copyright © 2020 taptap. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSError (Ext)
+ (instancetype)errorWithMessage:(NSString *)errorMsg code:(NSInteger)code;
+ (instancetype)errorWithContent:(NSString *)content message:(NSString *)message code:(NSInteger)code;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e71e6f6170e4248799add9b7c9d95eeb
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
//
// NSMutableArray+Safe.h
// TapAchievement
//
// Created by TapTap-David on 2020/9/24.
// Copyright © 2020 taptap. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSMutableArray (Safe)
- (void)tt_safeAddObject:(id)anObject;
- (void)tt_addNonNullObject:(id)anObject;
- (void)tt_safeInsertObject:(id)anObject atIndex:(NSUInteger)index;
- (void)tt_safeReplaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3f0b3c7b6e256437290324bbdcc89d8c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
//
// NSObject+TDSCoding.h
// TDSCommon
//
// Created by Insomnia on 2020/10/20.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSObject (TDSCoding)
/**
*
*/
- (void)tds_decode:(NSCoder *)decoder;
/**
*
*/
- (void)tds_encode:(NSCoder *)encoder;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 87aef2acb11ee408ba55e96594c67a53
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,30 @@
//
// NSObject+TDSModel.h
// TDSCommon
//
// Created by Insomnia on 2020/10/20.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol TDSModel <NSObject>
@optional
+ (NSDictionary *)replacedKeyFromPropertyName;
+ (NSString *)replacedKeyFromPropertyName:(NSString *)propertyName;
+ (NSDictionary *)objectClassInArray;
+ (Class)objectClassInArray:(NSString *)propertyName;
@end
@interface NSObject (TDSModel) <TDSModel>
+ (instancetype)tds_modelWithKeyValues:(id)keyValues;
- (NSDictionary *)tds_keyValues;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4982b90a689c94b07b73fcd242225974
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
//
// NSObject+TDSProperty.h
// TDSCommon
//
// Created by Insomnia on 2020/10/20.
//
#import <Foundation/Foundation.h>
#import <TapCommonSDK/TDSModelHelper.h>
#import <TapCommonSDK/TDSMacros.h>
NS_ASSUME_NONNULL_BEGIN
typedef void (^TDSClassesEnumerator) (Class cls, BOOL *stop);
typedef void (^TDSPropertiesEnumerator) (TDSProperty *property, BOOL *stop);
@interface NSObject (TDSProperty)
+ (void)tds_enumerateProperties:(TDSPropertiesEnumerator)enumerator;
+ (void)tds_enumerateClasses:(TDSClassesEnumerator)enumerator;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b066b8c09e93e4fe59af3cd837c273be
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,34 @@
//
// NSString+Tools.h
// TDS
//
// Created by JiangJiahao on 2018/4/24.
// Copyright © 2018年 dyy. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (Tools)
- (NSString *)tds_URLEncodedString;
- (NSString *)tds_URLDecodedString;
///反转字符串
- (NSString *)tds_reverse;
// MD5 hash of the file on the filesystem specified by path
+ (NSString *)tds_stringWithMD5OfFile:(NSString *)path;
// The string's MD5 hash
- (NSString *)tds_MD5Hash;
// base64
- (NSString *)tds_base64Encode;
- (NSString *)tds_base64Decode;
// aes256
- (NSString *)tds_aes256Encrypt:(NSString *)key;
- (NSString *)tds_aes256Decrypt:(NSString *)key;
/// 是否是空字符串
+ (BOOL)tds_isEmpty:(NSString *)string;
- (NSDictionary *)tds_toDictionary;
@end

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ce424c9f0e2f540d0b5f4d460e645709
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,20 @@
//
// NetworkStateModel.h
// TDSCommon
//
// Created by TapTap-David on 2021/3/23.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface NetworkStateModel : NSObject
@property (nonatomic, copy) NSString *session_id; //每次启动唯一ID
@property (nonatomic, copy) NSString *host; //服务器
@property (nonatomic, assign) NSInteger code; //返回码200成功
@property (nonatomic, assign) CGFloat delay; //网络延迟时间(毫秒)
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 00037c9e679884e24b8ae31917ee4661
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,37 @@
//
// PageModel.h
// TDSCommon
//
// Created by TapTap-David on 2021/1/19.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
//页面唯一id
FOUNDATION_EXPORT NSString *const PAGE_ID_TAPTAP_AUTHORIZE_WEB;
FOUNDATION_EXPORT NSString *const PAGE_ID_TAPTAP_AUTHORIZE_TAPTAPCLIENT;
FOUNDATION_EXPORT NSString *const PAGE_ID_GAME;
//页面别名
FOUNDATION_EXPORT NSString *const PAGE_NAME_TAPTAP_AUTHORIZE_WEB;
FOUNDATION_EXPORT NSString *const PAGE_NAME_TAPTAP_AUTHORIZE_TAPTAPCLIENT;
FOUNDATION_EXPORT NSString *const PAGE_NAME_GAME;
//页面事件名
FOUNDATION_EXPORT NSString *const PAGE_ACTION_APPEAR;
FOUNDATION_EXPORT NSString *const PAGE_ACTION_DISAPPEAR;
@interface PageModel : NSObject
//页面唯一id
@property (nonatomic, copy, nullable) NSString *page_id;
//页面别名
@property (nonatomic, copy, nullable) NSString *page_name;
//页面事件名
@property (nonatomic, copy, nullable) NSString *page_action;
@end
NS_ASSUME_NONNULL_END

Some files were not shown because too many files have changed in this diff Show More