appledoc- runscript- Expected end of line but found identifier

238 Views Asked by At

I'm trying to run this script as part of generating documentation using appledoc plug in. But, I'm receiving this 'Expected end of line but found identifier.' error when I run this script in Xcode(or terminal). Please help me out as I'm new to scripting and i'm unable to identify the exact error in the code!

#!/bin/bash
tmpdir="tmpdocs"
finaldir="docs"

rm -rf $tmpdir
mkdir $tmpdir # we killed this last time, create it to avoid warnings from appledoc

cd ./AppledocTemplates/
git checkout master
git pull origin master
expectedversion=$(./templateversion.sh) # Check repo version
cd ..

##########################################
# Install templates if not current
##########################################
if [ ! -f ~/.appledoc/templateversion.sh ]  #If this file doesn't exist, then need to install templates
then
  cd ./AppledocTemplates/
  ./installtemplates.sh 
  if [ $? -ne 0 ] # Descriptive error message is sent in installtemplates. Just exit with error
  then
    exit 1
  fi
  cd ..
fi

version=$(~/.appledoc/templateversion.sh) # Check installed version

if [ $version -ne $expectedversion ]
then
  echo "Updating templates"
  cd ./AppledocTemplates/
  ./installtemplates.sh #wrong version - try installing
  version=$(~/.appledoc/templateversion.sh)
  if [ $? -ne 0 ] # Descriptive error message is sent in installtemplates. Just exit with error
  then
    cd ..
    exit 1
  fi

  if [ $version -ne $expectedversion ] # Now is the version correct? If not, exit with error
  then
    cd ..
    echo "You do not have the correct version of the appledoc templates"
    echo "Make sure you run installtemplates.sh to put them in their correct location."
    exit 1
  fi
  cd ..
fi

##########################################
# Compile the docs
##########################################

appledoc ./AppledocSettings.plist MySDK # Compile the docs
if [ $? -ne 0 ]
then
  echo "Compile failure of source documents. MySDK doc creation not completed."
  exit 1
fi

##########################################
# Stage docs in proper places and cleanup
##########################################

#Move the docs to final directory
rm -rf $finaldir # clean out whatever was in the final dir
mkdir $finaldir # and recreate it

#Copy the docset file to the docs directory so that it can be loaded into github
cp -a ~/Library/Developer/Shared/Documentation/DocSets/us.MySDK.MySDK-Total-SDK.docset ./$finaldir
if [ $? -ne 0 ]
then
  echo "Unable to copy docset to ./docs" 
  exit 1
fi

# stage the html directories to their final destination
mv -f ./$tmpdir/html/* $finaldir
if [ $? -ne 0 ]
then
  echo "Unable to move html files to ./docs" 
  exit 1
fi

rm -rf $tmpdir #clear out the tmp dir

echo "MySDK doc creation successful."
exit 0

This is the log screen shot if I run the script from the terminal. This is the log screen shot if I run the script from Xcode.

The first one is the log screen shot if I run the script from the terminal. Second is the log screen shot if I run the script from Xcode.

0

There are 0 best solutions below