Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Flipper in RNTester on iOS #27762

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions RNTester/Dummy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import Foundation
// Added this dummy swift file to solve the app's compilation issue for Xcode 11.
// Following are the links with the explanation for this fix.
// D18420963, D18420963
// https://github.com/Carthage/Carthage/issues/2825
// https://twitter.com/krzyzanowskim/status/1151549874653081601?s=21
55 changes: 55 additions & 0 deletions RNTester/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,69 @@ def pods()
# Additional Pods which aren't included in the default Podfile
pod 'React-ART', :path => '../Libraries/ART'
pod 'React-RCTPushNotification', :path => '../Libraries/PushNotificationIOS'
pod 'Yoga',:path => '../ReactCommon/yoga', :modular_headers => true

# Additional Pods which are classed as unstable
#
# To use fabric: add `fabric_enabled` option to the use_react_native method above, like below
# use_react_native!(path: "..", fabric_enabled: true)
end

def flipper_pods()
flipperkit_version = '0.30.1'
pod 'FlipperKit', '~>' + flipperkit_version, :configuration => 'Debug'
pod 'FlipperKit/FlipperKitLayoutPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
pod 'FlipperKit/FlipperKitReactPlugin', '~>' + flipperkit_version, :configuration => 'Debug'

if ENV['USE_FRAMEWORKS'] == '1'
$static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
'CocoaAsyncSocket', 'ComponentKit', 'Flipper-DoubleConversion',
'Flipper-Glog', 'Flipper-PeerTalk', 'Flipper-RSocket',
'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']

pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
if $static_framework.include?(pod.name)
def pod.build_type;
Pod::Target::BuildType.static_library
end
end
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@priteshrnandgaonkar Could you link me to a write-up, if one exists, on the need for these deps to be linked statically?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go through the iOS setup mentioned here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I’ve seen those before, but they do not describe why these dependencies need to be linked statically and why a monkey-patch of CocoaPods is required. I would like to understand those technical reasons, as I would like to see if there’s a way to avoid the need to monkey-patch.

Copy link
Contributor Author

@priteshrnandgaonkar priteshrnandgaonkar Jan 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason being, Flipper relies on CocoaLibEvent which has bunch of statically linked binaries libevent.a, libevevnt_core.a etc. due to which the SubPods relying on it has to be built as a Static Framework, which is Flipper-Folly. So ideally speaking building just CocoaLibEvent, Flipper-Folly as a static framework should work, but for some reason the dynamic framework failed to link Flipper-Folly, which I was not able to solve. Thus I built all the Flipper and Flipper related deps as a Static Framework and it gave no errors.

Even I feel that we shouldn't have a monkey-patch, if you can solve this problem, then it would be great.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, when I’m back from vacation I’ll take a look-see 👍

end

# Post Install processing for Flipper
def flipper_post_install(installer)
installer.pods_project.targets.each do |target|
if target.name == 'YogaKit'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
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|
cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
cflags << ' -DFB_SONARKIT_ENABLED=1 '
end
config.build_settings['OTHER_CFLAGS'] = cflags
end
app_project.save
end
installer.pods_project.save
end

target 'RNTester' do
pods()
flipper_pods()
end

target 'RNTesterUnitTests' do
Expand All @@ -39,6 +93,7 @@ target 'RNTesterIntegrationTests' do
end

post_install do |installer|
flipper_post_install(installer)
installer.pods_project.targets.each do |target|
puts target.name
end
Expand Down
88 changes: 84 additions & 4 deletions RNTester/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
PODS:
- boost-for-react-native (1.63.0)
- CocoaAsyncSocket (7.6.3)
- CocoaLibEvent (1.0.0)
- DoubleConversion (1.1.6)
- FBLazyVector (1000.0.0)
- FBReactNativeSpec (1000.0.0):
Expand All @@ -9,6 +11,52 @@ PODS:
- React-Core (= 1000.0.0)
- React-jsi (= 1000.0.0)
- ReactCommon/turbomodule/core (= 1000.0.0)
- Flipper (0.30.1):
- Flipper-Folly (~> 2.1)
- Flipper-RSocket (~> 1.0)
- Flipper-DoubleConversion (1.1.7)
- Flipper-Folly (2.1.1):
- boost-for-react-native
- CocoaLibEvent (~> 1.0)
- Flipper-DoubleConversion
- Flipper-Glog
- OpenSSL-Universal (= 1.0.2.19)
- Flipper-Glog (0.3.6)
- Flipper-PeerTalk (0.0.4)
- Flipper-RSocket (1.0.0):
- Flipper-Folly (~> 2.0)
- FlipperKit (0.30.1):
- FlipperKit/Core (= 0.30.1)
- FlipperKit/Core (0.30.1):
- Flipper (~> 0.30.1)
- FlipperKit/CppBridge
- FlipperKit/FBCxxFollyDynamicConvert
- FlipperKit/FBDefines
- FlipperKit/FKPortForwarding
- FlipperKit/CppBridge (0.30.1):
- Flipper (~> 0.30.1)
- FlipperKit/FBCxxFollyDynamicConvert (0.30.1):
- Flipper-Folly (~> 2.1)
- FlipperKit/FBDefines (0.30.1)
- FlipperKit/FKPortForwarding (0.30.1):
- CocoaAsyncSocket (~> 7.6)
- Flipper-PeerTalk (~> 0.0.4)
- FlipperKit/FlipperKitHighlightOverlay (0.30.1)
- FlipperKit/FlipperKitLayoutPlugin (0.30.1):
- FlipperKit/Core
- FlipperKit/FlipperKitHighlightOverlay
- FlipperKit/FlipperKitLayoutTextSearchable
- YogaKit (~> 1.18)
- FlipperKit/FlipperKitLayoutTextSearchable (0.30.1)
- FlipperKit/FlipperKitNetworkPlugin (0.30.1):
- FlipperKit/Core
- FlipperKit/FlipperKitReactPlugin (0.30.1):
- FlipperKit/Core
- FlipperKit/FlipperKitUserDefaultsPlugin (0.30.1):
- FlipperKit/Core
- FlipperKit/SKIOSNetworkPlugin (0.30.1):
- FlipperKit/Core
- FlipperKit/FlipperKitNetworkPlugin
- Folly (2018.10.22.00):
- boost-for-react-native
- DoubleConversion
Expand All @@ -19,6 +67,9 @@ PODS:
- DoubleConversion
- glog
- glog (0.3.5)
- OpenSSL-Universal (1.0.2.19):
- OpenSSL-Universal/Static (= 1.0.2.19)
- OpenSSL-Universal/Static (1.0.2.19)
- RCTRequired (1000.0.0)
- RCTTypeSafety (1000.0.0):
- FBLazyVector (= 1000.0.0)
Expand Down Expand Up @@ -277,11 +328,18 @@ PODS:
- ReactCommon/callinvoker (= 1000.0.0)
- ReactCommon/turbomodule/core (= 1000.0.0)
- Yoga (1.14.0)
- YogaKit (1.18.1):
- Yoga (~> 1.14)

DEPENDENCIES:
- DoubleConversion (from `../third-party-podspecs/DoubleConversion.podspec`)
- FBLazyVector (from `../Libraries/FBLazyVector`)
- FBReactNativeSpec (from `../Libraries/FBReactNativeSpec`)
- FlipperKit (~> 0.30.1)
- FlipperKit/FlipperKitLayoutPlugin (~> 0.30.1)
- FlipperKit/FlipperKitReactPlugin (~> 0.30.1)
- FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.30.1)
- FlipperKit/SKIOSNetworkPlugin (~> 0.30.1)
- Folly (from `../third-party-podspecs/Folly.podspec`)
- glog (from `../third-party-podspecs/glog.podspec`)
- RCTRequired (from `../Libraries/RCTRequired`)
Expand Down Expand Up @@ -315,6 +373,17 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- boost-for-react-native
- CocoaAsyncSocket
- CocoaLibEvent
- Flipper
- Flipper-DoubleConversion
- Flipper-Folly
- Flipper-Glog
- Flipper-PeerTalk
- Flipper-RSocket
- FlipperKit
- OpenSSL-Universal
- YogaKit

EXTERNAL SOURCES:
DoubleConversion:
Expand Down Expand Up @@ -376,11 +445,21 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987
CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f
DoubleConversion: cde416483dac037923206447da6e1454df403714
FBLazyVector: 9806caa151956ce2238f70bde6649a6e3468d2c2
FBReactNativeSpec: 4612edcbf25240e05263399a484cb14bf513872c
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
Flipper: d591b88245dc8c8147819aa249f911923c7417fc
Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41
Flipper-Folly: 2de3d03e0acc7064d5e4ed9f730e2f217486f162
Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6
Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
Flipper-RSocket: 1260a31c05c238eabfa9bb8a64e3983049048371
FlipperKit: 3e13631bca7c5ec0dd54ee1d096f5e5d32a5d784
Folly: f1c65c1bdabb35617432cac9cf17d0cad310ce6f
glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355
RCTRequired: f04f9813bccb37099f642722b46e879fc47c7e78
RCTTypeSafety: a905fc5bfde67305e22588fb5178289bc8bc6be7
React: 7b262249ab4afa1d300c9e90f50edcc2a5f72bcd
Expand All @@ -404,7 +483,8 @@ SPEC CHECKSUMS:
React-RCTVibration: 7ee1cf4f386ed200c70b2be1b09a744ab79861ba
ReactCommon: ee43d06925ecaa2fc7a9d5d07adc2f77c9d65c72
Yoga: f7fa200d8c49f97b54c9421079e781fb900b5cae
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: fa397603c9a8f7cb49d7edc7fe85536d0789f34f
PODFILE CHECKSUM: 4662af01535bdfc6b1b358f77bd803c6130205df

COCOAPODS: 1.8.4
11 changes: 11 additions & 0 deletions RNTester/RNTester-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

Loading