Consider the input

\documentclass{article}
\usepackage{fontspec}
\usepackage[french,main=american]{babel}
% \usepackage{fontspec}%%% Doesn't matter where you use fontspec
\begin{document}
Nothing.
\end{document}


No matter which of the two lines including the fontspec package is enabled, the warning

Package frenchb.ldf Warning: Add \usepackage{fontspec} to the
(frenchb.ldf)                preamble of your document, on input line 5.


is printed to the log when compiling with xelatex or lualatex.

The output file seems to be ok. Is the warning bogus?

Versions:

• XeTeX 3.14159265-2.6-0.99996 (TeX Live 2016)
• LuaTeX Version 0.95.0 (TeX Live 2016)
• LaTeX2e <2017/01/01> patch level 1
• Babel 2016/04/23 3.9r
• Fontspec 2017/01/24 v2.5d
• Make a bug report to the french.ldf maintainer. He should adapt the code to the newest fontspec version (which no longer loads xunicode). – Ulrike Fischer Jan 31 '17 at 14:07

This is a consequence of the recent changes in fontspec that stopped loading xunicode by default. The relevant code in frenchb.ldf is

\ifFBunicode
\ifdefined\DeclareUTFcharacter
\else
{\PackageWarning{frenchb.ldf}%
}%
\fi
\else
[...irrelevant part...]
\fi


The \ifBunicode conditional is true when the engine used is either XeTeX or LuaTeX; in this case nothing is done if \DeclareUTFcharacter is defined, assuming this means fontspec has been loaded. This is the wrong test to do, because it just checks whether xunicode is loaded, not fontspec. Since this package doesn't load it any longer, the test returns false, so the warning is issued, because you aren't loading luainputenc, of course.

You can use the silence package to get rid of this spurious warning until babel-french is updated to look for, say, \setmainfont.

## Update

With babel-french version 3.2g, released 2017/01/30, the problem should be fixed. In the notes of the .dtx file we see

\changes{v3.2g}{2017/01/24}{fontspec defines TU encoding now and
no longer loads xunicode.sty. Test changed.}


that shows the maintainers were already aware of the issue. Now the test is

\ifFBunicode

so the loading of fontspec is checked specifically.
However, this doesn't allow (as it was before) to load fontspec after babel.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7703055739402771, "perplexity": 9077.844055482246}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-22/segments/1558232258621.77/warc/CC-MAIN-20190526025014-20190526051014-00136.warc.gz"}