How to make two platform code to one

nativescriptcore
ios
android

#1

I have Two branches in git for android and ios respectively and i want to merge both in one
How can it be done?
somewhere in any video like android.ts or ios.ts file but I don’t know the exact procedure?
can someone help?


#2

I have also used tns-declarations


#3

{N} means to build cross platform apps, even your platform specific code can reside in same repo.

For simple piece of platform specific code, use if conditions to check whether platform is iOS / Android. For code behind files, simply save the file as filename.ios.js / filename.android.js.

If your code is much more complex based on platform, try writing as internal or external plugins.

https://docs.nativescript.org/plugins/building-plugins#step-3-write-your-plugin


#4

What if I have Common Code to both I have separated component with component.android/ios.ts

and I want some common component to be called which is main
but for some platform dependent code i and android/ios.ts


#5

I have tried with common.ts but dosn’t work


#6

Common + Platform specific files really work, tns-core-modules and almost every plugin uses the structure. Refer the docs in the link above, it has everything you need follow.


#7

i have to override i.e, extend or directly works?


#8

when call console.log() in constructor or ngOnInit() it never show output