Comments (2)
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.
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)
- Installation? HOT 1
- Using this with Objective C HOT 1
- Typo in permission error message
- Generated code does not follow the enclosing class access control HOT 1
- Extension doesn't work on Big Sur HOT 16
- ObjectToTest ???? HOT 2
- Can't find Mock Generator on Big Sur HOT 1
- import AST errors HOT 2
- Stubs are not generated when the member variable end in a '$'
- Optional properties have a force-unwrapped stub
- Installation via Homebrew
- Stopped working under Big Sur and Xcode 12.4 HOT 1
- Extensions not supported HOT 1
- Indentation follows Xcode ctrl-i
- Naming Conventions
- Generate async mocks HOT 6
- Cannot compile because of missing private framework `SwiftToolkit`
- Optional function parameter break generator
- Handle generic completion handlers in mocked function
- Can I enter it in the function?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftmockgeneratorforxcode.