Title: ns embed ios: finish the host metadata setup (duplicate -sectcreate flags, missing metadata file, hardcoded arch) · Issue #6168 · NativeScript/nativescript-cli · GitHub
Open Graph Title: ns embed ios: finish the host metadata setup (duplicate -sectcreate flags, missing metadata file, hardcoded arch) · Issue #6168 · NativeScript/nativescript-cli
X Title: ns embed ios: finish the host metadata setup (duplicate -sectcreate flags, missing metadata file, hardcoded arch) · Issue #6168 · NativeScript/nativescript-cli
Description: 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 t...
Open Graph Description: 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: Nativ...
X Description: 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: N...
Opengraph URL: https://github.com/NativeScript/nativescript-cli/issues/6168
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ns embed ios: finish the host metadata setup (duplicate -sectcreate flags, missing metadata file, hardcoded arch)","articleBody":"### Is your feature request related to a problem? Please describe.\n\n`ns embed ios` (added in #5803) leaves the host project's metadata setup half-finished. This issue tracks the follow-ups.\n\nContext: 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.\n\nThe relevant block is in [`lib/services/ios-project-service.ts`](https://github.com/NativeScript/nativescript-cli/blob/e157c9fb8b3ef9d8e79635e6b5520805b3790b04/lib/services/ios-project-service.ts#L738-L829).\n\n**1. The linker flag is appended on every run (bug)**\n\n`project.addToOtherLinkerFlags('-sectcreate __DATA __TNSMetadata \"\u003cproject>/metadata-arm64.bin\"')` runs on every `ns embed ios`: embed forces `prepareProject` each time ([`prepare-native-platform-service.ts`](https://github.com/NativeScript/nativescript-cli/blob/e157c9fb8b3ef9d8e79635e6b5520805b3790b04/lib/services/platform/prepare-native-platform-service.ts#L55)), and `addToOtherLinkerFlags` in `nativescript-dev-xcode` pushes without checking for an existing entry. The host's `OTHER_LDFLAGS` gains one more copy per run.\n\n`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.\n\n**2. Nothing delivers the metadata file**\n\nThe flag points at `\u003chostProject>/\u003cprojectName>/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.\n\n**3. The architecture and SDK are hardcoded**\n\nThe 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.\n\n**4. Failures in this block are silent**\n\nThe 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.\n\n### Describe the solution you'd like\n\n- [ ] Make adding the `-sectcreate` flag idempotent (skip or replace an existing entry), and clean up duplicates left by earlier runs.\n- [ ] Have `ns embed ios` put 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).\n- [ ] Reference the metadata per architecture and SDK instead of a fixed `metadata-arm64.bin`.\n- [ ] Surface errors from the host-project setup instead of logging them at trace level.\n\n### Describe alternatives you've considered\n\nFor 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.\n\nHaving 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.\n\n### Anything else?\n\n- Runtime side: NativeScript/ios#488. After it, the `NativeScriptSDK` SwiftPM product additionally embeds a default-metadata framework for zero-config hosts, while the `NativeScript` product stays lean.\n- Related docs change outside this repo: `NativeScript/ns-embed-example` tells hosts to add `NativeScriptSDK`. Hosts set up with `ns embed` link their own metadata and should add the `NativeScript` product instead, otherwise they also carry the unused 8.8 MB default-metadata framework.\n\n### Please accept these terms\n\n- [x] I have searched the [existing issues](https://github.com/NativeScript/nativescript-cli/issues) as well as [StackOverflow](https://stackoverflow.com/questions/tagged/nativescript) and this has not been posted before\n- [x] I agree to follow this project's [Code of Conduct](https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#coc)\n","author":{"url":"https://github.com/edusperoni","@type":"Person","name":"edusperoni"},"datePublished":"2026-10-05T17:58:37Z","url":"https://github.com/NativeScript/nativescript-cli/issues/6168"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5df624d5-1181-2b9f-40d8-8083fb0831fd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D390:358871:1684AEC:1DA70D4:6B012F00 |
| html-safe-nonce | 4776c79b9870470476ee464ded9efb321e768107b15c20057a7e632cc99aab0c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzkwOjM1ODg3MToxNjg0QUVDOjFEQTcwRDQ6NkIwMTJGMDAiLCJ2aXNpdG9yX2lkIjoiNTcxMDQ4OTc4NTg0ODYzOTIzMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4d4733a79829be40a445923614afbed0693c0d934d6aeb5c674eb4131f660f78 |
| hovercard-subject-tag | issue:5716712726 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/nativescript-cli/6168/issue_layout |
| twitter:image | https://opengraph.githubassets.com/885dcb76229efa4c7c2afbedc0f81bfd327573dc4de92dc07568c82ac6b5b5aa/NativeScript/nativescript-cli/issues/6168 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/885dcb76229efa4c7c2afbedc0f81bfd327573dc4de92dc07568c82ac6b5b5aa/NativeScript/nativescript-cli/issues/6168 |
| og:image:alt | 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: Nativ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | edusperoni |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/nativescript-cli git https://github.com/NativeScript/nativescript-cli.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 21347346 |
| octolytics-dimension-repository_nwo | NativeScript/nativescript-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21347346 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/nativescript-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width