Apple became the first publicly listed US company with a $2 trillion stock market value, as Wall Street investors put aside challenges to its iPhone ecosystem.