• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do I create a simple script for XCode?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I create a simple script for XCode?


  • Subject: Re: How do I create a simple script for XCode?
  • From: Kevin Grant <email@hidden>
  • Date: Mon, 9 Feb 2004 22:01:29 -0600

. . . . . I'm looking at the possibility of converting from Quickdraw to Quartz. So I want to find the places in my program where I use Quickdraw commands. So I'm trying to make up a script that will find: MoveTo, LineTo, SetPort, GetPort.... in my code. As I change the code I can then run the script again to see how I'm doing. . . . .

Which is the right scripting language, AppleScript or UNIX scripts, for just doing something simple like a handful of finds?

I've found Unix more powerful, but that's because so many of its tools are geared for text manipulation (that's never been my impression with AppleScript as much). Also, in case this applies, you should convert all the line endings of your text files from Mac to Unix if you expect Unix command line tools to read the text lines correctly.



If I use Xcode to build an AppleScript what is suppose to be created (executable?) and what do I do with it to make it modify Xcode menus?

Personally I would use the Script Editor (in /Applications/AppleScript), but the result is either a text file that needs compiling, or a compiled script. To modify Xcode menus, place them into the "[home]/Library/Application Support/Apple/Developer Tools/Scripts" folder, which defines the scripts menu.



Does anyone know the right commands for doing:
Find MoveTo
Find LineTo
...

I just want it to do a regular search thru all files in the project (command-shift-F)

I appreciate all suggestions.

The Unix "grep" command does basic content searches, and "egrep" is a more powerful version (also installed on Mac OS X) that can do just about anything. Perl (also installed) is a really powerful language particularly nice for text parsing.


In my experience, the more structured your code is, the easier it is to script searches. If you're lucky, your source code follows style conventions, etc. that makes it very easy to find patterns. Otherwise, it may be tricky to write anything automated.

For example, if your function calling convention is consistent you can probably find all API invocations simply by adding a left parenthesis to your search pattern:

	(from a Unix shell)
	% grep "MoveTo(" *.c

The above would search all C source files in the current directory for apparent calls to MoveTo.

You could make it more complex in a shell script, perhaps to search many APIs - e.g.

	(in an executable text file)
	#!/bin/sh
	for API in MoveTo LineTo Move Line SetPort GetPort ; do
		grep "${API}(" *.c
	done


In all cases the Unix command would dump its results to standard output - the terminal - but this is easily redirected/reformatted using other commands.


Hope this helps,
Kevin G.
http://homepage.mac.com/kmg/
mail to kevin at ieee dot org
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Frameworks/multiply-defined symbols
      • From: Chris Silverberg <email@hidden>
References: 
 >How do I create a simple script for XCode? (From: Mike Lazear <email@hidden>)

  • Prev by Date: How do I create a simple script for XCode?
  • Next by Date: Where to put static libraries?
  • Previous by thread: How do I create a simple script for XCode?
  • Next by thread: Frameworks/multiply-defined symbols
  • Index(es):
    • Date
    • Thread