ns embed ios: finish the host metadata setup (duplicate -sectcreate flags, missing metadata file, hardcoded arch)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 50/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript
- 領域
- mobile-dev
研究方向
The work centers on lib/services/ios-project-service.ts lines 738-829. Make the -sectcreate flag addition idempotent, implement the missing metadata file delivery (uncomment or replace the build phase), replace the hardcoded metadata-arm64.bin with architecture/SDK-aware naming, and surface errors from the silent try/catch. Review prepare-native-platform-service.ts for the embed flow.
由索引模型根據 Issue 內容生成。
描述
Is your feature request related to a problem? Please describe.
ns embed ios (added in #5803) leaves the host project's metadata setup half-finished. This issue tracks the follow-ups.
Context: NativeScript/ios#488 changes the runtime so that, when Config.MetadataPtr is nil, it reads the __DATA,__TNSMetadata section of the host executable. Until that lands, the section ns embed ios links into the host is never read (embedded apps run on the default metadata baked into NativeScript.framework), which is why these problems have gone unnoticed. Once it lands, the section becomes the metadata the embedded app actually runs on.
The relevant block is in lib/services/ios-project-service.ts.
1. The linker flag is appended on every run (bug)
project.addToOtherLinkerFlags('-sectcreate __DATA __TNSMetadata "<project>/metadata-arm64.bin"') runs on every ns embed ios: embed forces prepareProject each time (prepare-native-platform-service.ts), and addToOtherLinkerFlags in nativescript-dev-xcode pushes without checking for an existing entry. The host's OTHER_LDFLAGS gains one more copy per run.
ld accepts a repeated -sectcreate for the same segment/section and concatenates the files (checked with a two-flag test link: a 17-byte file produced a 34-byte section). So every re-run adds another full copy of the metadata (roughly 9–12 MB each) to the host executable. The app still works, because the runtime reads from the start of the section.
2. Nothing delivers the metadata file
The flag points at <hostProject>/<projectName>/metadata-arm64.bin, but nothing creates that file. The "Copy Metadata (DEBUG)" build phase is commented out and step 2 ("Ensure metadata is copied as a file") is a // TODO. ns embed is a prepare, so the metadata generator never runs. Users have to build the NativeScript project separately and copy the file by hand (as the ns-embed-example README describes), and the host fails to link if it is missing.
3. The architecture and SDK are hardcoded
The flag always names metadata-arm64.bin, and the documented manual step copies the simulator build's file, so device builds link metadata generated against the simulator SDK. The app template uses metadata-$(CURRENT_ARCH).bin from the configuration build dir.
4. Failures in this block are silent
The whole host-project setup is wrapped in a try/catch that only logs at trace level ("Error adding NativeScript group to host project"), so a failure leaves the host partially configured with no visible error.
Describe the solution you'd like
- Make adding the
-sectcreateflag idempotent (skip or replace an existing entry), and clean up duplicates left by earlier runs. - Have
ns embed iosput the metadata in place, e.g. a build phase in the host that copies it from the NativeScript project's build output (what the commented-out phase sketched). - Reference the metadata per architecture and SDK instead of a fixed
metadata-arm64.bin. - Surface errors from the host-project setup instead of logging them at trace level.
Describe alternatives you've considered
For the metadata file: instead of copying the NativeScript project's metadata, run the metadata generator against the host project's own build settings (the nsld.sh mechanism the app template uses). That would also cover native classes that exist only in the host, which the copied metadata does not describe, but it is a larger change. Copying is a reasonable first step.
Having the host pass Config.MetadataPtr explicitly is no longer needed once NativeScript/ios#488 is in: the runtime finds the host executable's section itself, so Swift hosts need no C shim.
Anything else?
- Runtime side: NativeScript/ios#488. After it, the
NativeScriptSDKSwiftPM product additionally embeds a default-metadata framework for zero-config hosts, while theNativeScriptproduct stays lean. - Related docs change outside this repo:
NativeScript/ns-embed-exampletells hosts to addNativeScriptSDK. Hosts set up withns embedlink their own metadata and should add theNativeScriptproduct instead, otherwise they also carry the unused 8.8 MB default-metadata framework.
Please accept these terms
- I have searched the existing issues as well as StackOverflow and this has not been posted before
- I agree to follow this project's Code of Conduct
- 主要語言
- JavaScript
- 星號
- 1.1k
- 分支
- 203
- 平均合併
- 22 小時 26 分鐘
- 30 天內合併 PR
- 7
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
NativeScript/nativescript-cli 的其他 Issue
-
bug-pending-triage
難度 4/5 3-5 天 新手友好度 18/100
NativeScript/nativescript-cli#6172 · 3 則留言 ·
維護者通常 1 天內回覆
-
Fix cleanup request removal presence check logging可能重新可做 @edusperoni 於 101 天前認領,目前沒有進行中的 PR。 未關閉
NativeScript/nativescript-cli#6090 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
ns 9 running test after running the app starts the app not the test runner.可能重新可做 @NathanWalker 於 186 天前認領,目前沒有進行中的 PR。 未關閉in progress
NativeScript/nativescript-cli#6015 · 1 個 reaction · 已指派 1 人 ·
維護者通常 1 天內回覆
-
question
難度 4/5 3-5 天 新手友好度 48/100
NativeScript/nativescript-cli#5992 · 5 則留言 ·
維護者通常 1 天內回覆
-
feature-pending-triage
難度 4/5 3-5 天 新手友好度 35/100
NativeScript/nativescript-cli#5975 ·
維護者通常 1 天內回覆
查看 NativeScript/nativescript-cli 的全部 Issue
相似的 Issue
-
[ordering-review] workshop order graph: 1 confirmed ordering problem, 3 cycles are false positives未關閉
難度 2/5 1-3 小時 新手友好度 85/100
githubnext/gh-aw-workshop#5331 ·
維護者通常 1 天內回覆
-
channels:remove check:passed
難度 1/5 1 小時以內 新手友好度 65/100
維護者通常 4 天內回覆
-
[vika] console keeps a stale "in progress" turn after a daemon restart mid-run可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 86/100
volcengine/OpenViking#7011 ·
維護者通常 1 天內回覆
-
__VERSION__ within dist build is not replaced, causes missing version in XDM implementation details未關閉
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
Issue: ready for confirmation Reported on 2.4.9 Triage: Dev.Experience
難度 2/5 1-3 小時 新手友好度 70/100
magento/magento2#41773 · 1 則留言 ·
維護者通常 5 天內回覆