New York CNN Business  — 

Apple is one of the most powerful tech companies on the planet. But it’s running into big trouble in China.

The company this week issued a dire warning to investors about its business, announcing that it would miss its sales target for the last quarter of 2018 by at least $5 billion.

In a letter to investors Wednesday, CEO Tim Cook explained that Apple is grappling with several issues, many related to China. It’s the first time since 2002 that Apple issued a reduction in its quarterly revenue forecast.

Weak sales

Apple blamed bad sales numbers in China as a big reason why it had to revise its forecast. In his letter, Cook said that more than 100% of the company’s worldwide revenue decline was in China for sales of iPhones, Macs and iPads.

That’s a huge problem: China makes up about 20% of Apple’s revenues globally.

Analyst Daniel Ives from Wedbush Securities called the revenue miss “jaw dropping.”

“Although the company had some quarters over the past 20 years that missed Street expectations, in the modern iPhone era last night was clearly Apple’s darkest day,” he wrote in a note Thursday.

China’s economy is slowing faster than expected

Growth in China last year is set to be the weakest since 1990. The world’s second largest economy is feeling the effects of a darkening trade outlook and government attempts to rein in risky lending after a rapid rise in debt levels.

“While we anticipated some challenges in key emerging markets, we did not foresee the magnitude of the economic deceleration, particularly in Greater China,” Cook wrote in his letter.

Trade tensions

The company’s China problems have been magnified by an ongoing trade war with the United States.

Cook told CNBC that trade tensions between the two economic heavyweights are putting “additional pressure on their economy.”

“As the climate of mounting uncertainty weighed on financial markets, the effects appeared to reach consumers as well, with traffic to our retail stores and our channel partners in China declining as the quarter progressed,” Cook added in his letter. He said China’s smartphone market is feeling a particularly tight squeeze.

A ripple effect

Apple isn’t the only company that could be hurt by China’s slowing economy. Other brands such as General Motors (GM), Volkswagen (VLKAF) and Starbucks (SBUX), which will report earnings in the coming weeks, could be affected.

That spells trouble for companies that rely on China’s enormous market to boost their global sales. Chinese consumers could be less willing to part with their cash for the latest smartphone or luxury handbag as they tighten their belts.

“This year has the potential to be a tough year for western brands,” said Benjamin Cavender, a Shanghai-based analyst at consultant China Market Research Group.

Slumping stocks

Apple’s stock has fallen nearly 8% Thursday. All three major indexes were lower, too.

European markets opened lower on Thursday. France’s CAC 40 and Germany’s DAX were the biggest losers, shedding around 0.7%. Stocks in Asia closed with small losses.

CNN Business’ Matt Egan, Seth Fiegerman, David Goldman, Julia Horowitz and Daniel Shane contributed to this report.