Docs with an updated install instruction (#343)
Summary: This PR updates the installation instruction. It missed few crucial information and thus the projects installing flipper as a dependency were facing issues. It addresses the issue #341. It also brings the sample application at par with the documentation. Pull Request resolved: https://github.com/facebook/flipper/pull/343 Reviewed By: danielbuechele Differential Revision: D13507298 Pulled By: priteshrnandgaonkar fbshipit-source-id: 5a4b23d79930cb7eeb491e359b616d3558e260fb
This commit is contained in:
committed by
Facebook Github Bot
parent
470c770e97
commit
da37ab78bd
@@ -87,7 +87,11 @@ dependencies {
|
||||
|
||||
### Setup your iOS app
|
||||
|
||||
To integrate with an iOS app, you can use [CocoaPods](https://cocoapods.org). Add the mobile Flipper SDK and its dependencies to your `Podfile`:
|
||||
To integrate with an iOS app, you can use [CocoaPods](https://cocoapods.org). Add the mobile Flipper SDK and its dependencies to your `Podfile`
|
||||
|
||||
### Objective-c
|
||||
|
||||
Podfile for Objective-C projects will look like the following
|
||||
|
||||
```ruby
|
||||
project 'MyApp.xcodeproj'
|
||||
@@ -103,42 +107,133 @@ target 'MyApp' do
|
||||
pod 'FlipperKit/FlipperKitLayoutComponentKitSupport', '~>' + flipperkit_version
|
||||
pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version
|
||||
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', '~>' + flipperkit_version
|
||||
pod 'FlipperKit/FlipperKitCrashReporterPlugin', '~>' + flipperkit_version
|
||||
|
||||
# This post_install script adds swift version to yogakit's pod target.
|
||||
# It also adds -DFB_SONARKIT_ENABLED=1 flag to OTHER_CFLAGS, necessary to build expose Flipper classes in the header files
|
||||
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
|
||||
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
|
||||
file_name = Dir.glob("*.xcodeproj")[0]
|
||||
app_project = Xcodeproj::Project.open(file_name)
|
||||
app_project.native_targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
if (config.build_settings['OTHER_CFLAGS'])
|
||||
if !(config.build_settings['OTHER_CFLAGS'].include? '-DFB_SONARKIT_ENABLED=1')
|
||||
puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
|
||||
config.build_settings['OTHER_CFLAGS'] << '-DFB_SONARKIT_ENABLED=1'
|
||||
end
|
||||
else
|
||||
puts 'OTHER_CFLAGS does not exist, assigining it to `$(inherited), -DFB_SONARKIT_ENABLED=1` '
|
||||
config.build_settings['OTHER_CFLAGS'] = '$(inherited) -DFB_SONARKIT_ENABLED=1 '
|
||||
end
|
||||
app_project.save
|
||||
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 Flipper in your AppDelegate.
|
||||
Install the dependencies by running `pod install`.When you open the Xcode workspace file for your app, you now can import and initialize Flipper in your AppDelegate. Before running your app, make sure that the flag `-DFB_SONARKIT_ENABLED=1` is present in the `OTHER_CFLAGS` in your application's build settings.
|
||||
|
||||
```objective-c
|
||||
#import <FlipperKit/FlipperClient.h>
|
||||
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
|
||||
#import <FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.h>
|
||||
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
|
||||
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
|
||||
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
#if DEBUG
|
||||
FlipperClient *client = [FlipperClient sharedClient];
|
||||
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
|
||||
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode: application
|
||||
withDescriptorMapper: layoutDescriptorMapper]];
|
||||
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
|
||||
[FlipperKitLayoutComponentKitSupport setUpWithDescriptorMapper: layoutDescriptorMapper];
|
||||
[client addPlugin: [[FlipperKitLayoutPlugin alloc] initWithRootNode: application
|
||||
withDescriptorMapper: layoutDescriptorMapper]];
|
||||
|
||||
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; [client start];
|
||||
[client addPlugin: [[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
|
||||
[client start];
|
||||
#endif
|
||||
...
|
||||
}
|
||||
@end
|
||||
```
|
||||
### Swift
|
||||
|
||||
Podfile for the swift projects will look like the following:
|
||||
|
||||
```ruby
|
||||
project 'MyApp.xcodeproj'
|
||||
source 'https://github.com/facebook/flipper.git'
|
||||
source 'https://github.com/CocoaPods/Specs'
|
||||
swift_version = "4.1"
|
||||
flipperkit_version = '0.13.0'
|
||||
|
||||
target 'MyApp' do
|
||||
platform :ios, '9.0'
|
||||
|
||||
pod 'FlipperKit', '~>' + flipperkit_version
|
||||
# Layout and network plugins are not yet supported for swift projects
|
||||
pod 'FlipperKit/FlipperKitLayoutComponentKitSupport', '~>' + flipperkit_version
|
||||
pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version
|
||||
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', '~>' + flipperkit_version
|
||||
|
||||
# This post_install script adds -DFB_SONARKIT_ENABLED flag to OTHER_SWIFT_FLAGS, necessary to build swift target
|
||||
post_install do |installer|
|
||||
file_name = Dir.glob("*.xcodeproj")[0]
|
||||
app_project = Xcodeproj::Project.open(file_name)
|
||||
app_project.native_targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
if (config.build_settings['OTHER_SWIFT_FLAGS'])
|
||||
if !(config.build_settings['OTHER_SWIFT_FLAGS'].include? '-DFB_SONARKIT_ENABLED')
|
||||
puts 'Adding -DFB_SONARKIT_ENABLED ...'
|
||||
swift_flags = config.build_settings['OTHER_SWIFT_FLAGS']
|
||||
if swift_flags.split.last != '-Xcc'
|
||||
config.build_settings['OTHER_SWIFT_FLAGS'] << ' -Xcc'
|
||||
end
|
||||
config.build_settings['OTHER_SWIFT_FLAGS'] << ' -DFB_SONARKIT_ENABLED'
|
||||
end
|
||||
else
|
||||
puts 'OTHER_SWIFT_FLAGS does not exist thus assigning it to `$(inherited) -Xcc -DFB_SONARKIT_ENABLED`'
|
||||
config.build_settings['OTHER_SWIFT_FLAGS'] = '$(inherited) -Xcc -DFB_SONARKIT_ENABLED'
|
||||
end
|
||||
app_project.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
```
|
||||
|
||||
|
||||
Install the dependencies by running `pod install`.When you open the Xcode workspace file for your app, you now can import and initialize Flipper in your AppDelegate by following the below mentioned example. Before running your app, make sure that the flag `-Xcc -DFB_SONARKIT_ENABLED` is present in the `OTHER_SWIFT_FLAGS` in your application's build settings.
|
||||
|
||||
```swift
|
||||
import UIKit
|
||||
import FlipperKit
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
let client = FlipperClient.shared()
|
||||
let layoutDescriptorMapper = SKDescriptorMapper(defaults: ())
|
||||
FlipperKitLayoutComponentKitSupport.setUpWith(layoutDescriptorMapper)
|
||||
client?.add(FlipperKitLayoutPlugin(rootNode: application, with: layoutDescriptorMapper!))
|
||||
client?.start()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
<div class="warning">
|
||||
|
||||
Reference in New Issue
Block a user