Apple then asked the White House to waive tariffs on some components, suggesting it still wanted to make the Mac Pro in the United States. President Trump responded on Twitter that Apple “will not be given Tariff waiver, or relief, for Mac Pro parts that are made in China” and that the company should “Make them in the USA, no Tariffs!”

Days later, Timothy D. Cook, Apple’s chief executive, said Apple wanted to make the Mac Pro in America but suggested it needed tariff exemptions to do so. Weeks later, Mr. Trump tweeted that he was dining with Mr. Cook and that Apple “will be spending vast sums of money in the U.S. Great!”

The Mac Pro is Apple’s most expensive computer, starting at $6,000, and is targeted at professional customers such as photographers and film editors. It is among Apple’s lowest-volume products.

Mr. Trump for years has pressured Apple and other companies to shift manufacturing to the United States. Apple has been able to make a specialized product like the Mac Pro in the United States, but high-volume products like the iPhone would be difficult to manufacture outside China because no country can match China’s number of trained workers and its supply-chain infrastructure, according to analysts and former Apple employees.

Still, to reduce its dependence on China, where it assembles most of its products, Apple is investigating ways to increase manufacturing in Vietnam and India, even urging some suppliers to open new plants there, according to a former Apple executive who spoke on the condition of anonymity because of confidentiality agreements with Apple.