Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Xcode as an IDE for Perl scripts?

Tags:

xcode

perl

I am using OS X 10.9 (Mavericks) and need to work on a Perl project. I enjoy using TextMate, Atom, and BBEdit, but would like to try using Xcode instead, as it has good integration with git, a clean look, and I am already intimately familiar with the UI and syntax highlighting colour scheme.

Is it possible to use Xcode as an IDE to develop and run Perl scripts, in a way that puts it on par, or ahead of, existing text editors?


Update

I used Xcode 5 as an IDE for Perl for more than a month, and found it an excellent alternative to regular text editors like Atom and TextMate. However, like pure text editors, Xcode lacks support for debugging in Perl. I have since discovered Komodo IDE, a really nice IDE for Perl (and similar languages) that supports graphical Perl debugging, plus remote Perl debugging. I have since switched from using Xcode for Perl development to using Komodo IDE.

like image 270
Steve HHH Avatar asked Jun 07 '14 00:06

Steve HHH


1 Answers

After some experimentation, it seems that Xcode makes for a fairly decent environment for developing Perl. Here is a screenshot of Xcode showing some Perl, project navigator, Git integration, and command-line output from a Perl script, as run by Xcode.

enter image description here

Xcode 5's built-in syntax highlighting works fine with Perl (.pl and .pm) files, right out of the box. But to use Xcode to write Perl more efficiently, you'll want to set up a new Xcode project:

  1. Create a new Xcode workspace (File > New > Workspace) and select the folder you want to use for the Perl project.

  2. Enable the Xcode navigator, so you can see the files in your project (View > Navigators > Show Navigators). Notice that Xcode does not show you a list of files in the workspace folder by default. If you're reading this, you're probably already an Xcode user, already knew that.

  3. Manually add any files, or folders (groups, in Xcode parlance), that you want to see in the project (right-click on the Project Navigator pane and select Add files to "Project Name). Create groups to mirror your folder structure and add any files in subfolders to the groups. This can be a bit of work, depending on the size of your Perl project, but once you're set up it should not change much.

  4. Click on your files in the Project Navigator to view the code. If you are using a Git or Subversion, Xcode will generate diffs as normal in the Xcode version editor.

  5. To get your Perl script running when you hit Cmd-R:

    • Create a new scheme (Product > Scheme > New Scheme), configure Target to None and assign a name like Run Perl.

    • After creating the scheme, hit Edit Scheme.

    • In the Run perl scheme, set the Executable to /usr/bin/perl (select Other then press Shift-Cmd-G, enter /usr/bin/perl, and press Choose).

    • Go to the Arguments tab and ensure that your main script is the first argument. Add more arguments and environment variables as necessary.

    • Go to the Options tab and set Use custom working directory to your project folder. Deselect XPC services and any other options related to iOS or OS X development.

Press OK and when you press Cmd-R in Xcode, Xcode will call Perl, run your script, and show you the output.

To get Perl snippets and templates in Xcode, see How to create project templates in Xcode 4.

Extra tips:

  • If you are working with files that have extensions for an language that Xcode does not recognise, such as .sql files, you may be able to use the generic syntax highlighting. Go to Editor > Syntax Highlighting > Generic.
like image 113
Steve HHH Avatar answered Sep 23 '22 10:09

Steve HHH