Apple (AAPL -0.81%) shares reached an all-time high in January 2022, coming off a stellar year for the tech industry in which the COVID-19 pandemic led homebound consumers to invest heavily in home office and entertainment devices.

However, the rest of the year hasn't gone as well. While 2022 started off on a high, increases in inflation have severely stunted consumer spending, leading to a stock market sell-off. 

Although Apple shares have dipped 20% year to date, the iPhone manufacturer has fared better than most tech companies this year. For instance, Netflix and AMD shares are down more than 50% year to date. Despite a slowdown in spending in multiple industries, Apple has retained strong demand and sales of its products. 

Here's why Apple is a stellar buy during a stock dip. 

Beating the odds

Apple posted its 2022 fourth-quarter earnings on Oct. 27, reporting a year-over-year revenue rise of 8.1% to $90.15 billion, which beat analysts' expectations by $1.38 billion. Operating income came in at $24.89 billion, rising 4.6%. 

The company's growth stemmed primarily from high demand for its iPhone 14 lineup, launched in September, and products within its Mac segment.

According to IDC, worldwide smartphone shipments declined by 9.7% in the last year, while PC shipments similarly fell 15%. However, Apple reported 9.6% revenue growth in its iPhone segment, hitting $42.6 billion, and a 25.3% rise in revenue for its Mac segment to $11.5 billion. 

In addition to defying market declines, Apple has retained a promising amount of free cash flow compared to the competition. Free cash flow has become a crucial metric this year, as the higher the figure, the better equipped a company will be to overcome a potential recession in 2023.

Apple's free cash flow is considerably higher than its peers', as seen in the table below. 

AAPL Free Cash Flow Chart

Data by YCharts

With $111.4 billion in free cash flow, Apple appears to have what it needs to get through further economic declines and continue investing in its business. 

iPhone production strains 

At the moment, prospective investors might be most concerned over Apple's reliance on China for its iPhone production. The country has suffered a spike in COVID-19 cases, resulting in new regulations. Factories can remain open, but workers must live on-site. There has been considerable pushback from workers, slowing production at Foxconn -- the plant responsible for 70% of iPhone shipments.

iPhone sales made up 52% of Apple's revenue in its fiscal 2022, fueling investor concern over potential production delays. However, it's important to keep a long-term perspective when adding to your portfolio.

In addition to Foxconn coordinating backup production with other plants, Apple is making moves to diversify its production. The company is now making some iPhone 14s in India, with JP Morgan Chase estimating about 25% of all Apple's products will be produced there by 2025.

Additionally, Apple has developments in the works that could grow the percentage of revenue it receives from other segments. For instance, Services, which includes platforms such as Apple TV+, Music, iCloud, and more, is a quickly growing segment for the company.

Services revenue rose by 14% to $78 billion in Apple's fiscal 2022, bringing in the second-largest portion of revenue after the iPhone. As the company's services business continues to grow, it may take pressure off of Apple's iPhone segment, giving the company time to find a more reliable source of production.

Moreover, numerous reports state Apple is hard at work creating an augmented/virtual reality device that could enter the market as early as 2023. The $25.33 billion augmented reality market is expected to see a compound annual growth rate of 40.9% until at least 2030, according to Grand View Research. With

Apple has a history of entering new markets and quickly dominating, as it did with tablets, Bluetooth headphones, and smartwatches. So, I wouldn't bet against it doing the same with augmented or virtual reality and diversifying its revenue further.

Apple may face short-term headwinds in a potential recession in 2023 and reduced production in China. However, Apple should be an excellent long-term investment with a price-to-earnings ratio of 23.5 and a stock that has risen 237% in the last five years despite recent market declines.