Can't run on iOS due to Provisioning Profile issue


#1

So NativeScript development was working fine, until I updated to the latest version of macOS last night (10.12.4) and now when I execute the command tns run ios I get the following error:

ENOENT: no such file or directory, scandir '/Users/[my home folder]/Library/MobileDevice/Provisioning Profiles/'

and a bit below that:
IMPORTANT: Before building for iOS device, verify that you have configured a valid pair of certificate and provisioning profile on your OS X system.
If I prepare the project and open it in XCode it seems to work, but trying to run it through the NativeScript CLI fails every time. Have tried updating TNS to the latest version, removing and adding iOS platform from the project, updating XCode to the latest version, but I keep getting this error.

Do I need to become a paid Apple Developer so I can setup paid provisioning profiles? I was not a paid developer previously and have never setup provisioning profiles, but it was working before…


Build failed. ENOENT: no such file or directory, scandir '/Users/juan.../Library/MobileDevice/Provisioning Profiles/
#2

So I got it working. No idea why these steps worked (or exactly which ones are the ones that solve it), but this was how I solved the problem:

  1. Downloaded the latest version of Xcode from https://developer.apple.com/download/ - the Mac App Store wasn’t yet showing this update.
  2. Opened Xcode to ensure additional installation bits were completed.
  3. Updated to the latest version of NativeScript as per these instructions.
    Note: at this point tns run ios still wasn’t working.
  4. Ran tns prepare ios
  5. Navigated to \platforms\ios and opened the ‘.xcodeproj’ file in XCode
  6. Clicked the big ‘Run’ button, which opened the simulator and successfully ran the app.
  7. Ran tns run ios, which actually worked (with livesyncing!)
    And from now, tns run ios works, even with Xcode and the simulator closed (the simulator opens up automatically when I run it). It also works fine on other projects too.

EDIT
I suspect that this might have been caused because I had recently had a real iPhone plugged into my computer, and NativeScript was trying to run it on that rather than the simulator, which caused issues. When the problem came up again I was able to fix it by forcing it to use the simulator with the command

tns run ios --emulator