While Visual Studio Code is the best IDE for sure but it is really difficult and tiring to try without guide. Here is how to setup Visual Studio Code on Mac for debugging Arduino, WordPress etc common things for the iTerm2 + ZSH + Homebrew Users. Those who have not setup their Mac with iTerm2, ZSH, Homebrew should read our old guide to setup. Then realize the matters of .profile file – we use ~/.zshrc
as profile file. Other matter is understanding UNIX Wheel group. Obviously, as first step you need to download Visual Studio Code on Mac via GUI from official website :
1 | https://code.visualstudio.com/download |
Following our guide, Mac users will not face any error. Peoples forget what installed which things and get odd errors with PHPCS. Your everything’s path should be on ~/.zshrc
. Otherwise any debugger will fail. I am writing like poet. If you find any error in the poetry please inform me via Twitter.
Setup Visual Studio Code on Mac For Debugging
Skip steps which First upgrade Xcode and restart the system. After that is complete, open iTerm2 and run :
---
1 | sudo xcodebuild -license accept |
Then run :
1 | brew update |
and kindly fix all possible problems (it is not uncommon to see errors in long term). Then run :
1 | brew tap homebrew/dupes |
You’ll receive a friendly message :
1 | Warning: homebrew/dupes was deprecated. This tap is now empty as all its formulae were migrated. |
We will configure PHP first. Run :
1 | brew tap homebrew/php |
Install PHP 7.0 :
1 | brew install php70 |
You’ll receive lot of instructions around what to add on ~/.zshrc
, like this :
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 | This formula is keg-only, which means it was not symlinked into /usr/local, because macOS provides libicucore.dylib (but nothing else). If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc For compilers to find this software you may need to set: LDFLAGS: -L/usr/local/opt/icu4c/lib CPPFLAGS: -I/usr/local/opt/icu4c/include For pkg-config to find this software you may need to set: PKG_CONFIG_PATH: /usr/local/opt/icu4c/lib/pkgconfig If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.zshrc For compilers to find this software you may need to set: LDFLAGS: -L/usr/local/opt/libxml2/lib CPPFLAGS: -I/usr/local/opt/libxml2/include For pkg-config to find this software you may need to set: PKG_CONFIG_PATH: /usr/local/opt/libxml2/lib/pkgconfig If you need Python to find bindings for this keg-only formula, run: echo /usr/local/opt/libxml2/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/libxml2.pth If you are having issues with custom extension compiling, ensure that you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH: PATH="/usr/local/bin:$PATH" If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file: export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH" OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH: PATH="/usr/local/sbin:$PATH" To have launchd start homebrew/php/php70 now and restart at login: brew services start homebrew/php/php70 |
As they will be delivered one by one, copy paste them as plain text file somewhere else. Open .zshrc
:
1 | nano .zshrc |
Add :
1 2 3 4 5 6 | export PATH="/usr/local/opt/icu4c/bin:$PATH" export PATH="/usr/local/opt/icu4c/sbin:$PATH" export PATH="/usr/local/opt/libxml2/bin:$PATH" export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH" PATH="/usr/local/bin:$PATH" PATH="/usr/local/sbin:$PATH" |
Reload after addition :
1 | source .zshrc |
Now install Mcrypt :
1 | brew install mcrypt php70-mcrypt |
Now install Composer :
1 | brew install composer |
If you run :
1 | which composer |
You’ll get a valid path. Now Run this command :
1 | composer global require "squizlabs/php_codesniffer=*" |
You’ll receive response like this :
1 2 3 4 5 6 7 8 | Changed current directory to /Users/your-user-name-on-mac/.composer ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Installing squizlabs/php_codesniffer (3.1.0): Downloading (100%) Writing lock file Generating autoload files |
Run :
1 | composer global show |
Basically we installed PHPCS :
1 | https://github.com/ikappas/vscode-phpcs |
Add this to ~/.zshrc
:
1 | export PATH="$PATH:~/.composer/vendor/bin" |
Reload after addition :
1 | source .zshrc |
Run :
1 | phpcs -i |
For the sake of Python stuffs install pylint :
1 | sudo pip install pylint |
Now launch Visual Studio Code. On the left hand side there are 5 icons :
File icon = Explorer
Magnifying glass icon = Search
Git tree icon = Source control
No Bug icon = Debugging
Square icon = Extensions
Click that Extension’s square icon and install these extensions :
Arduino
C/C++
C#
Composer
Docker
Hg
jQuery Code Snippets
MagicPython
PHP Debug
phpcs 0.7.0 by Ioannis Kappas (Do not install some other than Ioannis Kappas’s thing)
Project Manager
Python
Python for VSCode
Wordpress Development by Hridoy
WordPress Snippet
Restart VSCode. You should not receive any error. This ends first part of the guide. Second part is about what to do with WordPress. For Arduino you should have Arduino IDE installed as advice for the third part.
Tagged With debug arduino vscode , For compilers to find this software you may need to set: LDFLAGS: -L/usr/local/opt/libxml2/lib CPPFLAGS: -I/usr/local/opt/libxml2/include , please update your include path visual code arduino , visual studio code arduino setup , wordpress arduino