Summary: Mention latest published version `0.0.8`. Closes https://github.com/facebook/Sonar/pull/118 Reviewed By: priteshrnandgaonkar Differential Revision: D8694476 Pulled By: passy fbshipit-source-id: 7fc536dde44313eff09a64611d4c942d4f52fa1f
5.1 KiB
id, title, sidebar_label
| id | title | sidebar_label |
|---|---|---|
| getting-started | Getting Started | Getting Started |
Sonar helps you debug Android and iOS apps running in an emulator/simulator or connected physical development devices. Sonar consists of two parts:
- The desktop app for macOS
- The native mobile SDKs for Android and iOS
To use Sonar, you need to add the mobile SDK to your app.
Setup
Desktop app
The desktop part of Sonar doesn't need any particular setup. Simply download the latest build of our app and launch it. The desktop app is available for macOS and requires a working installation of the Android/iOS development tools on your system.
Once you start Sonar and launch an emulator/simulator or connect a device, you will already be able to see the device logs in Sonar. To see app specific data, you need to integrate our native SDKs with your app.
Setup your Android app
Sonar is distributed via JCenter. Add dependencies to your build.gradle file.
Note: If you run into issues building the Android integration, check out the tracking Github issue for work-arounds while we're working on a solution.
repositories {
jcenter()
}
dependencies {
debugImplementation 'com.facebook.sonar:sonar:0.0.8'
}
Now you can initialize Sonar in your Application's onCreate-method like this:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, false);
if (BuildConfig.DEBUG && SonarUtils.shouldEnableSonar(this)) {
final SonarClient client = AndroidSonarClient.getInstance(this);
client.addPlugin(new MySonarPlugin());
client.start();
}
}
}
Setup your iOS app
To integrate with an iOS app, you can use CocoaPods. Add the mobile Sonar SDK and its dependencies to your Podfile:
platform :ios, '8.0'
swift_version = '4.1'
target 'MyApp' do
pod 'RSocket', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/RSocket.podspec'
pod 'DoubleConversion', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/Folly.podspec'
pod 'PeerTalk', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/PeerTalk.podspec'
pod 'Yoga','~>1.8.1', :modular_headers => true
pod 'Sonar', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/xplat/Sonar/Sonar.podspec'
pod 'SonarKit', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/SonarKit.podspec'
pod 'SonarKit/SonarKitLayoutComponentKitSupport', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/SonarKit.podspec'
pod 'SonarKit/SKIOSNetworkPlugin', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/SonarKit.podspec'
pod 'ComponentKit', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/ComponentKit.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
and install the dependencies by running pod install. When you open the Xcode workspace file for your app, you now can import and initialize Sonar in your AppDelegate.
#import <SonarKit/SonarClient.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if DEBUG
SonarClient *client = [SonarClient sharedClient];
[client addPlugin:[MySonarPlugin new]];
[client start];
#endif
...
}
@end
- We haven't released the dependency to CocoaPods, because we weren't able to successfully validate the podspec of SonarKit. You could help us out by fixing this issue by submitting a PR to the repo.
- If you do not use CocoaPods as a dependency management tool then currently there is no way to integrate SonarKit other than manually including all the dependencies and building it.
- For Android, Sonar works with both emulators and physical devices connected through USB. However on iOS, we don't yet support physical devices.
- Also Sonar doesn't work with swift projects as its written in C++ and had C++ dependencies. But we are working on supporting sonar for swift projects. You can find this issue here
Ready for takeoff
Finally you need to add plugins to your Sonar client. See Network Plugin and Layout Inspector Plugin on how to add them.
