Image source: Getty Images.

What: Shares of Taiwan Semiconductor Manufacturing (TSM -0.55%) have gained 11.1% so far in 2016, according to data from S&P Global Market Intelligence. It's been a rocky ride, including a sudden drop at the end of April, but the chip manufacturer found a way to bounce back.

So what: The year started with a solid fourth-quarter report, where Taiwan Semi beat analyst targets on both the top and bottom lines. CFO Lora Ho credited the earnings surprise to solid cost-savings initiatives, along with good orders from the communications sector.

This report set Taiwan Semi shares off on a gentle rise over the next three months. The trajectory was boosted even further by reports that a couple of key component makers for the upcoming Apple (AAPL -0.81%) iPhone 7 reserved "significant" manufacturing resources for the second and third calendar quarters.

Another solid earnings report later, Apple itself presented disappointing iPhone sales on April 26. Swept up in that panic, Taiwan Semi shares closed 4.3% lower the next day.

Investors forgave and forgot over the next several weeks, restoring Taiwan Semi's stock to the gains it had enjoyed before Apple's scary report. And that's where the chipmaker stands at the end of June.

Now what: Apple is one of Taiwan Semi's most important customers. For each new iPhone and iPad model, the Cupertino giant orders up third-party components from several of Taiwan Semiconductor's larger clients. Moreover, this is the chip foundry of choice for Apple's own in-house mobile processor designs, including the A10 model slated for inclusion in the iPhone 7.

So it makes sense to see this stock move in tandem with major Apple news. On the other hand, Taiwan Semi is also a highly diversified company that can fill its factories with other orders if Apple falls short of expectations. That's why Taiwan Semi shares have been able to shrug off Apple's faltering fires over the last two years, rising 19% while Cupertino investors traded sideways.

Smartphones and tablets may not be the massive growth drivers they used to be, but this company stands ready to shift into the rising automotive computing and Internet of Things trends instead. And when those flames die down, the next Next Big Thing should be rounding the corner to support the global demand for high-volume chip manufacturing.

Taiwan Semiconductor shares have doubled over the last five years and tripled in 10. It's a fundamentally solid stock for the long term, even if the chart often looks jagged along the way.