This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -34,9 +34,105 @@ By default the android.d.ts file contains the typings for android API level 17.
d.ts files require a lot of memory and CPU. Consider adding skipLibCheck option to tsconfig file.
## Generate android .d.ts files
* To generate android dependencies use [android-dts-generator](https://github.com/NativeScript/android-dts-generator) with the appropriate android version and android support jars
* To generate android dependencies use [android-dts-generator](https://github.com/NativeScript/android-dts-generator) with the appropriate android version and androidx jars
* To regenerate android-*.d.ts file use the **android-dts-generator** passing the corresponding android jar (described [here](https://github.com/NativeScript/android-dts-generator/blob/master/README.md#generate-definitons-for-android-sdk))
* More details for using the **android-dts-generator** can be found in [this article](https://docs.nativescript.org/core-concepts/android-runtime/metadata/generating-typescript-declarations).
### Generate new Android platform typings
The easiest way is to use the [makefile](https://github.com/NativeScript/android-dts-generator/blob/master/Makefile) in the [android-dts-generator](https://github.com/NativeScript/android-dts-generator) repo.
Open the makefile and check whether it already contains the command entry for the Android platform version you'd like to generate typings for. If it does not exist, add it. For example for api level 29 you need to add the following:
Copy the output from `out/android-platform-29.d.ts` to `tns-platform-declarations/android` folder in this repo.
Again in NativeScript repo create a new platform d.ts file in `tns-platform-declarations` folder by copying and updating an existing d.ts. For example as we are generating typings for api level 29 copy `tns-platform-declarations/android-28.d.ts`, rename it to `tns-platform-declarations/android-29.d.ts` and update its file contents like this:
NOTE that at this point we did not update the androidx reference above. To avoid having androidx typings for every different API level we try to reuse androidx typings built with an older API level for a range of Android versions (e.g. androidx 26 typings can be used for both api levels 26 and 27). Now we need to check whether the new platform typings can use the existing androidx d.ts, or we need to generate new ones.
In `tns-platform-declarations` folder in main NativeScript repo execute the following:
``` bash
# not mandatory, just to verify that the existing setup was ok (should complete without errors)
tsc android-28.d.ts
# this is the actual check for the new platform typings
tsc android-29.d.ts
```
If `tsc` command completed without errors, you are good to go; otherwise you need to generate the androidx typings with the same android API level super jar (more details [here](https://github.com/NativeScript/android-dts-generator#android-support-specifics) but you can also just follow the section below).
### Generate Androidx typings for new platform version
You can find the Androidx 1.0.0 jars [here](https://github.com/NativeScript/android-dts-generator/tree/master/libs/androidx/1.0.0) but we'll demonstrate how to extract the jars from scratch that will be useful for androidx version update. As androidx needs the base android jar file to create its typings you need to pass the android.jar file as a **super** parameter to the generator.
Open makefile in the [android-dts-generator](https://github.com/NativeScript/android-dts-generator) repo and the following (as we are generating typings for android api level 29):
Now we need to extract all androidx jars in`dts-generator/jar-files` folder (follow [https://github.com/NativeScript/android-dts-generator#finding-package-dependencies](https://github.com/NativeScript/android-dts-generator#finding-package-dependencies). Note that the necessary androidx dependencies are commented out in the [dts-generator/build.gradle](https://github.com/NativeScript/android-dts-generator/blob/master/dts-generator/build.gradle) file, you just need to temporarily uncomment them:
// add your dependency here as the example bellow, make sure you are using testCompileOnly
//AndroidX
//testCompileOnly "androidx.legacy:legacy-support-v4:1.0.0" <------ uncomment but do not commit
//testCompileOnly "androidx.appcompat:appcompat:1.0.0" <------ uncomment but do not commit
//testCompileOnly "com.google.android.material:material:1.0.0" <------ uncomment but do not commit
}
// ...
```
From `dts-generator` folder execute the following in command line (that will get the needed jars in `dts-generator/jar-files` folder):
``` bash
./gradlew extractAllJars
```
Now execute from command line the following:
``` bash
make android-platform-29
```
Copy the output from `out/androidx-29.d.ts` to `tns-platform-declarations/android` folder in the main [NativeScript](https://github.com/NativeScript/NativeScript) repo. Again in main NativeScript repo update the contents of `tns-platform-declarations/android-29.d.ts` like this:
In `tns-platform-declarations` folder in main NativeScript repo execute the following:
``` bash
# should complete without errors now
tsc android-29.d.ts
```
## Generate ios .d.ts files
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
chore: update readme #7929
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
chore: update readme #7929
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing