Comments (8)
There are a couple of problems there... The API for Xcode 8 Source Code Extension is still pretty limited. I think it could be pretty hard to determine the context of the source file you're looking at in Xcode as in:
- it's full path
- the project it is related to
However, if you could just feed Sourcery with text and make something out of that, it might work. I'll try to remember what we were brainstorming for Import extension, I think there was some stuff that could help. @clementpadovani @velyan
from sourcery.
I was thinking of just feeding the text to the tool, since we usually need only local context for snippets, if we wanted full AST then we could write regular plugin but that requires people to unsign Xcode so better to limit it to native extension. Looking forward to hearing your experiences with it, I didn't had a chance to write the native extensions yet :)
from sourcery.
from sourcery.
Do we have access to darwin notifications in extensions? If we do we could potentially use that to communicate between the app and extension, sourcery
can run it's parsing on text as it does in tests
from sourcery.
from sourcery.
Darwin notifications only have a single uint64_t
state variable to communicate information. What does the sandbox profile for a source editor extension roughly look like?
from sourcery.
So I've just made a simple prototype to work thanks to to the link from @ikesyo There are still few limitations, like extension not being provided with any kind of project info except currently opened file's content, or not being able to access any files out if it's container. But to make it work just for currently opened file will be possible in short time.
But there are few more things to solve here. Like accessing templates. As extension can not access anything outside it's container (which is ~/Library/Containers/extension.bundle.id/Data) it will be impossible to discover any template unless they are copied into this folder. This could be a simple task to solve just with a special cli command that would do that. When templates are copied extension can provide a menu item for each of them.
Going forward we could make an app (extension requires an app anyway) to manage templates, maybe even with a simple editor functionality.
And to make the extension really powerful we would need to give it access to Sourcery cache (again copying it to the container) that would be constantly updated in the background using some demon process maybe. Though this looks pretty complex and maybe it would be better to wait for the next version of Xcode if there would be any improvements for extensions from Apple.
The other way is to simply write a path to the sources to scan into extension container directory and scan them on each extension run using XPC service for Sourcery itself, instead of SourceKitten which I implemented now. This will also require to provide Sourcery functionality via framework ala SourceKittenFramework.
@krzysztofzablocki what do you think?
from sourcery.
I'd reckon we should wait for next Xcode version and see what they provide there, rather than complicating the tool too much, especially now that we have inline generation
from sourcery.
Related Issues (20)
- Malformed generated mocks HOT 1
- Missing bin folder with 2.1.3 HOT 5
- Missing bin folder with 2.1.4 HOT 5
- Homebrew does not include latest version (2.1.4) HOT 3
- The platform of the target `MyApp` (iOS 16.0) is not compatible with `Sourcery (2.1.4)`, which does not support `iOS` HOT 18
- AutoMockable stencil does not support inout parameters HOT 3
- Generated Automockable compilation issue due to malformed generated variable name HOT 2
- Generated AutoMockable compilation issue due to variadic parameters HOT 11
- [BUG] Generated AutoMockable compilation issues HOT 1
- Windows Support
- Sourcery doesn't properly work when using protocols with primary associated types HOT 2
- Add whitespace trimming configuration for Stencil templates
- [QUESTION] Thread-Safe Mocks HOT 1
- [Bug] Failed to resolve dependencies (SPM issue) HOT 5
- Watch mode only watches sources from last configuration file when passing multiple paths to configuration files using `--config` command line options
- Getting generic requirements from methods HOT 1
- Possible to generate asset catalog constants? HOT 1
- Detecting if a variable is an Enum works if enum is declared in the file but doesn't otherwise. HOT 4
- AutoMockable does not generate valid Swift code during method generic requirement parsing HOT 2
- Swift macros and method bodies HOT 1
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 sourcery.