This guide will show you how to provision an Apple Silicon machine to run a NativeScript app via Rosetta (x86 emulation). It may soon become possible to run it natively, but I believe that's pending this PR, so I had to go with Rosetta for the time being.
I did this setup on a borrowed M1 Mac Mini, so a few things had been provisioned already, but I'll do my best to retrace setup steps below.
I referenced the iOS-related setup steps in the NativeScript Advanced Setup: macOS docs. They're still up-to-date, except for referring to an older version of Node.js. Specifically, what I did was:
x86 Homebrew was provisioned already on the machine, like so:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
I just used Apple's stock Ruby (2.6.3p62
, which is only for x86).
Sidenote: I did experimentally try to run my NativeScript app using Node for arm64, but things ultimately failed once I reached the tns run ios
command, as it produced the error Error: spawn /usr/local/lib/node_modules/nativescript/node_modules/ios-device-lib/bin/darwin/arm64/ios-device-lib ENOENT
. This may shortly be solved once this PR lands, however.
arch -x86_64 brew update
arch -x86_64 brew install node@15
I also updated my .zshenv
with the following path to ensure that node was on my path:
export PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/local/sbin:$PATH
I just downloaded and installed it via the App Store app.
I then opened it, and accepted when it prompted me whether I'd like to install additional tools.
Next, I entered Preferences -> Locations -> Command Line Tools and selected "Xcode 12.3 (12C33)" (the only option available).
I also took this moment to log into my Xcode developer account in Preferences.
Nothing special needed for these steps.
sudo gem install xcodeproj
sudo gem install cocoapods
pod setup
sudo easy_install pip
pip install six
This step is necessary for the Cocoapods installation step to work, as the native Terminal encounters an issue with the ffi
gem otherwise, as documented in this GitHub issue.
See this GitHub Issue comment to show how to open Terminal in Rosetta mode.
Now you must reopen the Terminal app (if you haven't already) to ensure that it's in Rosetta (x86) mode. It's needed for the ns run ios
step to successfully perform the Pod install step.
ns create --react mycoolapp
cd mycoolapp
ns run ios
Your iOS app should now run in the simulator!
To run in arm64, after this PR lands, I think the steps would need to be modified to:
arch -x86_64
from the shell commands