Earlier Mr Cook visited an Apple store in Glasgow, where staff gave him a tartan scarf and a drawing.
His comments on the presidential decree targeting seven predominantly Muslim countries came in a Q&A session at the university.
Responding to questions from students and staff, Mr Cook said: "I wrote this letter, you probably read about it unless you're living underground, about the most recent executive order that was issued in the US.
"We have employees that secured a work visa, they brought family to the US, but happened to be outside the US when the executive order was issued and all of a sudden their families were affected.
"They couldn't get back in. That's a crisis. You can imagine the stress.
"If we stand and say nothing it's as if we're agreeing, that we become a part of it. It's important to speak out."
Mr Cook has taken a strong stance on user privacy and other issues which have at times brought him into conflict with the US authorities.
Since taking the helm of the company, Mr Cook has led the introduction of new products such as the iPhone 7, iPad Pro and Apple Watch.
He is also leading a company-wide effort to use 100% renewable energy at all Apple facilities.
In 2015, the 56-year-old became an honorary patron of Trinity College Dublin's Philosophical Society and gave a talk to students.
The embroidered picture presented by the Apple store staff shows Mr Cook waving and the words: "Welcome Tim."
It also features saltire flags and the Loch Ness monster.
He said: "That's great. I recall looking for the Loch Ness monster in 1984.
"Everything is right but the color of the hair."