@@ -104,6 +104,95 @@ Framework snapshots can attach source locations to individual nodes:
104104
105105The web inspector shows this in the selected node properties.
106106
107+ ## NativeScript
108+
109+ For NativeScript apps, use the companion runtime package instead of linking this
110+ Swift package directly into your app code:
111+
112+ ``` sh
113+ npm install @nativescript/xcode-canvas-inspector
114+ ```
115+
116+ Start it as early as possible in app startup, before bootstrapping the app:
117+
118+ ``` ts
119+ import { startXcodeCanvasInspector } from " @nativescript/xcode-canvas-inspector" ;
120+
121+ if (__DEV__ ) {
122+ startXcodeCanvasInspector ({ port: 4310 });
123+ }
124+ ```
125+
126+ Important:
127+
128+ - ` port ` here is the ` xcode-canvas-web ` server port, not a per-app inspector port.
129+ - NativeScript apps do not need to choose or manage a unique local inspector port.
130+ - The package connects to ` /api/inspector/connect ` and falls back to ` /api/inspector/poll ` .
131+ - The separate auto-discovered local TCP ports described above are for the Swift in-app inspector transport, not the NativeScript package.
132+
133+ When the NativeScript inspector is running, ` View.getHierarchy ` returns the
134+ NativeScript logical tree by default and ` "source": "uikit" ` still forces the
135+ raw UIKit hierarchy.
136+
137+ ### Angular
138+
139+ For Angular NativeScript apps, call ` startXcodeCanvasInspector() ` before
140+ ` runNativeScriptAngularApp() ` .
141+
142+ ``` ts
143+ import { startXcodeCanvasInspector } from " @nativescript/xcode-canvas-inspector" ;
144+
145+ startXcodeCanvasInspector ({ port: 4310 });
146+
147+ runNativeScriptAngularApp ({
148+ appModuleBootstrap : () => bootstrapApplication (AppComponent , {
149+ providers: [
150+ provideNativeScriptHttpClient (withInterceptorsFromDi ()),
151+ provideNativeScriptRouter (routes ),
152+ ],
153+ }),
154+ });
155+ ```
156+
157+ If you want template file and line locations in the hierarchy, enable Angular
158+ template source locations in your NativeScript webpack config:
159+
160+ ``` js
161+ const webpack = require (" @nativescript/webpack" );
162+
163+ class AngularTemplateSourceLocationsPlugin {
164+ apply (compiler ) {
165+ const enable = async () => {
166+ const angularCompiler = await import (" @angular/compiler" );
167+ angularCompiler .setEnableTemplateSourceLocations ? .(true );
168+ };
169+
170+ compiler .hooks .beforeRun .tapPromise (
171+ " AngularTemplateSourceLocationsPlugin" ,
172+ enable,
173+ );
174+ compiler .hooks .watchRun .tapPromise (
175+ " AngularTemplateSourceLocationsPlugin" ,
176+ enable,
177+ );
178+ }
179+ }
180+
181+ module .exports = (env ) => {
182+ webpack .init (env);
183+ webpack .chainWebpack ((config ) => {
184+ config
185+ .plugin (" angular-template-source-locations" )
186+ .use (AngularTemplateSourceLocationsPlugin);
187+ });
188+
189+ return webpack .resolveConfig ();
190+ };
191+ ` ` `
192+
193+ That lets the NativeScript inspector attach ` sourceLocation` metadata such as
194+ ` src/ app/ home .component .html : 12 : 5 ` to hierarchy nodes.
195+
107196## Auth Token
108197
109198For shared-network simulator sessions, start with a token and require every request to include top-level ` token` .
0 commit comments