"The one thing they say, and we do know, anyone who runs against Trump suffers".
Trump and McCain are engaged in a long-running feud that dates to Trump's 2016 presidential run.
The measure authorizes $7.6 billion for 77 new F-35 "stealth" Joint Strike Fighter jets built by Lockheed Martin, and $24.1 billion to fund the construction of 13 new battle force ships. The president signed the bill at Fort Drum Army Base in NY.
Mr. Trump also got what he wanted in the measure with controls on US government contracts with China's ZTE Corp. and Huawei Technologies because of national-security concerns; the restrictions are nevertheless weaker than earlier versions of the bill.
The compromise bill removes a provision reinstating penalties against ZTE and restricting the company's ability to buy USA component parts.
The president said the defense policy measure signals that the U.S.is "on the move once again and we are not backing down". It allows Trump to waive sanctions against countries that bought Russian weapons and now want to buy US military equipment.
The measure also addresses child-on-child sexual assault at US military bases worldwide. And just hours after signing the military spending bill Monday, he did the same thing at a fundraiser in upstate NY.
The president studiously avoided reading the official name of the legislation - which would have meant mentioning McCain - during the 28-minute speech or during the signing ceremony afterward.
At a June rally, Trump criticized McCain for voting against a Republican bill to repeal the Affordable Care Act, saying that "one senator chose to put the thumb down, late in the morning".
McCain said in a statement he was "humbled" the bill was named after him, adding that it will address "a growing array of threats". But in his remarks discussing the bill, Trump never once mentioned McCain's name.