Skip to content

Commit

Permalink
feat: support tuist (#91)
Browse files Browse the repository at this point in the history
* feat(tuist): support regeneration
* feat(project): support generating xcodeproj when absent
* feat(compile): append xcodeproj generation logs
* ref(compile): check for xcodeproj before trying to generate it
* feat(tuist): generate both project and manifest xcodeproj
* feat(tuist): generate compile commands for both project and manifest
* feat(nvim): update status variable when watch is running
* ref(project): decompose and specialize
* feat(tuist): lsp support for tuist files
* chore(readme): update
* ref: make main binary named xbase
* feat(tuist): recompile on config files change
* fix(xcodegen): ignoring existing xcodeproj
* fix(compile): on file rename
  • Loading branch information
kkharji authored Jun 21, 2022
1 parent ba9f297 commit 79ea745
Show file tree
Hide file tree
Showing 34 changed files with 955 additions and 526 deletions.
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ Client/Daemon requests and types definitions.

### [daemon] crate

The main product of [xbase] reside, it handle requets and data defined in [proto] crate.
The main product of [xbase] reside, it handle requests and data defined in [proto] crate.

- [build.rs](./daemon/src/build.rs): build request handler definition.
- [run.rs](./daemon/src/run.rs): run request handler definition.
- [drop.rs](./daemon/src/drop.rs): drop request handler definition.
- [register.rs](./daemon/src/register.rs): register request handler definition.
- [nvim.rs](./daemon/src/nvim.rs): helper methods to interact with running nvim instance.
- [project.rs](./daemon/src/project/mod.rs): traits to be implement for each supported project setup.
- [xcodegen.rs](./daemon/src/project/xcodegen.rs): implantation of project traits for xcodegen projects.
- [tuist.rs](./daemon/src/project/tuist.rs): implantation of project traits for tuist projects.
- [barebone.rs](./daemon/src/project/barebone.rs): implantation of project traits for barebone (i.e. no generators) projects.

### [sourcekit] crate

Expand Down
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint:
nix-shell -p lua51Packages.luacheck --command 'luacheck lua/xbase && exit 0 || exit 1'

watch:
RUST_LOG="trace" cargo watch -x 'build' -x 'run -p xbase-daemon' -w 'sourcekit' -w 'daemon' -w 'proto' -w 'lualib' -c
RUST_LOG="debug" cargo watch -x 'build -p xbase-sourcekit-helper -p xbase-lualib' -x 'run -p xbase' -w 'sourcekit' -w 'daemon' -w 'proto' -w 'lualib' -c

clean:
cargo clean
Expand All @@ -21,7 +21,7 @@ clean:
install: clean
mkdir bin
cargo build --release
mv target/release/xbase-daemon ./bin/xbase-daemon
mv target/release/xbase ./bin/xbase
mv target/release/xbase-sourcekit-helper ./bin/xbase-sourcekit-helper
mv target/release/libxbase_lualib.dylib ./lua/libxbase.so
cargo clean # NOTE: 3.2 GB must be cleaned up
Expand All @@ -30,7 +30,7 @@ install: clean
install_debug: clean
mkdir bin
cargo build
ln -sf ../target/debug/xbase-daemon ./bin/xbase-daemon
ln -sf ../target/debug/xbase ./bin/xbase
ln -sf ../target/debug/xbase-sourcekit-helper ./bin/xbase-sourcekit-helper
ln -sf ../target/debug/libxbase_lualib.dylib ./lua/libxbase.so
echo "DONE"
140 changes: 91 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,34 @@
<img src="./media/logo.png" alt="drawing" style="width:400px;"/>
</P>

## 👁 Overview

An XCode replacement-ish *development environment* that aims to be your reliable XCode alternative to develop exciting new [apple] software products 🚀.

[XBase] enables you to build, watch, and run xcode products from within your favorite editor. It supports running products on iOS, watchOS and tvOS simulators, along with real-time logging, and some lsp features such as auto-completion and code navigation. (for a complete list of features, see [🌟 Features](#-features)).
## Table of Content

- [👁 Overview]
- [🌝 Motivation]
- [🌟 Features]
- [💆 Generators]
- [🛠 Requirements]
- [🦾 Installation]
- [🎮 Usage]
- [⚙️ Defaults]
- [🩺 Debugging]
- [🎥 Preview]

Furthermore, [XBase] has built-in support for a variety of XCode project generators, which allow you to avoid launching XCode or manually editing '*.xcodeproj' anytime you add or remove files. We strongly advise you to use one ... at least till [XBase] supports adding/removing files and folders, along with other requirements. (For further information, see [💆 Generators](#-generators))
## 👁 Overview

[XBase] enables you to build, watch, and run xcode products from within your favorite editor. It supports running products on iOS, watchOS and tvOS simulators, along with real-time logging, and some lsp features such as auto-completion and code navigation. ([🌟 Features](#-features)).

Furthermore, [XBase] has built-in support for a variety of XCode project generators, which allow you to avoid launching XCode or manually editing '*.xcodeproj' anytime you add or remove files. We strongly advise you to use one ... at least till [XBase] supports adding/removing files and folders, along with other requirements. ([💆 Generators](#-generators))

- Watch [XBase] repo to remain up to date on fresh improvements and exciting new features.
- Checkout [Milestones](https://github.com/tami5/xbase/milestones) for planned future features and releases.
- Visit [CONTRIBUTING.md](./CONTRIBUTING.md) to have your setup to start contributing and support the project.
- Visit [CONTRIBUTING.md] to have your setup to start contributing and support the project.

Please be aware that [XBase] is still **WIP**, so don't hesitate to report bugs, ask questions or suggest new exciting features.


## Table of Content

- [🌝 Motivation](#-motivation)
- [🌟 Features](#-features)
- [🛠 Requirements](#-requirements)
- [🎮 Usage](#-usage)
- [🦾 Installation](#-installation)
- [⚙️ Defaults](#-defaults)
- [🩺 Debugging](#-debugging)
- [💆 Generators](#-generators)
- [🎥 Preview](#-preview)

## 🌝 Motivation

I chose to dive into iOS/macOS app development after purchasing an M1 MacBook. However, coming from vim/shell environment and being extremely keyboard oriented, I couldn't handle the transition to a closed sourced, opinionated, mouse-driven development environment. I've considered alternatives like [XVim2] and the built-in vim emulator, however still, I'd catch myself frequently hunting for my mouse.
Expand All @@ -38,23 +39,51 @@ As a long-time vim user who has previously developed a several lua/nvim plugins,
## 🌟 Features

* **Auto-Completion and Code navigation**\
[sourcekit-lsp] does not support auto-indexing. As a result, [XBase] contains a method for regenerating compilation instructions on directory changes (i.e. file removal/addition), as well as a custom build server that assists [sourcekit-lsp] in providing code navigation and auto complation for project symbols.
Auto-generate compilation database on directory changes + a custom build server that assists [sourcekit-lsp] in providing code navigation and auto-completion for project symbols.
* **Multi-nvim instance support**\
Thanks to having a single daemon running and simple client/server architecture, users can have and use multiple nvim instance running without process duplications and shared state. For instance, stop a watch service that was being run from a different instance.
Multiple nvim instance support without process duplications and shared state. For instance, you can stop a watch service that was being run from a different instance.
* **Auto-start/stop main background daemon**\
There is no need to manually start/stop the daemon background. The daemon will start and end automatically based on the number of connected client instances.
Daemon will start and stop automatically based on the number of connected client instances.
* **Multi Target/Project Support**\
Users can work on many projects at the same time and build/run on root directory changes or once. TODO
Work on multiple projects at one nvim instance at the same time. TODO
* **Simulator Support**\
Pick a simulator device that is close to the target's platform and run the target only once or whenever a file changes. Furthermore, if the simulator is not already running, the service will launch the simulator before installing and running your app.
* **Logging buffer**\
Real-time recording of 'print()' commands and real-time build logs Currently, logs are unique to the requested client; if you want shared logs, please submit an issue.
Run your products on simulators relative to your target's platform. (+ watch build and ran on change)
* **Runtime/Build Logging**\
Real-time logging of build logs and 'print()' commands
* **Statusline Support**\
Global variable to update statusline with build/run commands + [feline] provider. Other statusline plugins support are welcomed.
Global variable to update statusline with build/run commands, see [Statusline](#statusline)
* **Zero Footprint**\
Light resource usage. I've been using [XBase] for a while; it typically uses 0.1 percent RAM and 0 percent CPU.
* **XcodeGen Support**\
Automatically generate new xcodeproj when you edit
* **Multi XCodeProj Support**\
Auto-generate xcodeproj, when it doesn't exists, generator config files a updated or new files/directories added or removed.

## 💆 Generators

[XBase] primarily supports two project generators: [XcodeGen] and [Tuist].

[XCodeGen] is **recommended** if you are just starting started with `xcodeproj generators`
since it is considerably simpler with a yml-based configuration language. Having said that,
[Tuist] is more powerful and packed with features, of which `xcodeproj generation` is but one.

[XBase]'s support for generators is available in the following forms:

- Identification.
- Auto-generate xcodeproj if you haven't haven't generate it by hand.
- Auto-generate xcodeproj when you edit the generator config files.
- Auto-compile project when xcodeproj get regenerated.
- Code Completion and navigation (#tuist)

### Limitations

#### [XCodeGen]

- No support for custom named yml config files, only `project.yml`.

#### Other Generators

With current [XBase] architecture, it should be pretty easy to add support for yet another
awesome xcodeproj generator. feel free to get started with [CONTRIBUTING.md] or open a github
issue

## 🛠 Requirements

Expand All @@ -63,22 +92,6 @@ As a long-time vim user who has previously developed a several lua/nvim plugins,
- [telescope.nvim]
- [plenary.nvim]

## 🎮 Usage

TLDR:
- [Install XBase](#-installation)
- run `require'xbase'.setup({ --[[ see default configuration ]] })`
- Open xcodeproj codebase.
- Wait for first time project setup finish.
- Start coding
- Use available actions which can be configure with shortcuts bellow

When you start a neovim instance with a root that contains `project.yml,` `Project.swift,` or
`*.xcodeproj,` the daemon server will auto-start if no instance is running, and register the
project once for recompile-watch. To communicate with your deamon, checkout the configurable
shortcuts.


## 🦾 Installation

To install [XBase] on your system you need run `make install`. This will run `cargo build
Expand Down Expand Up @@ -117,6 +130,29 @@ call dein#add('tami5/xbase', { 'build': 'make install' })
lua require'xbase'.setup()
```

## 🎮 Usage

TLDR:
- [Install XBase](#-installation)
- run `require'xbase'.setup({ --[[ see default configuration ]] })`
- Open xcodeproj codebase.
- Wait for first time project setup finish.
- Start coding
- Use available actions which can be configure with shortcuts bellow

When you start a neovim instance with a root that contains `project.yml,` `Project.swift,` or
`*.xcodeproj,` the daemon server will auto-start if no instance is running, and register the
project once for recompile-watch. To communicate with your deamon, checkout the configurable
shortcuts.

### Statusline

[XBase] provide [feline] provider, other statusline plugins support are welcomed. However,
using `vim.g.xbase_watch_build_status` you can easily setup statusline indicators.

```lua
require("xbase.util").feline_provider() -- append to feline setup function
```

## ⚙️ Defaults
```lua
Expand Down Expand Up @@ -161,11 +197,6 @@ lua require'xbase'.setup()
}
```

## 💆 Generators

Currently, [XBase] supports two project generators: [XcodeGen] and [Tuist]. Support is compes
in form of recompiling the project and regenerating 'xcodeproj' everytime the generator config file is
modified.

## 🩺 Debugging

Expand Down Expand Up @@ -202,4 +233,15 @@ statusline get updated.
[plenary.nvim]: https://github.com/nvim-lua/plenary.nvim
[neovim]: https://github.com/neovim/neovim
[tuist]: https://github.com/tuist/tuist

[CONTRIBUTING.md]: ./CONTRIBUTING.md

[👁 Overview]: #-motivation
[🌝 Motivation]: #-motivation
[🌟 Features]: #-features
[💆 Generators]: #-generators
[🛠 Requirements]: #-requirements
[🎮 Usage]: #-usage
[🦾 Installation]: #-installation
[⚙️ Defaults]: #-defaults
[🩺 Debugging]: #-debugging
[🎥 Preview]: #-preview
4 changes: 3 additions & 1 deletion daemon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "xbase-daemon"
name = "xbase"
version = "0.1.2"
edition = "2021"

Expand Down Expand Up @@ -28,6 +28,7 @@ async-stream = { version = "0.3.3" }
parity-tokio-ipc = { version = "0.9.0" }
process-stream = { version = "0.2.*" }
xcodeproj = { version = "0.2.*" }
# xcodeproj = { path = "../../xcodeproj/" }

# Filesystem watcher
notify = { version = "5.0.0-pre.13" }
Expand All @@ -52,3 +53,4 @@ libc = { version = "0.2.126"}
libproc = { version = "0.12.0" }
paste = "1.0.7"
which = "4.2.5"
erased-serde = "0.3.21"
3 changes: 1 addition & 2 deletions daemon/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ impl Watchable for BuildRequest {
log::info!("Building {}", self.client.abbrev_root());
let is_once = self.ops.is_once();
let (root, config) = (&self.client.root, &self.settings);
// let args = state.projects.get(root)?.build_args(&config, &None)?;
let args: Vec<String> = vec![];
let args = state.projects.get(root)?.build_arguments(&config, &None)?;

let nvim = state.clients.get(&self.client.pid)?;
let ref mut logger = nvim.logger();
Expand Down
Loading

0 comments on commit 79ea745

Please sign in to comment.