Code Monkey home page Code Monkey logo

Comments (2)

seanhenry avatar seanhenry commented on May 23, 2024

Hi,

Thanks for raising this issue. I will try to write some contribution guidelines this week to help you navigate the project. Did the Makefile work as expected? Run ./scripts/test to verify all tests are passing (you may have to install xcpretty gem install xcpretty).

How it finds protocols now:

SourceKit accepts a list of swift files to search when resolving symbols such as protocols. At the moment, the mock generator finds every swift file in the directory that you provide to the companion app and gives them to SourceKit. Therefore, protocols can be found in any source code that is included in the folder you give to the companion app, including protocols in custom frameworks.

How to find protocols in third party frameworks:

The list of files given to SourceKit are actually command line arguments that you would give to swiftc. Alongside the swift files you can provide locations to linked frameworks and then symbols from these frameworks should be able to be resolved.

Rough steps to implement this:

  • Figure out what command line arguments SourceKit needs to resolve symbols in third party frameworks.
  • Find which frameworks are linked in any given Xcode project.
  • Link those frameworks to SourceKit instead of just a list of files.

Tips:

You can run ./scripts/runxcode to launch Xcode and see how Xcode uses SourceKit. In Xcode, you could then cmd click on a protocol reference to a third party framework and see exactly what command line arguments are sent to SourceKit.

Take inspiration from other projects that use SourceKit. For example, Sourcery may have a way to do this. (Or even SourceKitten, I haven’t checked for a few months)

Once you figure out how to do it, use the SourceKitten command line tool to test if it works. See the ‘cursor info’ SourceKit request.

Links:
https://github.com/jpsim/SourceKitten/tree/master/Source/SourceKittenFramework
https://github.com/apple/swift/blob/master/tools/SourceKit/docs/Protocol.md
https://github.com/krzysztofzablocki/Sourcery
The SKCursorInfoRequest.swift file in this project.

from swiftmockgeneratorforxcode.

GoatHunter avatar GoatHunter commented on May 23, 2024

Thanks for the detailed reply, I haven't compiled the project from source yet, only tried out the plug-in, I'll start digging.

from swiftmockgeneratorforxcode.

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.