Files
knowledge-kit/Chapter1 - iOS/1.85.md
2020-08-10 20:16:18 +08:00

101 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 统跳
定义:
使用统一的 URL 来描述特定的业务功能,并通过路由映射到任意资源目标,并基于此可实现 rewrite、埋点、监控、灰度、A/B 等功能
iOS非统跳接口调用检测设计方案
工作原理
由于ObjectC语言自身的限制获取编译时的调用关系信息相对较为困难。因此没有一个简便的方法获取到哪些接口调用了SDK中的方法。
ObjectC语言继承自C语言的头文件引用的机制可以作为检测的点。即如果App中调用了SDK中的某个方法那么一定会直接或者间接引用了SDK中的某个头文件。通过检测引用头文件引导iOS开发删除对应SDK的头文件那么应该可以暴露出App中直接调用SDK接口的位置。从而达到辅助检测非统跳接口的目的。
配置文件
配置文件主要用于在检测过程中,提供工程的目录结构相关信息。在生成过程中,提供生成结果文件需要的额外信息。
```YAML
category: login_register_sdk
plist: Example/LoginRegisterSDK/LoginRegisterSDK-Info.plist
workspace: Example/LoginRegisterSDK.xcworkspace
xcodeproj: Example/LoginRegisterSDK.xcodeproj
scheme: LoginRegisterSDK-Example
source_directory: LoginRegisterSDK/
pods_directory: Example/Pods
ignore:
- LoginRegisterSDK/**/*SDK.m
```
调用流程
```objective-c
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ...
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[TNTRouter sharedRouter] manuallyFetchRoutingTableWithCompletion:^(BOOL succeeded) {
}];
});
return YES;
}
```
```objective-c
- (void)manuallyFetchRoutingTableWithCompletion:(TNTManualFetchRoutingTableCompletion)completion {
NSDictionary *params = [self getRouterRequestParams];
[TMTrinityMGetTask manuallyFetchWithKey:TMNeutronRouterRewriteKey
params:params
moduleCallback:^(NSString * _Nullable result, NSError * _Nullable error) {
if (error) return ;
if (result.length == 0) return;
// encryp & json
NSDictionary *routesAndWrites = [self routesAndRewriteForRemoteEncryptedString:result];
// routes is existed
if (routesAndWrites) {
// process routes
[self loadRoutesAndWritesFromRemote:routesAndWrites];
// save decrpy data string
[self saveRemoteRouteString:result];
if(completion) completion(true);
}
} callback:nil];
}
```
# 参考资料
- [iOS performSelector传递两个以上参数](https://www.jianshu.com/p/4118793c88df)
-
之前看代码理解设计太慢了,不清楚设计背景,所以想请教你一下
1. 使用统一的 URL 来描述特定的业务功能,并通过路由映射到任意资源目标,并基于此可实现 rewrite、埋点、监控、灰度、A/B 等功能
如何理解rewrite、埋点、监控、灰度、A/B 等功能。
用统跳 url 后,调用某 SDK ,区分 typeh5、RN、Nativenative 则 runtimeperformSelector
H5、RN 没看到处理逻辑?
2. 通跳的设计背景是什么?解决业务上什么问题?举个例子理解下工作流程
- RoutingTableGenerator.rb 扫描工程 TNT_TARGET写入 Targets.json 的目的是什么?
- DefaultRoutingTableFetcher.rb 调用接口,写入文件
- ProjectConfigurator.rb 调用上述2个脚本写入工程 script
3. TrinityParams 和 TrinityConfigurator 2个 SDK 背景、作用分别是什么?