Skip to content

Commit bb2051a

Browse files
committed
feat: additional guides wip
1 parent e413c32 commit bb2051a

File tree

4 files changed

+113
-9
lines changed

4 files changed

+113
-9
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Platform Specific Handling
3+
---
4+
5+
Given there are often various differences between Android, iOS, visionOS, macOS, Meta Quest, etc.), how best to handle platform specific behavior? Like when a feature or behavior is only available on one and not the other.
6+
7+
NativeScript offers many ways to deal with platform specific cases.
8+
9+
:::tip
10+
In general, never sacrifice the quality of a target feature for the sake of cross platform compatibility. Your job is to deliver a superior experience for your users and thus NativeScript gives you a lot to work with in this regard.
11+
:::
12+
13+
## Android
14+
15+
There are many Android specific features which may only be accessible within the Android ecosystem. Let's start by looking at language specific features.
16+
17+
### Java
18+
19+
NativeScript gives you access to Java API's from TypeScript, however you may just want to work with Java and/or integrate Java features on Android devices. You can do so as follows:
20+
21+
1. Add `App_Resources/Android/src/main/java/com/company/features/Custom.java`
22+
2. You can now access `com.company.features.Custom` and any public API implementations from your TypeScript code.
23+
24+
For example, `Custom.java`:
25+
26+
```java
27+
28+
```
29+
30+
Upon running your NativeScript project, the `Custom.java` becomes accessible to your TypeScript code:
31+
32+
```ts
33+
const custom = new com.company.features.Custom();
34+
console.log(custom.name()); // 'NativeScript'
35+
```
36+
37+
### Kotlin
38+
39+
NativeScript gives you access to many Kotlin API's from TypeScript, however you may just want to work with Kotlin and/or integrate Kotlin features on Android devices. You can do so as follows:
40+
41+
1. Add `App_Resources/Android/src/main/java/com/company/features/Custom.kt`
42+
2. You can now access `com.company.features.Custom` and any public API implementations from your NativeScript project.
43+
44+
For example, `Custom.kt`:
45+
46+
```java
47+
48+
```
49+
50+
### Jetpack Compose
51+
52+
[Jetpack Compose](https://developer.android.com/compose) is "Android’s recommended modern toolkit for building native UI" and thus is not available on iOS. However with NativeScript you are never limited and can use Jetpack Compose using [@nativescript/jetpack-compose](https://docs.nativescript.org/plugins/jetpack-compose) for particular feature implementations or entire UI's if desired.
53+
54+
A great article on using Jetpack Compose with NativeScript is [here](https://dev.to/valorsoftware/introduction-to-jetpack-compose-for-nativescript-54d7).
55+
56+
## iOS
57+
58+
There are many iOS specific features which may only be accessible within the Apple ecosystem. Let's start by looking at language specific features.
59+
60+
### Objective C
61+
62+
### Swift
63+
64+
### SwiftUI
65+
66+
[SwiftUI](https://developer.apple.com/xcode/swiftui/) "helps you build great-looking apps across all Apple platforms with the power of Swift" and thus is not available on Android. However with NativeScript you are never limited and can use SwiftUI using [@nativescript/swift-ui](https://docs.nativescript.org/plugins/swift-ui) for particular feature implementations or entire UI's if desired.
67+
68+
A great article on using SwiftUI with NativeScript is [here](https://dev.to/valorsoftware/introduction-to-swiftui-for-nativescript-4m1b).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Platform Version Handling
3+
---
4+
5+
There are several key things to understand about platform version handling (eg: Android, iOS, visionOS, macOS, Meta Quest, etc.) within the scope of your NativeScript project.
6+
7+
As customary with JavaScript ecosystem handling, maintaining `package.json` dependency version handling is quite familiar with JavaScript developers in general. We recommend [this article](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Client-side_tools/Package_management) as well as [our overview here](https://docs.nativescript.org/guide/development-workflow/using-packages#package-managers) if not familiar with package managers.
8+
9+
This focuses on a topic beyond the JavaScript ecosystem -- How you can manage platform versions in different circumstances.
10+
11+
## Android
12+
13+
## iOS
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Unexpected Error Handling
3+
---
4+
5+
Beyond the standard error handling [mentioned here](/guide/error-handling), what to do with completely unexpected errors?
6+
7+
Let's look at a few examples here.
8+
9+
## Android
10+
11+
## iOS

content/sidebar.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,18 @@ export default [
161161
{
162162
text: 'Fundamental Concepts',
163163
items: [
164+
{
165+
text: 'Accessibility',
166+
link: '/guide/accessibility',
167+
},
164168
{
165169
text: 'Animations',
166170
link: '/guide/animations',
167171
},
172+
{
173+
text: 'Best Practices',
174+
link: '/best-practices/',
175+
},
168176
...coreSidebarItems,
169177
{
170178
text: 'Data Binding',
@@ -199,7 +207,7 @@ export default [
199207
{
200208
text: 'Styling',
201209
link: '/guide/styling',
202-
},
210+
}
203211
],
204212
},
205213
{
@@ -254,14 +262,6 @@ export default [
254262
text: 'Shared Element Transitions',
255263
link: '/guide/shared-element-transitions',
256264
},
257-
{
258-
text: 'Accessibility',
259-
link: '/guide/accessibility',
260-
},
261-
{
262-
text: 'Best Practices',
263-
link: '/best-practices/',
264-
},
265265
{
266266
text: 'Multithreading',
267267
link: '/guide/multithreading',
@@ -296,6 +296,18 @@ export default [
296296
},
297297
],
298298
},
299+
{
300+
text: 'Platform Specific Handling',
301+
link: '/guide/platform-specific-handling',
302+
},
303+
{
304+
text: 'Platform Version Handling',
305+
link: '/guide/platform-version-handling',
306+
},
307+
{
308+
text: 'Unexpected Error Handling',
309+
link: '/guide/unexpected-error-handling',
310+
},
299311
],
300312
},
301313
] as NSSidebarGroup[]

0 commit comments

Comments
 (0)