1

When i run iOS xcode project with embedded nativescript frameworks and nativescript code, apps gives error when try to show/load nativescript pages into xcode console: Error: Error: A Frame must be used to navigate to a Page.

Below are the my Objective-c Function which starts loading NativeScript pages.

- (NSString*) scriptStringToLoad {
    NSString *source = @"var platform_1 = require('nativescript-angular/platform');"
    "var app_module_1 = require('./app/app.module');"
    "var platform = platform_1.platformNativeScriptDynamic();"
    "platform.bootstrapModule(app_module_1.AppModule);";

    return  source;
}

Below is NativeSctipt part:

  1. app.module.ts file code
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";

import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";

@NgModule({
    bootstrap: [
        AppComponent
    ],
    imports: [
        NativeScriptModule,
        AppRoutingModule
    ],
    declarations: [
        AppComponent
    ],
    schemas: [
        NO_ERRORS_SCHEMA
    ]
})
export class AppModule { }
  1. app.component.ts file code

    import { Component } from "@angular/core";

    @Component({ moduleId: module.id, selector: "ns-app", templateUrl: "app.component.html" }) export class AppComponent {

    onButtonTap() {
        console.log('Hi hello button tapped');
    }
    

    }

  2. app.component.html file code

3
  • What you have inside app.component.html? Commented Dec 5, 2018 at 16:08
  • My app.component.html has below code <StackLayout > <Button text="Button" (tap)="onButtonTap()"></Button> <Label class ="backgroundColor" text="Welocme Home"></Label> </StackLayout> Commented Dec 5, 2018 at 18:59
  • Your app.component.html should only have <page-router-outlet></page-router-outlet> and to build you can use tns build with --bundle flag to enable webpack build and check. You can follow the structure as in this playground sample - play.nativescript.org/?template=play-ng&id=iayuat Commented Dec 6, 2018 at 19:12

1 Answer 1

0

Your app.component.html should only have

<page-router-outlet></page-router-outlet> 

and to build you can use tns build with --bundle flag to enable webpack build and check.

You can follow the structure as in this playground sample - play.nativescript.org/?template=play-ng&id=iayuat

Sign up to request clarification or add additional context in comments.

2 Comments

My requirement is to push or present Nativescript page into existing iOS project, not to completely make nativescript as starting point for my existing iOS app. I am trying to run into XCode project which has all nativescript framework embedded. <page-router-outlet></page-router-outlet> is only if you want to use router approach but till now i don't want to route anywhere. just want to show nativescript page i.e "app.component.html" into existing iOS app.
Ok got it, You can refer to this - nativescript.org/blog/… , but as per NativeScript it is still an experimental approach. Not sure if it completely supported.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.