In certain scenarios where runtime errors occur, the debug info provided by the NativeScript CLI or by the application's XCode project is not sufficient. This article will guide you through the steps needed to debug the iOS Runtime library as a part of your NativeScript application. It implies you have the ios-runtime repository already cloned and set up. For more info on how to setup the ios-runtime project on your machine refer to its README.
1. Create a new NativeScript application using one of the following commands depending on your platform preference:
You can skip this step if you want to use some of your existing apps
NativeScript with Angular:
tns create debug-ios-runtime --ng
NativeScript with TypeScript:
tns create debug-ios-runtime --tsc
tns create debug-ios-runtime
tns prepare ios
WARNING: Make sure your environment fulfills all the requirements mentioned in ios-runtime's README.
mkdir cmake-build && cd cmake-build
WARNING: By default the generated XCode project builds the Runtime as a static library. In order to build it as a dynamic library you should pass the
BUILD_SHARED_LIBS=1flag to CMake.
cmake .. -GXcode -DBUILD_SHARED_LIBS=1
IMPORTANT: If you drag it from the Runtime's xcodeproj you will get an error, thus drag it from Finder after closing Nativescript.xcodeproj
Select your app target and go to General tab. Then under Embedded binaries select the
+ button and add
4. If you run the application project you should hit the breakpoint and see the printed text in the console: