Swift Playground Result Not Shown on Mac M1? Try This!

In Guides by Bintoro Adi Guna2 Comments

Anda berbicara Bahasa Indonesia? Baca link terjemahannya di sini!

As a mobile developer, especially for iOS apps, having a Mac is a must. Apple’s announcement on M1 Macs in November last year was very exciting. It promised not only amazing performance compared to Intel macs, it also offered superior compatibility with previous x86 architecture (M1 is ARM, a whole different set of architecture compared to Intel’s x86 architecture). For the same price, it seemed like a bargain, so I pulled the trigger on the base model Mac Mini. After 6 months, I think I’m going to post an impression article later.

Anyway, I’ve been meaning to learn Swift for a while. It’s a modern programming language that is much easier to learn compared to Objective-C (thank God I did not learn it in College…) for developing native iOS and macOS apps. Apple has been encouraging developers to transition to Swift, and inviting new and aspiring developers to learn with its vast resources and documentations. Apple even released an iPad app called Swift Playground to gamify the learning experience.

Although Windows support seems to be around the corner, you’ll still need a Mac and Xcode for the best possible experience. In Xcode, you can quickly create a playground, and try out coding in Swift. What’s amazing is that it will automatically run your code, and put the result on a bar on the right.

The Issue

The results should appear at the right side of the editor.

That is, until I try it out on my M1 Mac Mini. I was following a course in LinkedIn Learning, and it uses Swift Playground. Unfortunately, the bar does not show any result. I’ve searched through the Internet for hours, and unfortunately, I did not find any results. I’ve tried everything, from deleting derived data, to messing with the Xcode preferences. Nothing worked. For your information, I was using Xcode 12.4 on macOS Big Sur. The Swift Playground was working fine on my Intel MacBook Pro.

The Solution

The solution turns out to be simple: disable Rosetta. Initially, I turned Rosetta on for Xcode to prevent building issues with React Native. Unfortunately, it caused issues with the Swift Playground. To disable Rosetta for Xcode, go to Applications folder, right click on the Xcode icon, click More Info. You should see a Run with Rosetta checkbox. Uncheck it. Restart Xcode if it’s still running.

Disabling Rosetta turns out to be the fix.

After disabling Rosetta, voila! The Swift Playground’s result shows up again! Since it no longer causes build issues for my React Native project, I keep it disabled. It should run better in native mode, I guess.

Now the results appear! Enjoy your learning!

Well, I guess that’s it for now, Folks. If you face the same issue as mine for the Swift Playground, try it out. Finally, as usual, thanks for reading and see you in the next article! 😀


Leave a Comment