在IOS中使用Facebook-Sonar调试套件
原文发表于本人笔记小站http://leanote.bitcode.tk:251/blog/post/sma11case/%E5%9C%A8IOS%E4%B8%AD%E4%BD%BF%E7%94%A8Facebook-Sonar%E8%B0%83%E8%AF%95%E5%A5%97%E4%BB%B6, 此处仅作为备份, 转载请保留所有内容
近日,Facebook在Github开源了内部使用的移动APP调试套件(支持Android/IOS, 项目地址: https://github.com/facebook/Sonar), 笔者也第一时间进行了尝试, 感觉功能还算强大, 但由于是BETA版, 直接POD添加或源代码添加到项目都是编译不过的, 本人在使用过程中不断尝试,研究出通用的整合到项目的办法, 公诸于从! _
Step 1. 不要使用官方示例的Podfile
写法, 使用如下写法(毕竟是BETA嘛~~~)
platform :ios, '8.4'
swift_version = '4.0'
inhibit_all_warnings!
target 'SonarSDK' do
pod 'boost-for-react-native', '1.63.0'
pod 'CocoaAsyncSocket', '7.6.3'
pod 'CocoaLibEvent', '1.0.0'
pod 'OpenSSL-Static', '1.0.2.c1'
pod 'Yoga','1.8.1', :modular_headers => true
pod 'YogaKit', '1.8.1'
# pod 'SonarKit', '0.0.1'
# pod 'SonarKit/SKIOSNetworkPlugin', '0.0.1'
# pod 'SonarKit/SonarKitLayoutComponentKitSupport', '0.0.1'
# pod 'SonarKit/SonarKitLayoutPlugin', '0.0.1'
# pod 'SonarKit/SonarKitNetworkPlugin', '0.0.1'
pod 'RSocket', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/third-party-podspecs/RSocket.podspec'
pod 'DoubleConversion', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/third-party-podspecs/Folly.podspec'
pod 'PeerTalk', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/third-party-podspecs/PeerTalk.podspec'
pod 'ComponentKit', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/third-party-podspecs/ComponentKit.podspec'
pod 'Sonar', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/xplat/Sonar/Sonar.podspec'
pod 'SonarKit', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/SonarKit.podspec'
pod 'SonarKit/SKIOSNetworkPlugin', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/SonarKit.podspec'
pod 'SonarKit/SonarKitLayoutComponentKitSupport', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/SonarKit.podspec'
pod 'SonarKit/SonarKitLayoutPlugin', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/SonarKit.podspec'
pod 'SonarKit/SonarKitNetworkPlugin', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/Fix-Broken-iOS-OSS/iOS/SonarKit.podspec'
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['YogaKit'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = swift_version
end
end
end
end
end
Setp 2. pod update
拉取对应组件.
Step 3. 在Xcode中添加System Header Searth Paths
(因为代码某些头文件引用有问题)
${PROJECT_DIR}/Pods/SonarKit/iOS/SonarKit
${PROJECT_DIR}/Pods/SonarKit/iOS
Setp 4. 在AppDelegate
中使用如下代码
#import "../Pods/SonarKit/iOS/SonarKit/SonarClient.h"
#import "../Pods/SonarKit/iOS/SonarKit/SonarPlugin.h"
#import "../Pods/SonarKit/iOS/Plugins/SonarKitLayoutPlugin/SonarKitLayoutPlugin/SonarKitLayoutPlugin.h"
#import "../Pods/SonarKit/iOS/Plugins/SonarKitLayoutPlugin/SonarKitLayoutPlugin/SKDescriptorMapper.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
SonarClient *client = [SonarClient sharedClient];
SKDescriptorMapper *mapper = [[SKDescriptorMapper alloc] initWithDefaults];
[client addPlugin:[[SonarKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:mapper]];
[client start];
}
Step 5. 在模拟器中启动APP, 然后打开Sonar.app
即可看到效果,貌似目前只能在模拟器运行, 真机运行搜索不到APP, 谁知道方法的求告知一下~~~~
Step 6. 收工!!! 喜欢本人或本文的欢迎评论或捐助~~
- Contact Me: qokelate$gmail.com
-
Donate Me: (Alipay/WeChat)
Alipay
WeChat
网友评论