The macro \DeclareUnicodeCharacter is defined in the package inputenc when loaded with the utf8 encoding. So normally you need the following line before you use \DeclareUnicodeCharacter:
\usepackage[utf8]{inputenc}
In this case though, the sp.cls already contains the line \RequirePackage[utf8]{inputenc} on line 103, before it uses \DeclareUnicodeCharacter on line 107, so you should be able to compile sp-template.tex with pdflatex even without explicitly adding the line.
However, if you compile with the xelatex or lualatex engines (which are Unicode-based and default to utf8), then the inputenc package gets ignored, and (only) a warning is printed in the error log:
% xelatex sp-template.tex
This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./sp-template.tex
LaTeX2e <2017-04-15>
Babel <3.10> and hyphenation patterns for 84 language(s) loaded.
(./sp.cls
Document Class: sp 2015/01/04 v.3.0 Class for Semantics & Pragmatics
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/size12.clo)) (/usr/local/texlive/2017/texmf-dist/tex/latex/stmaryrd/stmaryrd.sty) (/usr/local/texlive/2017/texmf-dist/tex/latex/base/textcomp.sty (/usr/local/texlive/2017/texmf-dist/tex/latex/base/ts1enc.def)) (/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/local/texlive/2017/texmf-dist/tex/latex/base/fontenc.sty (/usr/local/texlive/2017/texmf-dist/tex/latex/base/t1enc.def) (/usr/local/texlive/2017/texmf-dist/tex/latex/lm/t1lmr.fd)) (/usr/local/texlive/2017/texmf-dist/tex/latex/psnfss/mathptmx.sty) (/usr/local/texlive/2017/texmf-dist/tex/latex/base/inputenc.sty
Package inputenc Warning: inputenc package ignored with utf8 based engines.
)
! Undefined control sequence.
<recently read> \DeclareUnicodeCharacter
l.107 \DeclareUnicodeCharacter
{2011}{\mbox{-}\nobreak\hskip0pt}
?
(Note the line that starts with "Package inputenc warning". IMO it makes sense for this to be an error instead, but probably the authors of inputenc chose to make it a warning because many files written with inputenc have a chance of working on Unicode-based engines if inputenc simply does nothing.)
So you need to either
- compile your file with the pdfTeX engine, or
if you wish to compile with XeTeX/LuaTeX, hack sp.cls to remove the following line:
\DeclareUnicodeCharacter{2011}{\mbox{-}\nobreak\hskip0pt}
(note it was added to deal with a hyphenation problem which you are unlikely to have with a Unicode-based engine as presumably no one would define hyphenation after U+2011) and also these lines that use \ifpdf to mean “non-PostScript output” but unfortunately excludes XeTeX but not LuaTeX (they're ok to remove because breakurl is not needed):
% If the author is using postscript (discouraged), then load the
% breakurl package, else don't load it.
\RequirePackage{ifpdf}
\ifpdf
\else
\RequirePackage{breakurl}
\fi
(Note that if you're sending the source .tex file to someone else, such as the journal, then you shouldn't choose the latter option: and in general if you're submitting papers to journals you shouldn't mess with their style files. But if you're not going to send the file to anyone and are simply typesetting it in the journal's style for your own amusement, you can do whatever you like.)
\DeclareUnicodeCharactercomes frominputenc(withutf8), but yoursp.clsalready contains\RequirePackage[utf8]{inputenc}. And if I download yoursp-template.texandsp.cls, I am able to compilesp-template.texwith no errors. Please include the complete compilation log (from either your local installation or Overleaf (or link to the file at the latter)); that may help. – ShreevatsaR Jul 07 '17 at 15:08sp.clsindeed has\DeclareUnicodeCharacter{2011}{\mbox{-}\nobreak\hskip0pt}, but the immediate (non-comment) line before that is line 103 with\RequirePackage[utf8]{inputenc}. Either that line gave an error, or loaded the wrong file somehow. Whichever it is, if you include your full compilation log (and not just those lines), then it will become clear. – ShreevatsaR Jul 07 '17 at 15:16XeTeXengine used by default caused the bug? – xji Jul 07 '17 at 15:19/usr/local/texlive/2016/texmf-dist/tex/latex/breakurl/breakurl.sty:311: Undefined control sequencein the log. – xji Jul 07 '17 at 15:22