GithubHelp home page GithubHelp logo

Swift support for Sonar about flipper HOT 13 CLOSED

facebook avatar facebook commented on April 24, 2024 9
Swift support for Sonar

from flipper.

Comments (13)

sergeyzenchenko avatar sergeyzenchenko commented on April 24, 2024 11

@bolismauro, @priteshrnandgaonkar you can try https://appspector.com instead. Works with swift and has more features :)

from flipper.

noahsark769 avatar noahsark769 commented on April 24, 2024 2

Quick update: I managed to get a Swift app talking to Sonar today. The main bug was a search paths issue: SonarKit/SonarClient.h was including SonarPlugin.h, but because of how Cocoapods does default search paths, it was including Sonar/SonarPlugin.h, a C++ header, instead of SonarKit/SonarPlugin.h, an Obj-C header.

This is also the cause of #28 - iosfwd is part of the C++ standard library and imported in the C++ version of the header, Sonar/SonarPlugin.h.

I'll try to get a PR up in the next couple of days with a Swift sample project and the necessary podspec changes :)

from flipper.

bolismauro avatar bolismauro commented on April 24, 2024 1

Is there any plan to fix this or an ETA? The tool seems extremely powerful and interesting and I have several use cases for it but unfortunately our projects are swift only

from flipper.

noahsark769 avatar noahsark769 commented on April 24, 2024 1

@bolismauro PR is up (#106), let me know if it works for you (you should be able to point your Podfile at the podspecs in my branch). Note that the Network and Layout plugins are not yet supported in Swift (decided to take care of implementing core client support first).

from flipper.

bolismauro avatar bolismauro commented on April 24, 2024 1

It works perfectly!
Thanks a lot for have worked on this, I struggled to find the proper time and it is great that you guys are pushing this forward :)

from flipper.

bolismauro avatar bolismauro commented on April 24, 2024

Looks very cool but it is not what I'm looking for :(

from flipper.

sergeyzenchenko avatar sergeyzenchenko commented on April 24, 2024

interesting, are you looking for some specific feature? @bolismauro

from flipper.

bolismauro avatar bolismauro commented on April 24, 2024

I want to play with layout editor and the ability of developing custom things within the tool.
Also I prefer not to go trough a 3rd party service I cannot control.

I think this isn't the proper place to discuss this though. Let's keep it clean for the sonar swift support

from flipper.

priteshrnandgaonkar avatar priteshrnandgaonkar commented on April 24, 2024

@bolismauro Currently its isn't in our internal roadmap.We would expect open source community to fix it. But seeing on how things pan out we may end up working on it. But I can't see that happen soon.

from flipper.

bolismauro avatar bolismauro commented on April 24, 2024

Gotcha. I unfortunately don't have strong c++ knowledge but I think I'll try anyway. Do you have some suggestions about how to proceed and what need to be fixed?

from flipper.

priteshrnandgaonkar avatar priteshrnandgaonkar commented on April 24, 2024

Just try and get rid off the c++ in the header files of sonar. In header files you may also find other inported dependency that has c++ in it. So one has to create a c wrapper over it and then use in the public headers of sonar.Basically we have to make sure that headers doesn't have c++ in it.

from flipper.

noahsark769 avatar noahsark769 commented on April 24, 2024

I took a look into building Sonar for use in Trestle, which is a Swift project. As far as I can see, Cocoapods should be able to configure the Sonar/SonarKit pods to build into modules which Swift can use using :modular_headers => true. Swift projects use pods which have C++ in them all the time - Sentry is a good example of a pod which has no Swift and some C++ and is usuable from a Swift project.

Here's what my Podfile looks like:

  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', :modular_headers => true
  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_representation|
    installer_representation.pods_project.targets.each do |target|
      if ['YogaKit'].include? target.name
          target.build_configurations.each do |config|
              config.build_settings['SWIFT_VERSION'] = '3.0.2'
          end
      end
    end
  end

Not running into any errors due to C++ used in headers like @priteshrnandgaonkar said, however I'm seeing the same error as in #28 ('iosfwd' file not found). Here's the full trace:

/Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/SonarKit/SonarCppBridgingConnection.h:8:9: note: while building module 'Sonar' imported from /Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/SonarKit/SonarCppBridgingConnection.h:8:
#import <Sonar/SonarConnection.h>
        ^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Sonar-umbrella.h"
        ^
/Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Sonar/Sonar-umbrella.h:14:9: note: in file included from /Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Sonar/Sonar-umbrella.h:14:
#import "SonarClient.h"
        ^
/Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Sonar/SonarClient.h:11:10: note: in file included from /Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Sonar/SonarClient.h:11:
#include <Sonar/SonarConnectionImpl.h>
         ^
/Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Sonar/SonarConnectionImpl.h:11:10: note: in file included from /Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Sonar/SonarConnectionImpl.h:11:
#include <Sonar/SonarConnection.h>
         ^
/Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Sonar/SonarConnection.h:11:10: note: in file included from /Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Sonar/SonarConnection.h:11:
#include <Sonar/SonarResponder.h>
         ^
/Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Sonar/SonarResponder.h:11:10: note: in file included from /Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Sonar/SonarResponder.h:11:
#include <folly/json.h>
         ^
/Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/Folly/folly/json.h:43:10: error: 'iosfwd' file not found
#include <iosfwd>
         ^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "SonarKit-umbrella.h"
        ^
/Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/SonarKit/SonarKit-umbrella.h:13:9: note: in file included from /Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/SonarKit/SonarKit-umbrella.h:13:
#import "SonarCppBridgingConnection.h"
        ^
/Users/noahgilmore/code/trest-ios/Trest/../Pods/Headers/Public/SonarKit/SonarCppBridgingConnection.h:8:9: error: could not build module 'Sonar'
#import <Sonar/SonarConnection.h>
        ^
/Users/noahgilmore/code/trest-ios/Trest/Trest/AppDelegate.swift:16:8: error: could not build Objective-C module 'SonarKit'
import SonarKit
       ^

I could be wrong but the solution to this might just be an include path configuration fix. Any advice here is appreciated :) @bolismauro were you able to make any headway here?

from flipper.

bolismauro avatar bolismauro commented on April 24, 2024

Sorry for not having answered before, I took some time off and I didn't see the notification.

It is amazing that you managed to make it work :) can't wait to try your PR! Thanks a lot!

from flipper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.