-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathxcodebuild.txt
More file actions
5570 lines (3800 loc) · 186 KB
/
Copy pathxcodebuild.txt
File metadata and controls
5570 lines (3800 loc) · 186 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
==============================================================================
Table of Contents *xcodebuild.contents*
Introduction ······················································ |xcodebuild|
Features ················································· |xcodebuild.features|
Requirements ········································· |xcodebuild.requirements|
Highlights ············································· |xcodebuild.highlights|
Key Bindings ············································· |xcodebuild.bindings|
User Commands ············································ |xcodebuild.commands|
Global Variables ································· |xcodebuild.global_variables|
Debugging On iOS 17+ Device ···················· |xcodebuild.integrations.ios17|
Health Check ··············································· |xcodebuild.health|
Actions ··················································· |xcodebuild.actions|
Constants ··············································· |xcodebuild.constants|
Autocommands ········································· |xcodebuild.core.autocmd|
Default Options ······································· |xcodebuild.core.config|
Quickfix List ······································· |xcodebuild.core.quickfix|
Xcodebuild Wrapper ····································· |xcodebuild.core.xcode|
UI Previews ········································· |xcodebuild.core.previews|
Xcode Logs Parser ······························· |xcodebuild.xcode_logs.parser|
Logs Panel ······································· |xcodebuild.xcode_logs.panel|
Project Configuration ······························ |xcodebuild.project.config|
App Data ·········································· |xcodebuild.project.appdata|
Project Builder ··································· |xcodebuild.project.builder|
Project Manager ··································· |xcodebuild.project.manager|
Project Assets Manager ····························· |xcodebuild.project.assets|
Device ············································ |xcodebuild.platform.device|
Device Proxy ································ |xcodebuild.platform.device_proxy|
macOS Platform Integration ························· |xcodebuild.platform.macos|
Debugger ········································ |xcodebuild.platform.debugger|
Swift Macro Management ···························· |xcodebuild.platform.macros|
Autocommand Events ···························· |xcodebuild.broadcasting.events|
Notifications ·························· |xcodebuild.broadcasting.notifications|
Test Diagnostics ································ |xcodebuild.tests.diagnostics|
Test Enumeration Parser ·················· |xcodebuild.tests.enumeration_parser|
Test Explorer ······································ |xcodebuild.tests.explorer|
Test Provider ······································ |xcodebuild.tests.provider|
Test Runner ·········································· |xcodebuild.tests.runner|
Test Search ·········································· |xcodebuild.tests.search|
Snapshot Tests ···································· |xcodebuild.tests.snapshots|
Xcresult File Parser ························ |xcodebuild.tests.xcresult_parser|
Code Coverage ······························ |xcodebuild.code_coverage.coverage|
Code Coverage Report ························· |xcodebuild.code_coverage.report|
DAP Integration ·································· |xcodebuild.integrations.dap|
DAP Configurations - lldb ······················· |xcodebuild.integrations.lldb|
DAP Configurations - codelldb ··············· |xcodebuild.integrations.codelldb|
DAP Symbolicate ······················ |xcodebuild.integrations.dap-symbolicate|
Remote Debugger Integration ·········· |xcodebuild.integrations.remote_debugger|
LSP Integration ·································· |xcodebuild.integrations.lsp|
nvim-tree Integration ······················ |xcodebuild.integrations.nvim-tree|
neo-tree.nvim Integration ··················· |xcodebuild.integrations.neo-tree|
oil.nvim Integration ························ |xcodebuild.integrations.oil-nvim|
Quick Test Framework Integration ··············· |xcodebuild.integrations.quick|
xcode-build-server Integration ···· |xcodebuild.integrations.xcode-build-server|
Xcodebuild Workaround ············· |xcodebuild.integrations.xcodebuild-offline|
Telescope Picker ··························· |xcodebuild.integrations.telescope|
fzf-lua Integration ·························· |xcodebuild.integrations.fzf-lua|
Snacks Picker Integration ·············· |xcodebuild.integrations.snacks-picker|
Pickers ················································ |xcodebuild.ui.pickers|
Picker Actions ·································· |xcodebuild.ui.picker_actions|
Utils For Pickers ································ |xcodebuild.ui.pickers_utils|
Helpers ··················································· |xcodebuild.helpers|
Lua Utils ···················································· |xcodebuild.util|
==============================================================================
Introduction *xcodebuild*
Xcodebuild.nvim is a plugin designed to let you migrate your app
app development from Xcode to Neovim. It provides all essential actions
for development including building, debugging, and testing.
Make sure to check out Tips & Tricks to improve your development in Neovim:
https://github.com/wojciech-kulik/xcodebuild.nvim/discussions/categories/tips-tricks
Source Code: https://github.com/wojciech-kulik/xcodebuild.nvim
*xcodebuild.nvim*
*xcodebuild.config*
*xcodebuild.options*
M.setup({options}) *xcodebuild.setup*
Setup and initialize xcodebuild.nvim
Parameters: ~
{options} (table|nil)
All options are optional, below you can see the default values:
Usage: ~
>lua
require("xcodebuild").setup({
restore_on_start = true, -- logs, diagnostics, and marks will be loaded on VimEnter (may affect performance)
auto_save = true, -- save all buffers before running build or tests (command: silent wa!)
show_build_progress_bar = true, -- shows [ ... ] progress bar during build, based on the last duration
prepare_snapshot_test_previews = true, -- prepares a list with failing snapshot tests
project_config = {
store_in_project_dir = true, -- if true, the configuration directory is stored in the project directory. If false, it's stored in a global nvim data directory
search_in_parent_dirs = false, -- search for configuration in parent directories
reload_on_cwd_change = false, -- detect when the current working directory changes and update the configuration accordingly
},
test_search = {
file_matching = "filename_lsp", -- one of: filename, lsp, lsp_filename, filename_lsp. Check out README for details
target_matching = true, -- checks if the test file target matches the one from logs. Try disabling it in case of not showing test results
lsp_client = "sourcekit", -- name of your LSP for Swift files
lsp_timeout = 200, -- LSP timeout in milliseconds
},
commands = {
extra_build_args = { "-parallelizeTargets" }, -- extra arguments for `xcodebuild build`
extra_test_args = { "-parallelizeTargets" }, -- extra arguments for `xcodebuild test`
project_search_max_depth = 3, -- maxdepth of xcodeproj/xcworkspace search while using configuration wizard
focus_simulator_on_app_launch = true, -- focus simulator window when app is launched
keep_device_cache = false, -- keep device cache even if scheme or project file changes
},
logs = { -- build & test logs
auto_open_on_success_tests = false, -- open logs when tests succeeded
auto_open_on_failed_tests = false, -- open logs when tests failed
auto_open_on_success_build = false, -- open logs when build succeeded
auto_open_on_failed_build = true, -- open logs when build failed
auto_close_on_app_launch = false, -- close logs when app is launched
auto_close_on_success_build = false, -- close logs when build succeeded (only if auto_open_on_success_build=false)
auto_focus = true, -- focus logs buffer when opened
filetype = "", -- file type set for buffer with logs
open_command = "silent botright 20split {path}", -- command used to open logs panel. You must use {path} variable to load the log file
logs_formatter = "xcbeautify --disable-colored-output --disable-logging", -- command used to format logs, you can use "" to skip formatting
only_summary = false, -- if true logs won't be displayed, just xcodebuild.nvim summary
live_logs = true, -- if true logs will be updated in real-time
show_warnings = true, -- show warnings in logs summary
notify = function(message, severity) -- function to show notifications from this module (like "Build Failed")
vim.notify(message, severity)
end,
notify_progress = function(message) -- function to show live progress (like during tests)
vim.cmd("echo '" .. message .. "'")
end,
},
console_logs = {
enabled = true, -- enable console logs in dap-ui
format_line = function(line) -- format each line of logs
return line
end,
filter_line = function(line) -- filter each line of logs
return true
end,
},
marks = {
show_signs = true, -- show each test result on the side bar
success_sign = "✔", -- passed test icon
failure_sign = "✖", -- failed test icon
show_test_duration = true, -- show each test duration next to its declaration
show_diagnostics = true, -- add test failures to diagnostics
},
quickfix = {
show_errors_on_quickfixlist = true, -- add build/test errors to quickfix list
show_warnings_on_quickfixlist = true, -- add build warnings to quickfix list
},
test_explorer = {
enabled = true, -- enable Test Explorer
auto_open = true, -- open Test Explorer when tests are started
auto_focus = true, -- focus Test Explorer when opened
open_command = "botright 42vsplit Test Explorer", -- command used to open Test Explorer, must create a buffer with "Test Explorer" name
open_expanded = true, -- open Test Explorer with expanded classes
success_sign = "✔", -- passed test icon
failure_sign = "✖", -- failed test icon
progress_sign = "…", -- progress icon (only used when animate_status=false)
disabled_sign = "⏸", -- disabled test icon
partial_execution_sign = "‐", -- icon for a class or target when only some tests were executed
not_executed_sign = " ", -- not executed or partially executed test icon
show_disabled_tests = false, -- show disabled tests
animate_status = true, -- animate status while running tests
cursor_follows_tests = true, -- moves cursor to the last test executed
},
code_coverage = {
enabled = false, -- generate code coverage report and show marks
file_pattern = "*.swift", -- coverage will be shown in files matching this pattern
-- configuration of line coverage presentation:
covered_sign = "",
partially_covered_sign = "┃",
not_covered_sign = "┃",
not_executable_sign = "",
},
code_coverage_report = {
warning_coverage_level = 60,
error_coverage_level = 30,
open_expanded = false,
},
project_manager = {
guess_target = true, -- guess target for the new file based on the file path
find_xcodeproj = false, -- instead of using configured xcodeproj search for xcodeproj closest to targeted file
should_update_project = function(path) -- path can lead to directory or file
-- it could be useful if you mix Xcode project with SPM for example
return true
end,
project_for_path = function(path)
-- you can return a different project for the given {path} (could be directory or file)
-- ex.: return "/your/path/to/project.xcodeproj"
return nil
end,
},
previews = {
open_command = "vertical botright split +vertical\\ resize\\ 42 %s | wincmd p", -- command used to open preview window
show_notifications = true, -- show preview-related notifications
},
device_picker = {
mappings = {
move_up_device = "<M-y>", -- move device up in the list
move_down_device = "<M-e>", -- move device down in the list
add_device = "<M-a>", -- add device to cache
delete_device = "<M-d>", -- delete device from cache
refresh_devices = "<C-r>", -- refresh devices list
},
},
macro_picker = {
auto_show_on_error = true, -- automatically show macro approval picker when build fails due to unapproved macros
mappings = {
approve_macro = "<C-a>", -- approve the selected macro
},
},
integrations = {
pymobiledevice = {
enabled = true, -- enable pymobiledevice integration (requires configuration, see: `:h xcodebuild.remote-debugger`)
remote_debugger_port = 65123, -- port used by remote debugger (passed to pymobiledevice3)
},
xcodebuild_offline = {
enabled = false, -- improves build time when using Xcode below 26 (requires configuration, see `:h xcodebuild.xcodebuild-offline`)
},
xcode_build_server = {
enabled = true, -- enable calling "xcode-build-server config" when project config changes
guess_scheme = false, -- run "xcode-build-server config" with the scheme matching the current file's target
},
nvim_tree = {
enabled = true, -- enable updating Xcode project files when using nvim-tree
},
neo_tree = {
enabled = true, -- enable updating Xcode project files when using neo-tree.nvim
},
oil_nvim = {
enabled = true, -- enable updating Xcode project files when using oil.nvim
},
quick = { -- integration with Swift test framework: github.com/Quick/Quick
enabled = true, -- enable Quick tests support (requires Swift parser for nvim-treesitter)
},
telescope_nvim = {
enabled = true, -- enable telescope picker
},
snacks_nvim = {
enabled = true, -- enable Snacks.nvim picker
layout = nil, -- Snacks layout config, check Snacks docs for details
},
fzf_lua = {
enabled = true, -- enable fzf-lua picker
fzf_opts = {}, -- fzf options
win_opts = {}, -- window options
},
codelldb = {
enabled = false, -- enable codelldb dap adapter for Swift debugging
port = 13000, -- port used by codelldb adapter
codelldb_path = nil, -- path to codelldb binary, REQUIRED, example: "/Users/xyz/tools/codelldb/extension/adapter/codelldb"
lldb_lib_path = "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB", -- path to lldb library
},
lldb = {
port = 13000, -- port used by lldb-dap
},
},
highlights = {
-- you can override here any highlight group used by this plugin
-- simple color: XcodebuildCoverageReportOk = "#00ff00",
-- link highlights: XcodebuildCoverageReportOk = "DiagnosticOk",
-- full customization: XcodebuildCoverageReportOk = { fg = "#00ff00", bold = true },
},
})
<
M.setup_commands() *xcodebuild.setup_commands*
Sets up user commands for xcodebuild.nvim
M.setup_modules() *xcodebuild.setup_modules*
Sets up all modules of xcodebuild.nvim
M.update_cwd() *xcodebuild.update_cwd*
Refreshes the plugin to use the correct `{appdir}` based on the current working directory.
==============================================================================
Features *xcodebuild.features*
- Support for iOS, iPadOS, watchOS, tvOS, visionOS, and macOS.
- Support for Swift Packages (building & testing).
- Project-based configuration.
- Project Manager to deal with project files without using Xcode.
- Assets Manager to manage images, colors, and data assets.
- Test Explorer to visually present a tree with all tests and results.
- Built using official command line tools like `xcodebuild` and `xcrun simctl`.
- Actions to build, run, debug, and test apps on simulators and
- Previews for SwiftUI, UIKit, and AppKit views.
physical devices.
- Environment variables and run arguments management.
- Buffer integration with test results
(code coverage, success & failure marks, duration, extra diagnostics).
- Code coverage report with customizable levels.
- Advanced log parser to detect all errors, warnings, and failing tests.
- `nvim-tree`, `neo-tree.nvim`, and `oil.nvim` integration that automatically
reflects all file tree operations and updates Xcode project file.
- `nvim-dap` integration to let you easily build, run, and debug apps.
- `nvim-dap-ui` integration to show app logs in the console window.
- `lualine.nvim` integration to show selected device, test plan,
and other project settings.
- `swift-snapshot-testing` integration to present diff views for failing snapshot tests.
- `Quick` integration to show test results for tests written using `Quick` framework.
- `Swift Testing` integration to show test results for tests written using `Swift Testing` framework.
- Auto-detection of the target membership for new files.
- Picker with all available plugin actions.
- Highly customizable (many config options, auto commands, highlights,
and user commands).
Availability of features
| | Device (iOS <17) | Device (iOS 17+) | via Network (<17 / 17+) | Simulator | MacOS |
| :---------: | :--------------: | :--------------: | :---------------------: | :-------: | :---: |
| build | 🛠️ | ✅ | ❌ / ✅ | ✅ | ✅ |
| (un)install | 🛠️ | ✅ | 🛠️ / ✅ | ✅ | ❌ |
| launch | 🛠️ | ✅ | 🛠️ / ✅ | ✅ | ✅ |
| run tests | 🛠️ | ✅ | ❌ / ✅ | ✅ | ✅ |
| debug | 🛠️ | 🔐 🛠️ | ❌ | ✅ | ✅ |
| debug tests | ❌ | ❌ | ❌ | ✅ | ✅ |
| app logs | 🪲 | 🪲 | ❌ | ✅ | 🪲 |
🔐 - requires passwordless `sudo` permission to `tools/remote_debugger`
script (see |xcodebuild.remote-debugger|).
🛠️ - available if pymobiledevice3 is installed.
🪲 - available while debugging.
==============================================================================
Requirements *xcodebuild.requirements*
*xcodebuild.tools*
*xcodebuild.dependencies*
Neovim environment
- `Neovim 0.9.5+`
- `telescope.nvim`, `fzf-lua`, or `snacks.nvim` to present pickers.
- `nui.nvim` to present floating code coverage report.
- `snacks.nvim` to show previews for SwiftUI, UIKit, and AppKit views.
- `nvim-tree`, `neo-tree.nvim`, or `oil.nvim` to visually manage your project files.
- `nvim-dap` and `nvim-dap-ui` to debug apps.
- `nvim-treesitter` + Swift parser to show test results for tests written using `Quick` framework.
External tools
- `xcbeautify` to format Xcode logs (you can set a different tool or disable formatting in the config).
- `XcodeProjectCLI` to manage project files within Neovim.
- `pymobiledevice3` to debug on physical devices and/or run apps on devices below iOS 17.
- `jq` to get some information from `pymobiledevice3`.
- `xcode-build-server` to make LSP work properly with xcodeproj/xcworkspace.
- `ripgrep` to find matching test files while using Swift Testing framework.
- `Xcode` to build, run, and test apps. Make sure that `xcodebuild` and `xcrun simctl` work correctly. Tested with Xcode 15.
Installation
>bash
brew install xcp xcode-build-server xcbeautify pipx rg jq coreutils
pipx install pymobiledevice3
<
To quickly install all required tools you can run:
>bash
cd ~/.local/share/nvim/lazy/xcodebuild.nvim
make install
<
To debug on physical devices with iOS 17+ you will need to set up `sudo`,
see |xcodebuild.ios17| to learn more.
==============================================================================
Highlights *xcodebuild.highlights*
You can customize the highlights by setting `config.highlights` (see |xcodebuild.config|).
Below you can find all highlight groups used by the plugin.
Test File
| Highlight Group | Description |
| --------------------------------- | ------------------------------ |
| `XcodebuildTestSuccessSign` | Test passed sign |
| `XcodebuildTestFailureSign` | Test failed sign |
| `XcodebuildTestSuccessDurationSign` | Test duration of a passed test |
| `XcodebuildTestFailureDurationSign` | Test duration of a failed test |
Test Explorer
| Highlight Group | Description |
| ------------------------------------------ | --------------------------- |
| `XcodebuildTestExplorerTest` | Test name (function) |
| `XcodebuildTestExplorerClass` | Test class |
| `XcodebuildTestExplorerTarget` | Test target |
| `XcodebuildTestExplorerTestInProgress` | Test in progress sign |
| `XcodebuildTestExplorerTestPassed` | Test passed sign |
| `XcodebuildTestExplorerTestFailed` | Test failed sign |
| `XcodebuildTestExplorerTestDisabled` | Test disabled sign |
| `XcodebuildTestExplorerTestNotExecuted` | Test not executed sign |
| `XcodebuildTestExplorerTestPartialExecution` | Not all tests executed sign |
Code Coverage (inline)
| Highlight Group | Description |
| ------------------------------------- | ------------------------------------ |
| `XcodebuildCoverageFullSign` | Covered line - sign |
| `XcodebuildCoverageFullNumber` | Covered line - line number |
| `XcodebuildCoverageFullLine` | Covered line - code |
| `XcodebuildCoveragePartialSign` | Partially covered line - sign |
| `XcodebuildCoveragePartialNumber` | Partially covered line - line number |
| `XcodebuildCoveragePartialLine` | Partially covered line - code |
| `XcodebuildCoverageNoneSign` | Not covered line - sign |
| `XcodebuildCoverageNoneNumber` | Not covered line - line number |
| `XcodebuildCoverageNoneLine` | Not covered line - code |
| `XcodebuildCoverageNotExecutableSign` | Not executable line - sign |
| `XcodebuildCoverageNotExecutableNumber` | Not executable line - line number |
| `XcodebuildCoverageNotExecutableLine` | Not executable line - code |
Code Coverage (report)
| Highlight Group | Description |
| ------------------------------- | -------------------------------------------------- |
| `XcodebuildCoverageReportOk` | Percentage color when above `warning_coverage_level` |
| `XcodebuildCoverageReportWarning` | Percentage color when below `warning_coverage_level` |
| `XcodebuildCoverageReportError` | Percentage color when below `error_coverage_level` |
==============================================================================
Key Bindings *xcodebuild.bindings*
*xcodebuild.keybindings*
*xcodebuild.keys*
*xcodebuild.keymaps*
Sample key bindings for the plugin.
>lua
vim.keymap.set("n", "<leader>X", "<cmd>XcodebuildPicker<cr>", { desc = "Show Xcodebuild Actions" })
vim.keymap.set("n", "<leader>xf", "<cmd>XcodebuildProjectManager<cr>", { desc = "Show Project Manager Actions" })
vim.keymap.set("n", "<leader>xb", "<cmd>XcodebuildBuild<cr>", { desc = "Build Project" })
vim.keymap.set("n", "<leader>xB", "<cmd>XcodebuildBuildForTesting<cr>", { desc = "Build For Testing" })
vim.keymap.set("n", "<leader>xr", "<cmd>XcodebuildBuildRun<cr>", { desc = "Build & Run Project" })
vim.keymap.set("n", "<leader>xt", "<cmd>XcodebuildTest<cr>", { desc = "Run Tests" })
vim.keymap.set("v", "<leader>xt", "<cmd>XcodebuildTestSelected<cr>", { desc = "Run Selected Tests" })
vim.keymap.set("n", "<leader>xT", "<cmd>XcodebuildTestClass<cr>", { desc = "Run Current Test Class" })
vim.keymap.set("n", "<leader>x.", "<cmd>XcodebuildTestRepeat<cr>", { desc = "Repeat Last Test Run" })
vim.keymap.set("n", "<leader>xl", "<cmd>XcodebuildToggleLogs<cr>", { desc = "Toggle Xcodebuild Logs" })
vim.keymap.set("n", "<leader>xc", "<cmd>XcodebuildToggleCodeCoverage<cr>", { desc = "Toggle Code Coverage" })
vim.keymap.set("n", "<leader>xC", "<cmd>XcodebuildShowCodeCoverageReport<cr>", { desc = "Show Code Coverage Report" })
vim.keymap.set("n", "<leader>xe", "<cmd>XcodebuildTestExplorerToggle<cr>", { desc = "Toggle Test Explorer" })
vim.keymap.set("n", "<leader>xs", "<cmd>XcodebuildFailingSnapshots<cr>", { desc = "Show Failing Snapshots" })
vim.keymap.set("n", "<leader>xp", "<cmd>XcodebuildPreviewGenerateAndShow<cr>", { desc = "Generate Preview" })
vim.keymap.set("n", "<leader>x<cr>", "<cmd>XcodebuildPreviewToggle<cr>", { desc = "Toggle Preview" })
vim.keymap.set("n", "<leader>xd", "<cmd>XcodebuildSelectDevice<cr>", { desc = "Select Device" })
vim.keymap.set("n", "<leader>xq", "<cmd>Telescope quickfix<cr>", { desc = "Show QuickFix List" })
vim.keymap.set("n", "<leader>xx", "<cmd>XcodebuildQuickfixLine<cr>", { desc = "Quickfix Line" })
vim.keymap.set("n", "<leader>xa", "<cmd>XcodebuildCodeActions<cr>", { desc = "Show Code Actions" })
<
Test Explorer
- Press `o` to jump to the test implementation
- Press `t` to run selected tests
- Press `T` to re-run recently selected tests
- Press `R` to reload test list
- Press `[` to jump to the previous failed test
- Press `]` to jump to the next failed test
- Press `<cr>` to expand or collapse the current node
- Press `<tab>` to expand or collapse all classes
- Press `q` to close the Test Explorer
Logs Panel
- Press `o` on a failed test in the summary section to jump to the failing location
- Press `q` to close the panel
Code Coverage Report
- `enter` or `tab` - expand or collapse the current node
- `o` - open source file
==============================================================================
User Commands *xcodebuild.commands*
*xcodebuild.user-commands*
General
| Command | Description |
| -------------------------- | -------------------------------------------------------- |
| `XcodebuildSetup` | Run configuration wizard to select project configuration |
| `XcodebuildPicker` | Show picker with all available actions |
| `XcodebuildBuild` | Build project |
| `XcodebuildCleanBuild` | Build project (clean build) |
| `XcodebuildBuildRun` | Build & run app |
| `XcodebuildBuildForTesting` | Build for testing |
| `XcodebuildRun` | Run app without building |
| `XcodebuildCancel` | Cancel currently running action |
| `XcodebuildCleanDerivedData` | Deletes project's DerivedData |
| `XcodebuildToggleLogs` | Toggle logs panel |
| `XcodebuildOpenLogs` | Open logs panel |
| `XcodebuildCloseLogs` | Close logs panel |
| `XcodebuildOpenInXcode` | Open project in Xcode |
| `XcodebuildQuickfixLine` | Try fixing issues in the current line |
| `XcodebuildCodeActions` | Show code actions for the current line |
Project Manager
| Command | Description |
| ---------------------------------- | ---------------------------------------------------------- |
| `XcodebuildProjectManager` | Show picker with all Project Manager actions |
| `XcodebuildAssetsManager` | Show picker with all Assets Manager actions |
| `XcodebuildCreateNewFile` | Create a new file and add it to target(s) |
| `XcodebuildAddCurrentFile` | Add the active file to target(s) |
| `XcodebuildRenameCurrentFile` | Rename the current file |
| `XcodebuildDeleteCurrentFile` | Delete the current file |
| `XcodebuildCreateNewGroup` | Create a new directory and add it to the project |
| `XcodebuildAddCurrentGroup` | Add the parent directory of the active file to the project |
| `XcodebuildRenameCurrentGroup` | Rename the current directory |
| `XcodebuildDeleteCurrentGroup` | Delete the current directory including all files inside |
| `XcodebuildUpdateCurrentFileTargets` | Update target membership of the active file |
| `XcodebuildShowCurrentFileTargets` | Show target membership of the active file |
👉 To add a file to multiple targets use multi-select feature (by default `tab`).
Previews
| Command | Description |
| ---------------------------------- | ------------------------------------------------------------- |
| `XcodebuildPreviewGenerate` | Generate preview (optional parameter: `hotReload`) |
| `XcodebuildPreviewGenerateAndShow` | Generate and show preview (optional parameter `hotReload`) |
| `XcodebuildPreviewShow` | Show preview |
| `XcodebuildPreviewHide` | Hide preview |
| `XcodebuildPreviewToggle` | Toggle preview |
Testing
| Command | Description |
| -------------------------- | ----------------------------------------- |
| `XcodebuildTest` | Run tests (whole test plan) |
| `XcodebuildTestTarget` | Run test target (where the cursor is) |
| `XcodebuildTestClass` | Run test class (where the cursor is) |
| `XcodebuildTestNearest` | Run test (where the cursor is) |
| `XcodebuildTestSelected` | Run selected tests (using visual mode) |
| `XcodebuildTestFailing` | Rerun previously failed tests |
| `XcodebuildTestRepeat` | Repeat the last test run |
| `XcodebuildFailingSnapshots` | Show a picker with failing snapshot tests |
Debugging
| Command | Description |
| -------------------------- | ----------------------------------------- |
| `XcodebuildAttachDebugger` | Attach debugger to the running process |
| `XcodebuildDetachDebugger` | Detach debugger without killing the process |
| `XcodebuildBuildDebug` | Build, install, and debug the app |
| `XcodebuildDebug` | Install and debug the app without building |
Code Coverage
| Command | Description |
| -------------------------------- | ------------------------------------------ |
| `XcodebuildToggleCodeCoverage` | Toggle code coverage marks on the side bar |
| `XcodebuildShowCodeCoverageReport` | Open HTML code coverage report |
| `XcodebuildJumpToNextCoverage` | Jump to next code coverage mark |
| `XcodebuildJumpToPrevCoverage` | Jump to previous code coverage mark |
Test Explorer
| Command | Description |
| -------------------------------------- | ------------------------------ |
| `XcodebuildTestExplorerShow` | Show Test Explorer |
| `XcodebuildTestExplorerHide` | Hide Test Explorer |
| `XcodebuildTestExplorerToggle` | Toggle Test Explorer |
| `XcodebuildTestExplorerClear` | Clears Test Explorer |
| `XcodebuildTestExplorerRunSelectedTests` | Run Selected Tests |
| `XcodebuildTestExplorerRerunTests` | Re-run recently selected tests |
Configuration
| Command | Description |
| -------------------------| ----------------------------------- |
| `XcodebuildSelectScheme` | Show scheme picker |
| `XcodebuildSelectDevice` | Show device picker |
| `XcodebuildNextDevice` | Selects next device |
| `XcodebuildPreviousDevice` | Selects previous device |
| `XcodebuildSelectTestPlan` | Show test plan picker |
| `XcodebuildShowConfig` | Print current project configuration |
| `XcodebuildEditEnvVars` | Edit environment variables |
| `XcodebuildEditRunArgs` | Edit run arguments |
| `XcodebuildBootSimulator` | Boot selected simulator |
| `XcodebuildInstallApp` | Install application |
| `XcodebuildUninstallApp` | Uninstall application |
Swift Macros
| Command | Description |
| -------------------------| ----------------------------------- |
| `XcodebuildApproveMacros` | Show picker to approve Swift macros |
==============================================================================
Global Variables *xcodebuild.global_variables*
*xcodebuild.global-variables*
*xcodebuild.variables*
*xcodebuild.lualine*
This plugin provides several global variables that you can use to
integrate with `lualine` or other plugins.
| Variable | Description |
| ---------------------------- | -------------------------------------------------- |
| `vim.g.xcodebuild_device_name` | Device name (ex. iPhone 15 Pro) |
| `vim.g.xcodebuild_os` | OS version (ex. 16.4) |
| `vim.g.xcodebuild_platform` | Device platform (ex. iPhone Simulator) |
| `vim.g.xcodebuild_scheme` | Selected project scheme (ex. MyApp) |
| `vim.g.xcodebuild_product` | Selected project product name (ex. MyApp) |
| `vim.g.xcodebuild_test_plan` | Selected Test Plan (ex. MyAppTests) |
| `vim.g.xcodebuild_last_status` | Last build/test status (ex. Build Succeeded [15s]) |
Sample `lualine` integration:
>lua
local function xcodebuild_device()
if vim.g.xcodebuild_platform == "macOS" then
return " macOS"
end
local deviceIcon = ""
if vim.g.xcodebuild_platform:match("watch") then
deviceIcon = ""
elseif vim.g.xcodebuild_platform:match("tv") then
deviceIcon = " "
elseif vim.g.xcodebuild_platform:match("vision") then
deviceIcon = " "
end
if vim.g.xcodebuild_os then
return deviceIcon .. " " .. vim.g.xcodebuild_device_name .. " (" .. vim.g.xcodebuild_os .. ")"
end
return deviceIcon .. " " .. vim.g.xcodebuild_device_name
end
------
lualine_x = {
{ "' ' .. vim.g.xcodebuild_last_status", color = { fg = "Gray" } },
{ "' ' .. vim.g.xcodebuild_test_plan", color = { fg = "#a6e3a1", bg = "#161622" } },
{ xcodebuild_device, color = { fg = "#f9e2af", bg = "#161622" } },
},
<
==============================================================================
Debugging On iOS 17+ Device *xcodebuild.integrations.ios17*
*xcodebuild.ios17*
*xcodebuild.remote-debugger*
Since iOS 17, a new secure connection between Mac and mobile devices is
required. Xcodebuild.nvim uses `pymobiledevice3` to establish a special
trusted tunnel that is later used for debugging. However, this operation
requires `sudo`.
Showing a pop-up to enter a password every time you run a debugger would
be quite annoying. That's why the plugin provides a small script
`tools/remote_debugger` that wraps the only two operations requiring
`sudo` (starting a secure tunnel and closing it).
This allows you to configure passwordless access just for this single
file and make it work with xcodebuild.nvim.
⚠️ CAUTION
Giving passwordless `sudo` access to that file, potentially opens a gate for
malicious software that could modify the file and run some evil code using
`root` account. The best way to protect that file is to create a local copy,
change the owner to `root`, and give write permission only to `root`.
The same must be applied to the parent directory. The script below
automatically secures the file.
👉 Enable integration
Update your config with:
>lua
integrations = {
pymobiledevice = {
enabled = true,
},
}
<
👉 Run the following command to install & protect the script
>bash
DEST="$HOME/Library/xcodebuild.nvim" && \
SOURCE="$HOME/.local/share/nvim/lazy/xcodebuild.nvim/tools/remote_debugger" && \
ME="$(whoami)" && \
sudo install -d -m 755 -o root "$DEST" && \
sudo install -m 755 -o root "$SOURCE" "$DEST" && \
sudo bash -c "echo \"$ME ALL = (ALL) NOPASSWD: $DEST/remote_debugger\" >> /etc/sudoers"
<
See also: https://github.com/doronz88/pymobiledevice3/blob/master/misc/RemoteXPC.md#trusted-tunnel
*xcodebuild.remote-debugger-migration*
Previous version of xcodebuild.nvim asked you to give sudo permission to:
`$HOME/.local/share/nvim/lazy/xcodebuild.nvim/tools/remote_debugger`
Unfortunately, it's not the best solution, because someone could modify
that file and run some evil code using `root` account.
Therefore, to improve security, please run `sudo visudo -f /etc/sudoers` and
remove previously added line with `remote_debugger` path.
After that, run the script that is presented above to securely install
`pymobiledevice3` integration. See: |xcodebuild.remote-debugger|.
The script installed in a new way will be protected and the modification
of the file will be allowed only for the `root` user.
Please also note that remote debugger config options have been moved to:
`integrations.pymobiledevice`.
*xcodebuild.remote-debugger-update*
To update the `remote_debugger` script, you can run:
>bash
DEST="$HOME/Library/xcodebuild.nvim" && \
SOURCE="$HOME/.local/share/nvim/lazy/xcodebuild.nvim/tools/remote_debugger" && \
sudo install -m 755 -o root "$SOURCE" "$DEST"
<
==============================================================================
Health Check *xcodebuild.health*
This module checks if everything is installed and configured correctly.
M.check() *xcodebuild.health.check*
==============================================================================
Actions *xcodebuild.actions*
*xcodebuild.api*
This module is responsible for handling actions that the user can
call programmatically. It is the main entry point to the plugin's API.
The interface should stay relatively stable.
M.open_in_xcode() *xcodebuild.actions.open_in_xcode*
Opens the project in Xcode.
M.open_logs() *xcodebuild.actions.open_logs*
Opens the logs panel.
M.close_logs() *xcodebuild.actions.close_logs*
Closes the logs panel.
M.toggle_logs() *xcodebuild.actions.toggle_logs*
Toggles the logs panel.
M.show_picker() *xcodebuild.actions.show_picker*
Shows the pickers with all available actions.
M.cancel() *xcodebuild.actions.cancel*
Cancels all running actions.
M.configure_project() *xcodebuild.actions.configure_project*
Shows configuration wizard.
M.build({callback}) *xcodebuild.actions.build*
Builds the project.
Parameters: ~
{callback} (fun(report:ParsedReport)|nil)
M.clean_build({callback}) *xcodebuild.actions.clean_build*
Starts clean build.
Parameters: ~
{callback} (fun(report:ParsedReport)|nil)
M.build_for_testing({callback}) *xcodebuild.actions.build_for_testing*
Builds the project for testing.
Parameters: ~
{callback} (fun(report:ParsedReport)|nil)
M.build_and_run({callback}) *xcodebuild.actions.build_and_run*
Builds and runs the project.
Parameters: ~
{callback} (fun(report:ParsedReport)|nil)
M.clean_derived_data() *xcodebuild.actions.clean_derived_data*
Cleans the derived data.
M.edit_env_vars() *xcodebuild.actions.edit_env_vars*
Opens `env.txt` file in a new tab.
M.edit_run_args() *xcodebuild.actions.edit_run_args*
Opens `run_args.txt` file in a new tab.
M.run({callback}) *xcodebuild.actions.run*
Launches the app.
Parameters: ~
{callback} (function|nil)
M.run_tests() *xcodebuild.actions.run_tests*
Starts tests.
M.run_target_tests() *xcodebuild.actions.run_target_tests*
Starts tests of the current target.
M.run_class_tests() *xcodebuild.actions.run_class_tests*
Starts tests from the class under the cursor.
M.run_nearest_test() *xcodebuild.actions.run_nearest_test*
Starts the nearest test to the cursor.
It searches for the test declaration going up.
M.run_selected_tests() *xcodebuild.actions.run_selected_tests*
Starts selected tests.
M.rerun_failed_tests() *xcodebuild.actions.rerun_failed_tests*
Starts tests that failed previously.
M.repeat_last_test_run() *xcodebuild.actions.repeat_last_test_run*
Repeats the last test run.
*xcodebuild.actions.show_failing_snapshot_tests*
M.show_failing_snapshot_tests()
Shows a pickers with failing snapshot tests.
M.select_project({callback}) *xcodebuild.actions.select_project*
Starts the pickers with project file selection.
Parameters: ~
{callback} (function|nil)
M.select_scheme({callback}) *xcodebuild.actions.select_scheme*
Starts the pickers with scheme selection.
Parameters: ~
{callback} (function|nil)
M.select_testplan({callback}) *xcodebuild.actions.select_testplan*
Starts the pickers with test plan selection.
Parameters: ~
{callback} (fun(testPlan:string)|nil)
M.select_device({callback}) *xcodebuild.actions.select_device*
Starts the pickers with device selection.
Parameters: ~
{callback} (function|nil)
M.show_current_config() *xcodebuild.actions.show_current_config*
Sends a notification with the current project settings.
M.install_app({callback}) *xcodebuild.actions.install_app*
Installs the app on the device.
Parameters: ~
{callback} (function|nil)
M.uninstall_app({callback}) *xcodebuild.actions.uninstall_app*
Uninstalls the app from the device.
Parameters: ~
{callback} (function|nil)
M.boot_simulator({callback}) *xcodebuild.actions.boot_simulator*
Boots the simulator.
Parameters: ~
{callback} (function|nil)
M.toggle_code_coverage({isVisible}) *xcodebuild.actions.toggle_code_coverage*
Toggles the code coverage.
Parameters: ~
{isVisible} (boolean)
*xcodebuild.actions.show_code_coverage_report*
M.show_code_coverage_report()
Shows the code coverage report.
M.jump_to_next_coverage() *xcodebuild.actions.jump_to_next_coverage*
Jumps to the next coverage marker.
*xcodebuild.actions.jump_to_previous_coverage*
M.jump_to_previous_coverage()
Jumps to the previous coverage marker.
*xcodebuild.actions.previews_generate*
M.previews_generate({hotReload}, {callback})
Generates the preview.
If {hotReload} is true, the app will be kept running.
Parameters: ~
{hotReload} (boolean|nil)
{callback} (function|nil)
*xcodebuild.actions.previews_generate_and_show*
M.previews_generate_and_show({hotReload}, {callback})
Generates and shows the preview.
If {hotReload} is true, the app will be kept running.
Parameters: ~
{hotReload} (boolean|nil)
{callback} (function|nil)
M.previews_show() *xcodebuild.actions.previews_show*
Shows the preview.
M.previews_hide() *xcodebuild.actions.previews_hide*
Hides the preview.
M.previews_toggle() *xcodebuild.actions.previews_toggle*
Toggle the preview.
M.test_explorer_clear() *xcodebuild.actions.test_explorer_clear*
Clears the test explorer.
M.test_explorer_show() *xcodebuild.actions.test_explorer_show*
Shows the test explorer.
M.test_explorer_hide() *xcodebuild.actions.test_explorer_hide*
Hides the test explorer.
M.test_explorer_toggle() *xcodebuild.actions.test_explorer_toggle*
Toggles the test explorer.
*xcodebuild.actions.test_explorer_run_selected_tests*
M.test_explorer_run_selected_tests()
Runs selected tests.
*xcodebuild.actions.test_explorer_rerun_tests*
M.test_explorer_rerun_tests()
Runs last executed tests or all if nothing was executed.
M.show_assets_manager() *xcodebuild.actions.show_assets_manager*
Show the Assets Manager.