NativeScript / NativeScript/NativeScript

Project unable to build when using native api in code-sharing project

Open
#8,247 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

code-sharing os: ios
Dominant language
TypeScript
Stars
25.7k
Forks
1.7k
Avg merge
1d 5h
Merged PRs (30d)
35

Description

Environment

  • CLI: 6.3.3
  • Cross-platform modules: 6.3.2
  • Android Runtime:
  • iOS Runtime: 6.3.0
  • Plugin(s):

Describe the bug
Unable to build when using native api (iOS) in angular code sharing project. I have tried using multiple different ios specific functions and classes but I always get the same error. "Cannot find name ..."

When trying to access the same function in a regular project (non-code sharing) everything works as expected.

To Reproduce

  1. Create a code-sharing project.
  2. Install tns-platform-declarations (https://www.npmjs.com/package/tns-platform-declarations)
  3. Write some code that interacts with the native api.
  4. Build/Run

Expected behavior
The code-sharing project should build just like the regular one.

Sample project
https://github.com/johandrott/ns-codesharing

Additional context
Console output:
ERROR in src/app/home/home.component.tns.ts:9:21 - error TS2304: Cannot find name 'UIVisualEffectView'.

9 public overlay: UIVisualEffectView;
~~~~~~~~~~~~~~~~~~
src/app/home/home.component.tns.ts:19:22 - error TS2304: Cannot find name 'UIApplication'.

19 const window = UIApplication.sharedApplication.keyWindow;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked sample project and src/app/home/home.component.tns.ts, then reproduce the Angular code-sharing build after installing tns-platform-declarations. Trace why UIVisualEffectView and UIApplication are unavailable in the TypeScript build; done means the sample builds and the native API references resolve as they do in a regular project.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, ios, typescript
Domain
build-system, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.