abb*_*ood 8 xcode objective-c ios swift
我们已经有一个运行良好的应用程序几个月了,然后,这段代码突然中断了:
ViewController.swift
self.tableView.delegate = self.viewModel.tableViewHandler
Run Code Online (Sandbox Code Playgroud)
使用了这段代码
component.swift
public override weak var delegate: UITableViewDelegate? {
get { return super.delegate }
set {
if let del = newValue as? TableViewDelegateProxy {
super.delegate = del
} else if let del = super.delegate as? TableViewDelegateProxy {
del.targetDelegate = newValue
} else {
super.delegate = newValue
}
}
}
Run Code Online (Sandbox Code Playgroud)
我们不知道为什么,但是我们使用以下代码修复了它:
ViewController.swift
self.tableView.fixedDelegate = self.viewModel.tableViewHandler
Run Code Online (Sandbox Code Playgroud)
component.swift
// IMPORTANT NOTE: That is the correct way to set a delegate,
// otherwise overriding `delegate` property fails
public var fixedDelegate: UITableViewDelegate? {
get { return self.delegate }
set {
self.delegateProxy.targetDelegate = newValue
self.delegate = self.delegateProxy
}
}
Run Code Online (Sandbox Code Playgroud)
最初,我们认为后端存在问题(JSON格式不正确或类似问题),但后来我们意识到了以下几点:
我们跳回了Git历史上的许多发行版,并且始终如此,这使我们相信Xcode或Objc / Swift运行时库可能有所更改,这导致了这种怪异。
我们的Xcode IDE中可以进行哪些更改以解释这一点?可能是远程更改或在幕后更改的东西吗?我们如何进一步调试呢?
1)Xcode版本:版本10.1(10B61)
2)Swift版本:
xcrun swift -version
Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
Target: x86_64-apple-darwin18.2.0
Run Code Online (Sandbox Code Playgroud)
3)obj-c库:
otool -L /usr/lib/libobjc.A.dylib
/usr/lib/libobjc.A.dylib:
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 400.17.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
Run Code Online (Sandbox Code Playgroud)
_serverConfiguration.isCodelessEventsEnabled
Run Code Online (Sandbox Code Playgroud)
不确定如何从SDK(Android或iOS)
1)我们找不到通过FB SDK做到这一点的任何方法,例如:https : //developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/facebooksdk.html/
2)我们尝试通过curl反向工程师联系FB API,它适用于电子邮件之类的情况:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"app_events_feature_bitmask":0}' \
"https://graph.facebook.com/***?access_token=<app_secret>"
Run Code Online (Sandbox Code Playgroud)
哪个返回了
{"success":true}
Run Code Online (Sandbox Code Playgroud)
但对于应用程序事件功能,则保持不变:
curl -i -X GET "https://graph.facebook.com/***?fields=app_events_feature_bitmask&access_token=<app_secret>"
Run Code Online (Sandbox Code Playgroud)
它返回旧值:
{"app_events_feature_bitmask":37,"id":"***"}
Run Code Online (Sandbox Code Playgroud)
3)寻求FB技术支持
事实证明,这是一些Facebook远程配置的事情,如果我们注释掉以下代码:
// UITableView
void (^tableViewBlock)(UITableView *tableView,
SEL cmd,
id<UITableViewDelegate> delegate) =
^(UITableView *tableView, SEL cmd, id<UITableViewDelegate> delegate) {
if (!delegate) {
return;
}
[self matchView:tableView delegate:delegate];
};
[FBSDKSwizzler swizzleSelector:@selector(setDelegate:)
onClass:[UITableView class]
withBlock:tableViewBlock
named:@"match_table_view"];
Run Code Online (Sandbox Code Playgroud)
#if !TARGET_OS_TV
- (void)enableCodelessEvents {
if (_serverConfiguration.isCodelessEventsEnabled) { <-----
if (!_eventBindingManager) {
_eventBindingManager = [[FBSDKEventBindingManager alloc] init];
}
if ([FBSDKInternalUtility isUnity]) {
[FBSDKAppEvents sendEventBindingsToUnity];
} else {
[_eventBindingManager updateBindings:[FBSDKEventBindingManager
parseArray:_serverConfiguration.eventBindings]];
}
}
}
#endif
Run Code Online (Sandbox Code Playgroud)
问题是:什么打开了这个标志?(即从某些fb远程配置)
_serverConfiguration.isCodelessEventsEnabled
Run Code Online (Sandbox Code Playgroud)
这就是我们试图找出的
Facebook技术支持人员以简明的英语回复我,说根本不可能使用此选项:
长话短说:通过安装FB App Events SDK,您将自动打开FB远程配置,以启用无代码事件,并且无法将其关闭。
我们能够重现该问题(具体而言,通过在Facebook管理员上执行几个步骤来打开fb远程事件标志)
当您单击该按钮时,您将看到
这就是标志打开的时候!
| 归档时间: |
|
| 查看次数: |
597 次 |
| 最近记录: |