Making Sense of Java CodeSense in XCode 1.5
The long-awaited Code Sense finally arrives in
XCode released in Aug 2004. Here are my notes on what I had to do to make it
work after I installed XCode 1.5 on top of XCode 1.2/OS X 10.2.4/WO
5.2.3
In summary follow these steps to
success:
* Check Java installation and make
sure CurrentJDK is linked to 1.4.2
* Install
XCode 1.5
* Install Java 1.4.2 Developer
Package
* Unjar Java
Docs
* Prepare Java Classes for Code
Sense
* Fix the WO documentation support as
per XCode 1.5 release notes
* Turn On
CodeSense
* Finally Use
CodeSense
Check Your Java 1.4.2
Installation# First, cd into the Java
Versions directory% cd
/System/Library/Frameworks/JavaVM.framework/Versions#
Then list contents% ls
-al# the output should look something
like this:total
16drwxr-xr-x 10 root wheel 340 24 Sep
2003 .drwxr-xr-x 10 root wheel 340 10 Aug
17:19 ..drwxr-xr-x 3 root wheel 102 10
Jan 2004 1.2drwxr-xr-x 3 root wheel 102
10 Jan 2004 1.3drwxr-xr-x 8 root wheel
272 24 Sep 2003 1.3.1drwxr-xr-x 4 root
wheel 136 6 Dec 2003 1.4.1drwxr-xr-x 8
root wheel 272 10 Jan 2004
1.4.2drwxr-xr-x 5 root wheel 170 10 Jan
2004 Alrwxr-xr-x 1 root wheel 1 10 Aug
17:19 Current -> Alrwxr-xr-x 1 root
wheel 5 10 Aug 16:18 CurrentJDK ->
1.4.2# If the CurrentJDK points to
1.4.2 (as shown here since I fixed it yesterday), then you are OK. If 1.4.1
exists (which it should not since 1.4.2 installer was supposed to replace it!)
and if CurrentJDK -> 1.4.1, then you need to fix the symbolic link using this
command%sudo ln -fhsv 1.4.2
CurrentJDKInstall XCode
1.5Download XCode 1.5 from
connect.apple.com, BACKUP your development Mac, and then install XCode 1.5. Do
not open it yet.Install Java
1.4.2 Developer PackageDownload Java
1.4.2 Developer from connect.apple.com and install
itUnjar Java
DocsRun this script form the command
line/Developer/Documentation/Java/scripts/unjarJavaDocumentation.shPrepare
Java Classes for Code SenseThe objective
is to put the XXX.pbxindex for the appropriate "pre-cooked" project index in
this folder~/Library/Application
Support/Apple/Developer Tools/Index
TemplatesThe WebObjects HTML App index
template is named JavaWebObjectsAppIndex.pbxindex and contains the files shown
here:
With
XCode, open the
file:/Developer/Extras/Xcode\ Index\
Templates/JavaWebObjectsAppIndexNext
select Window/Activity Viewer menu. You will see indexing
progress.Check that all the jar files
in the project are NOT red font. If red, it means Xcode cannot find them. In
that case, Get Info on the file and use Choose to find it and correct the
absolute path.Leave the
JavaWebObjectsAppIndex project open until Activity Viewer indicates that
indexing is complete. When complete
close it and copy the folder JavaWebObjectsAppIndex.pbxindex inside in
./build/JavaWebObjectsAppIndex.build/
to~/Library/Application
Support/Apple/Developer Tools/Index
TemplatesRepeat this process for any
other Index Templates that you want code sense functionality
for.Finally, ENABLE codesense by
setting this user-specific default from the command
line% defaults write
com.apple.Xcode PBXCodeSenseEnableIndexTemplates
YESFix the WO documentation
support as per XCode 1.5 release
notesOpen XCode and READ the RELEASE
NOTES, especially the WebObjects related notes at the
bottom!Follow the instructions for
fixing WebObjects Help Documentation as shown in the release notes and expanded
here:
1) Create a soft
link to the WebObjects documentation in the ADC Reference Library. To do so, run
the command:
% sudo ln -s
"/Developer/Documentation/WebObjects" "/Developer/ADC Reference Library"
2) Open
/Developer/ADC Reference
Library/documentation/Help/Developer Help
Viewer/MacOSXDeveloper.pbHelpIndexerList and
add this line to the XML:
/Developer/Documentation/WebObjects
# This can be done by opening the file with
pico
% cd /Developer/ADC\ Reference\
Library/documentation/Help/Developer\ Help\ Viewer/
% sudo pico
MacOSXDeveloper.pbHelpIndexerList
# Then add the value as a string member (highlighted
below) of the XML array so that the contents of the file look like
this:
3) Re-index the documentation. To do so, run the
command:
sudo /Developer/Tools/pbhelpindexer -o
"/Developer/ADC Reference Library/documentation/Help/Developer Help
Viewer/"
This may take a a couple of minutes!
4) Restart Xcode.
Turn On CodeSense
Open XCode Preferences
Click on Navigation pane and set up desired options,
for
example:
Finally
Use CodeSense1) Start typing a
variable
name
2)
Entering a period shows all
fields/methods
3)
Typing letters filters the list (use up/down arrows and/or tab to
choose)
Troubleshooting:So
you find that CodeSense is not finding your newly created methods? ... usually
caused by syntax mistakes and an index that is not up to date. Just save your
files and Build, fixing any errors and reBuilding until you have no more java
errors. Code Sense should now find all methods.</HTMLCode>
Posted: Tuesday - August 10, 2004 at 04:39 PM