diff --git a/iOS/FlipperKit.podspec b/iOS/FlipperKit.podspec index 6e2a5b451..00d84e451 100644 --- a/iOS/FlipperKit.podspec +++ b/iOS/FlipperKit.podspec @@ -71,6 +71,7 @@ Pod::Spec.new do |spec| 'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.h', 'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKSubDescriptor.h', 'iOS/FBDefines/FBMacros.h', + 'iOS/Plugins/FlipperKitExamplePlugin/FlipperKitExamplePlugin/FlipperKitExamplePlugin.h', 'iOS/FlipperKit/**/{FlipperDiagnosticsViewController,FlipperStateUpdateListener,FlipperClient,FlipperPlugin,FlipperConnection,FlipperResponder,SKMacros}.h' header_search_paths = "\"$(PODS_ROOT)/FlipperKit/iOS/FlipperKit\" \"$(PODS_ROOT)\"/Headers/Private/FlipperKit/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/PeerTalkSonar\"" ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", diff --git a/iOS/SampleSwift/Podfile b/iOS/SampleSwift/Podfile index 5f9c923ba..a852cda71 100644 --- a/iOS/SampleSwift/Podfile +++ b/iOS/SampleSwift/Podfile @@ -9,6 +9,7 @@ target 'SampleSwift' do pod 'FlipperKit', :path => '../../FlipperKit.podspec' pod 'FlipperKit/SKIOSNetworkPlugin', :path => '../../FlipperKit.podspec' pod 'FlipperKit/FlipperKitUserDefaultsPlugin', :path => '../../FlipperKit.podspec' + pod 'FlipperKit/FlipperKitExamplePlugin', :path => '../../FlipperKit.podspec' # Layout and network plugins are not yet supported for swift projects pod 'FlipperKit/FlipperKitLayoutComponentKitSupport', :path => '../../FlipperKit.podspec' diff --git a/iOS/SampleSwift/SampleSwift.xcodeproj/project.pbxproj b/iOS/SampleSwift/SampleSwift.xcodeproj/project.pbxproj index d6a3a1612..f5d3f8cda 100644 --- a/iOS/SampleSwift/SampleSwift.xcodeproj/project.pbxproj +++ b/iOS/SampleSwift/SampleSwift.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 322121E8134CB1102F388691 /* libPods-SampleSwift.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6233B2BCBACBB2E8D715CC04 /* libPods-SampleSwift.a */; }; 4E102343216ADB5900160734 /* UserDefaultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E102342216ADB5900160734 /* UserDefaultsViewController.swift */; }; 532FF2DF211316ED00FC5A10 /* NetworkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 532FF2DE211316ED00FC5A10 /* NetworkViewController.swift */; }; + 53C327E5219DDCA800FE7A4C /* CommunicationDemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C327E4219DDCA800FE7A4C /* CommunicationDemoViewController.swift */; }; A19C402720E20023004BF1F7 /* Icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A19C402620E20023004BF1F7 /* Icons.xcassets */; }; A1EC522D20DED61B007C6977 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1EC522C20DED61B007C6977 /* AppDelegate.swift */; }; A1EC522F20DED61B007C6977 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1EC522E20DED61B007C6977 /* ViewController.swift */; }; @@ -20,6 +21,7 @@ /* Begin PBXFileReference section */ 4E102342216ADB5900160734 /* UserDefaultsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsViewController.swift; sourceTree = ""; }; 532FF2DE211316ED00FC5A10 /* NetworkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkViewController.swift; sourceTree = ""; }; + 53C327E4219DDCA800FE7A4C /* CommunicationDemoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunicationDemoViewController.swift; sourceTree = ""; }; 6233B2BCBACBB2E8D715CC04 /* libPods-SampleSwift.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SampleSwift.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 82933F6ACB19D9FAA4A0B0DC /* Pods-SampleSwift.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SampleSwift.release.xcconfig"; path = "Pods/Target Support Files/Pods-SampleSwift/Pods-SampleSwift.release.xcconfig"; sourceTree = ""; }; 871A353CDDB4CD0F4FE9A564 /* Pods-SampleSwift.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SampleSwift.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SampleSwift/Pods-SampleSwift.debug.xcconfig"; sourceTree = ""; }; @@ -81,6 +83,7 @@ A1EC523820DED61C007C6977 /* Info.plist */, 532FF2DE211316ED00FC5A10 /* NetworkViewController.swift */, 4E102342216ADB5900160734 /* UserDefaultsViewController.swift */, + 53C327E4219DDCA800FE7A4C /* CommunicationDemoViewController.swift */, ); path = SampleSwift; sourceTree = ""; @@ -188,6 +191,7 @@ buildActionMask = 2147483647; files = ( A1EC522F20DED61B007C6977 /* ViewController.swift in Sources */, + 53C327E5219DDCA800FE7A4C /* CommunicationDemoViewController.swift in Sources */, 532FF2DF211316ED00FC5A10 /* NetworkViewController.swift in Sources */, 4E102343216ADB5900160734 /* UserDefaultsViewController.swift in Sources */, A1EC522D20DED61B007C6977 /* AppDelegate.swift in Sources */, diff --git a/iOS/SampleSwift/SampleSwift/AppDelegate.swift b/iOS/SampleSwift/SampleSwift/AppDelegate.swift index 806387382..18150682e 100644 --- a/iOS/SampleSwift/SampleSwift/AppDelegate.swift +++ b/iOS/SampleSwift/SampleSwift/AppDelegate.swift @@ -19,6 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { client?.add(FlipperKitLayoutPlugin(rootNode: application, with: layoutDescriptorMapper!)) client?.add(FlipperKitNetworkPlugin(networkAdapter: SKIOSNetworkAdapter())) + client?.add(FlipperKitExamplePlugin.sharedInstance()); client?.add(FKUserDefaultsPlugin.init(suiteName: nil)) client?.start() diff --git a/iOS/SampleSwift/SampleSwift/CommunicationDemoViewController.swift b/iOS/SampleSwift/SampleSwift/CommunicationDemoViewController.swift new file mode 100644 index 000000000..9657c1251 --- /dev/null +++ b/iOS/SampleSwift/SampleSwift/CommunicationDemoViewController.swift @@ -0,0 +1,42 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +import UIKit +import FlipperKit + +class CommunicationDemoViewController: UIViewController, UITableViewDataSource, FlipperKitExampleCommunicationResponderDelegate { + @IBOutlet weak var messageField: UITextField! + @IBOutlet weak var tableView: UITableView! + var messageArray: [String] = [] + + override func viewDidLoad() { + super.viewDidLoad() + FlipperKitExamplePlugin.sharedInstance()?.delegate = self + } + + @IBAction func tappedTriggerNotification(_ sender: UIButton) { + FlipperKitExamplePlugin.sharedInstance()?.triggerNotification(); + } + + @IBAction func tappedSendMessage(_ sender: UIButton) { + if let message = self.messageField.text { + FlipperKitExamplePlugin.sharedInstance()?.sendMessage(message); + } + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "reusableCell", for: indexPath) + cell.textLabel?.text = messageArray[indexPath.row] + return cell + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return messageArray.count; + } + + func messageReceived(_ msg: String!) { + messageArray.append(msg) + DispatchQueue.main.async { [weak self] in + self?.tableView.reloadData(); + } + } +} diff --git a/iOS/SampleSwift/SampleSwift/MainStoryBoard.storyboard b/iOS/SampleSwift/SampleSwift/MainStoryBoard.storyboard index f2508e204..461ded24e 100644 --- a/iOS/SampleSwift/SampleSwift/MainStoryBoard.storyboard +++ b/iOS/SampleSwift/SampleSwift/MainStoryBoard.storyboard @@ -59,6 +59,20 @@ + @@ -66,14 +80,17 @@ + + + @@ -243,8 +260,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - +