Upated the installation instruction for iOS

Summary: Updated the installation instruction for iOS. Also updated the sample app's podfile

Reviewed By: passy

Differential Revision: D15165222

fbshipit-source-id: 33fe27f687619b716b73cea5c3a3a898ea6edc79
This commit is contained in:
Pritesh Nandgaonkar
2019-05-01 07:29:03 -07:00
committed by Facebook Github Bot
parent c12b8d28fb
commit 5b26ce954f
3 changed files with 55 additions and 74 deletions

View File

@@ -100,8 +100,6 @@ We support both Swift and Objective-C for Flipper with CocoaPods as build and di
<!--Objective-C--> <!--Objective-C-->
```ruby ```ruby
project 'MyApp.xcodeproj' project 'MyApp.xcodeproj'
source 'https://github.com/facebook/flipper.git'
source 'https://github.com/CocoaPods/Specs'
swift_version = "4.1" swift_version = "4.1"
flipperkit_version = '0.20.0' flipperkit_version = '0.20.0'
@@ -112,40 +110,28 @@ target 'MyApp' do
pod 'FlipperKit/FlipperKitLayoutComponentKitSupport', '~>' + flipperkit_version pod 'FlipperKit/FlipperKitLayoutComponentKitSupport', '~>' + flipperkit_version
pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', '~>' + flipperkit_version pod 'FlipperKit/FlipperKitUserDefaultsPlugin', '~>' + flipperkit_version
# This post_install script adds min deployment iOS version to yoga's pod target. # This post_install hook adds the -DFB_SONARKIT_ENABLED=1 flag to OTHER_CFLAGS, necessary to expose Flipper classes in the header files
# 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| post_install do |installer|
installer.pods_project.targets.each do |target| file_name = Dir.glob("*.xcodeproj")[0]
if ('Yoga' == target.name) app_project = Xcodeproj::Project.open(file_name)
target.build_configurations.each do |config| app_project.native_targets.each do |target|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0' target.build_configurations.each do |config|
end cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
end unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
end puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
file_name = Dir.glob("*.xcodeproj")[0] cflags << '-DFB_SONARKIT_ENABLED=1'
app_project = Xcodeproj::Project.open(file_name) end
app_project.native_targets.each do |target| config.build_settings['OTHER_CFLAGS'] = cflags
target.build_configurations.each do |config| end
if (config.build_settings['OTHER_CFLAGS']) app_project.save
if !(config.build_settings['OTHER_CFLAGS'].include? '-DFB_SONARKIT_ENABLED=1') end
puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...' installer.pods_project.save
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
end end
``` ```
<!--Swift--> <!--Swift-->
```ruby ```ruby
project 'MyApp.xcodeproj' project 'MyApp.xcodeproj'
source 'https://github.com/facebook/flipper.git'
source 'https://github.com/CocoaPods/Specs'
swift_version = "4.1" swift_version = "4.1"
flipperkit_version = '0.20.0' flipperkit_version = '0.20.0'
@@ -177,22 +163,14 @@ target 'MyApp' do
# end # end
# end # end
# This post_install script adds min deployment iOS version to yoga's pod target. # This post_install hook adds the -DFB_SONARKIT_ENABLED flag to OTHER_SWIFT_FLAGS, necessary to build swift target
# It also adds -DFB_SONARKIT_ENABLED flag to OTHER_SWIFT_FLAGS, necessary to build swift target
post_install do |installer| post_install do |installer|
file_name = Dir.glob("*.xcodeproj")[0] file_name = Dir.glob("*.xcodeproj")[0]
app_project = Xcodeproj::Project.open(file_name) app_project = Xcodeproj::Project.open(file_name)
installer.pods_project.targets.each do |target|
if ('Yoga' == target.name)
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
end
end
end
app_project.native_targets.each do |target| app_project.native_targets.each do |target|
target.build_configurations.each do |config| target.build_configurations.each do |config|
if (config.build_settings['OTHER_SWIFT_FLAGS']) if (config.build_settings['OTHER_SWIFT_FLAGS'])
if !(config.build_settings['OTHER_SWIFT_FLAGS'].include? '-DFB_SONARKIT_ENABLED') unless config.build_settings['OTHER_SWIFT_FLAGS'].include? '-DFB_SONARKIT_ENABLED'
puts 'Adding -DFB_SONARKIT_ENABLED ...' puts 'Adding -DFB_SONARKIT_ENABLED ...'
swift_flags = config.build_settings['OTHER_SWIFT_FLAGS'] swift_flags = config.build_settings['OTHER_SWIFT_FLAGS']
if swift_flags.split.last != '-Xcc' if swift_flags.split.last != '-Xcc'
@@ -207,16 +185,21 @@ target 'MyApp' do
app_project.save app_project.save
end end
end end
installer.pods_project.save
end end
end end
``` ```
<!--END_DOCUSAURUS_CODE_TABS--> <!--END_DOCUSAURUS_CODE_TABS-->
Install the dependencies by running `pod install`. When you open the XCode You need to compile your project with the `FB_SONARKIT_ENABLED=1` compiler flag. The above `post_install` hook adds this compiler flag to your project settings.
workspace file of your app, you now can import and initialize Flipper in your
AppDelegate. Before running your app, make sure that the flag <div class="warning">
`-DFB_SONARKIT_ENABLED=1` is present in the `OTHER_CFLAGS` of
application's build settings. On the first run of `pod install`, `FB_SONARKIT_ENABLED=1` may not be added in the "Build Settings" of your project, but in all the subsequent runs of `pod install`, the above `post_install` hook successfully adds the compiler flag. So before running your app, make sure that `FB_SONARKIT_ENABLED=1` is present in `OTHER_CFLAGS` and `OTHER_SWIFT_FLAGS` for Objective-C and Swift projects respectively.
</div>
Install the dependencies by running `pod install`. You can now import and initialize Flipper in your
AppDelegate.
<!--DOCUSAURUS_CODE_TABS--> <!--DOCUSAURUS_CODE_TABS-->
@@ -271,7 +254,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
<div class="warning"> <div class="warning">
- We haven't released the dependency to CocoaPods yet, here is the [issue](https://github.com/facebook/flipper/issues/132) by which you can track.
- If you do not use CocoaPods as a dependency management tool then currently there is no way to integrate FlipperKit other than manually including all the dependencies and building it. - If you do not use CocoaPods as a dependency management tool then currently there is no way to integrate FlipperKit other than manually including all the dependencies and building it.
- For Android, Flipper works with both emulators and physical devices connected through USB. However on iOS, we don't yet support physical devices. - For Android, Flipper works with both emulators and physical devices connected through USB. However on iOS, we don't yet support physical devices.

View File

@@ -13,21 +13,19 @@ target 'Sample' do
pod 'Flipper', :path => '../../Flipper.podspec' pod 'Flipper', :path => '../../Flipper.podspec'
# It also adds -DFB_SONARKIT_ENABLED=1 flag to OTHER_CFLAGS, necessary to build expose Flipper classes in the header files # 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| post_install do |installer|
file_name = Dir.glob("*.xcodeproj")[0] file_name = Dir.glob("*.xcodeproj")[0]
app_project = Xcodeproj::Project.open(file_name) app_project = Xcodeproj::Project.open(file_name)
app_project.native_targets.each do |target| app_project.native_targets.each do |target|
target.build_configurations.each do |config| target.build_configurations.each do |config|
if (config.build_settings['OTHER_CFLAGS']) cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
if !(config.build_settings['OTHER_CFLAGS'].include? '-DFB_SONARKIT_ENABLED=1') unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...' puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
config.build_settings['OTHER_CFLAGS'] << '-DFB_SONARKIT_ENABLED=1' cflags << '-DFB_SONARKIT_ENABLED=1'
end end
else config.build_settings['OTHER_CFLAGS'] = cflags
puts 'OTHER_CFLAGS does not exist, assigining it to `$(inherited), -DFB_SONARKIT_ENABLED=1` ' end
config.build_settings['OTHER_CFLAGS'] = '$(inherited) -DFB_SONARKIT_ENABLED=1 ' app_project.save
end end
app_project.save installer.pods_project.save
end
end
end end
end end

View File

@@ -15,22 +15,23 @@ target 'SampleSwift' do
file_name = Dir.glob("*.xcodeproj")[0] file_name = Dir.glob("*.xcodeproj")[0]
app_project = Xcodeproj::Project.open(file_name) app_project = Xcodeproj::Project.open(file_name)
app_project.native_targets.each do |target| app_project.native_targets.each do |target|
target.build_configurations.each do |config| target.build_configurations.each do |config|
if (config.build_settings['OTHER_SWIFT_FLAGS']) if (config.build_settings['OTHER_SWIFT_FLAGS'])
if !(config.build_settings['OTHER_SWIFT_FLAGS'].include? '-DFB_SONARKIT_ENABLED') unless config.build_settings['OTHER_SWIFT_FLAGS'].include? '-DFB_SONARKIT_ENABLED'
puts 'Adding -DFB_SONARKIT_ENABLED ...' puts 'Adding -DFB_SONARKIT_ENABLED ...'
swift_flags = config.build_settings['OTHER_SWIFT_FLAGS'] swift_flags = config.build_settings['OTHER_SWIFT_FLAGS']
if swift_flags.split.last != '-Xcc' if swift_flags.split.last != '-Xcc'
config.build_settings['OTHER_SWIFT_FLAGS'] << ' -Xcc' config.build_settings['OTHER_SWIFT_FLAGS'] << ' -Xcc'
end
config.build_settings['OTHER_SWIFT_FLAGS'] << ' -DFB_SONARKIT_ENABLED'
end end
config.build_settings['OTHER_SWIFT_FLAGS'] << ' -DFB_SONARKIT_ENABLED' 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 end
else app_project.save
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 end
app_project.save
end end
end installer.pods_project.save
end end
end end