Develop Apple software products within your favorite editor.
An Xcode replacement-ish development environment that aims to be your reliable Xcode alternative to develop exciting new [apple] software products ๐.
Table of Content
- [๐ Overview]
- [๐ Motivation]
- [๐ Features]
- [๐ Generators]
- [๐ Requirements]
- [๐ฆพ Installation]
- [๐ฎ Usage]
- [โ๏ธ Defaults]
- [๐ฉบ Debugging]
- [๐ฅ Preview]
๐ Overview
[XBase] enables you to build, watch, and run xcode products as well as swift packages 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).
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)
Please be aware that [XBase] is still WIP, so don't hesitate to report bugs, ask questions or suggest new exciting features.
๐ 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.
As a long-time vim user who has previously developed a several lua/nvim plugins, I decided to invest some effort in simplifying my development workflow for producing 'xOS' products.
๐ Features
- Auto-Completion and Code navigation\
- Multi-nvim instance support\
- Auto-start/stop main background daemon\
- Multi Target/Project Support\
- Simulator Support\
- Runtime/Build Logging\
- Statusline Support\
- Zero Footprint\
- Multi XcodeProj Generator Support\
- Swift Package Support\
.build folder doesn't exists, Package.swift file is updated or new files or directories are 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
Shared
- [rust] ^1.60 compile project locally
Neovim
- [neovim] ^0.7 Neovim Editor.
- [lspconfig] * LSP integration.
- [telescope.nvim] ^0.1 better picker UI experience optional
- [dressing.nvim] * support for other neovim ecosystem pickers optional
Vscode
TODO
๐ฆพ Installation
To install [XBase] on your system you need run make install. This will run cargo build --release and resulting binrary to ~/.local/share/xbase/.
Neovim
With [packer]
use {
'xbase-lab/xbase',
run = 'make install', -- or "make install && make free_space" (not recommended, longer build time)
requires = {
"neovim/nvim-lspconfig",
-- "nvim-telescope/telescope.nvim", -- optional
-- "nvim-lua/plenary.nvim", -- optional/requirement of telescope.nvim
-- "stevearc/dressing.nvim", -- optional (in case you don't use telescope but something else)
},
config = function()
require'xbase'.setup({}) -- see default configuration bellow
end
}
With [vim-plug]
" Plug 'nvim-telescope/telescope.nvim' " optional
" Plug 'nvim-lua/plenary.nvim' " optional/requirement of telescope
" Plug 'stevearc/dressing.nvim' " optional/in case you don't use telescope but use something else
Plug 'neovim/nvim-lspconfig'
Plug 'xbase-lab/xbase', { 'do': 'make install' }
lua require'xbase'.setup()
With [dein]
" call dein#add('nvim-telescope/telescope.nvim') " optional
" call dein#add('nvim-lua/plenary.nvim') " optional/requirement of telescope
" call dein#add('stevearc/dressing.nvim') " optional/in case you don't use telescope but use something else
call dein#add('neovim/nvim-lspconfig')
call dein#add('xbase-lab/xbase', { 'build': 'make install' })
lua require'xbase'.setup()
NOTE: You need to setup sourcekit-lsp (see [sourcekit-setup]) and consider adding more
file to root patterns
Vscode
TODO
๐ฎ Usage
Neovim
TLDR:
- Install XBase
- 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
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 daemon, checkout the configurable shortcuts.
Statusline
[XBase] provide [feline] provider, other statusline plugins support are welcomed. However, using vim.g.xbasewatchbuild_status you can easily setup statusline indicators.
require("xbase.statusline").feline() -- append to feline setup function
Vscode
TODO
โ๏ธ Defaults
Neovim
-- NOTE: Defaults
{
--- Log level. Set it to ERROR to ignore everything
log_level = vim.log.levels.DEBUG,
--- Options to be passed to lspconfig.nvim's sourcekit setup function.
--- Setting this to {} is sufficient, However, it is strongly recommended to use on_attach key to setup custom mappings
--- {
--- cmd = { "sourcekit-lsp", "--log-level", "error" },
--- filetypes = { "swift" },
--- root_dir = pattern("Package.swift", ".git", "project.yml", "Project.swift"),
--- }
sourcekit = nil, -- Disabled by default (xbase will not call it for you)
--- Statusline provider configurations
statusline = {
watching = { icon = "๏", color = "#1abc9c" },
device_running = { icon = "๏ด", color = "#4a6edb" },
success = { icon = "๏
", color = "#1abc9c" },
failure = { icon = "๏", color = "#db4b4b" },
},
--- Simulators to only include.
--- run xcrun simctl list to get a full list of available simulator
--- If the list is empty then all simulator available will be included
simctl = {
iOS = {
-- "iPhone 13 Pro", --- only use this devices
},
watchOS = {}, -- all available devices
tvOS = {}, -- all available devices
},
--- Log buffer configurations
log_buffer = {
--- Whether toggling the buffer should auto focus to it?
focus = true,
--- Split Log buffer height
height = 20,
--- Vsplit Log buffer width
width = 75,
--- Default log buffer direction: { "horizontal", "vertical" }
default_direction = "horizontal",
},
--- Mappings
mappings = {
--- Whether xbase mapping should be disabled.
enable = true,
--- Open build picker. showing targets and configuration.
build_picker = "<leader>b", --- set to 0 to disable
--- Open run picker. showing targets, devices and configuration
run_picker = "<leader>r", --- set to 0 to disable
--- Open watch picker. showing run or build, targets, devices and configuration
watch_picker = "<leader>s", --- set to 0 to disable
--- A list of all the previous pickers
all_picker = "<leader>ef", --- set to 0 to disable
--- horizontal toggle log buffer
togglesplitlog_buffer = "<leader>ls",
--- vertical toggle log buffer
togglevsplitlog_buffer = "<leader>lv",
},
}
Vscode
TODO
๐ฉบ Debugging
Sometimes xcodebuild acts up and things might break, the first step to find the root cause is to check logs. The following is how you can have a stream of logs in your terminal.
# Daemon logs
tail -f /tmp/xbase.log
Build Server logs
tail -f /tmp/xbase-build-server.log
In case, you need to manually stop servers:
killall xbase xbase-sourcekit-helper
[xcodegen]: https://github.com/yonaskolb/XcodeGen [sourcekit-lsp]: https://github.com/apple/sourcekit-lsp [XBase]: https://github.com/xbase-lab/xbase [xcodebuild]: https://github.com/xbase-lab/xcodebuild [feline]: https://github.com/feline-nvim/feline.nvim [XVim2]: https://github.com/XVimProject/XVim2 [rust]: https://www.rust-lang.org [tuist]: https://github.com/tuist/tuist [dein]: https://github.com/Shougo/dein.vim [packer]: https://github.com/wbthomason/packer.nvim [vim-plug]: https://github.com/junegunn/vim-plug [rust getting started]: https://www.rust-lang.org/tools/install [telescope.nvim]: https://github.com/nvim-telescope/telescope.nvim [plenary.nvim]: https://github.com/nvim-lua/plenary.nvim [neovim]: https://github.com/neovim/neovim [tuist]: https://github.com/tuist/tuist [dev.md]: ./dev.md [lspconfig]: https://github.com/neovim/nvim-lspconfig [sourcekit-setup]: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sourcekit [apple]: https://github.com/apple [dressing.nvim]: https://github.com/stevearc/dressing.nvim
[๐ Overview]: #-motivation [๐ Motivation]: #-motivation [๐ Features]: #-features [๐ Generators]: #-generators [๐ Requirements]: #-requirements [๐ฎ Usage]: #-usage [๐ฆพ Installation]: #-installation [โ๏ธ Defaults]: #-defaults [๐ฉบ Debugging]: #-debugging [๐ฅ Preview]: #-preview