Widget app extension: .appex binary is empty (dead-stripped) and the extension crashes in ExtensionFoundation on launch
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- swift
- 領域
- build-system, mobile
調査の方向性
Start with the .appExtension case in Sources/PackLib/Packer.swift and reproduce the empty binary using Examples/DemoExtensions. The report identifies the linker entry point as the cause of the empty binary, but also describes a separate crash in ExtensionFoundation after that entry point is removed. Trace both behaviors and compare the generated extension with the Xcode template; done means the widget code is retained and the extension launches with its widgets available.
索引モデルが issue の本文から書いたものです。
説明
Description
Building a WidgetKit app extension with xtool produces an .appex whose binary
is empty (no __text). Once the entry point is corrected so the widget code
is retained, the extension launches but crashes inside Apple's
ExtensionFoundation before any widget is registered.
Both are reproducible with the repo's own example at Examples/DemoExtensions.
- Empty
.appexbinary.Packeremits-e _NSExtensionMainfor every app
extension._NSExtensionMaincomes fromFoundation, so the linker resolves
the entry point outside the binary and drops all objects from the widget's
.libraryproduct. The appex has no__text, onlyU _NSExtensionMain.
A WidgetKit extension should use the defaultmainfrom@main/WidgetBundle. - Crash in
ExtensionFoundation. Without-e _NSExtensionMainthe widget
code is retained and the appex launches, but the process dies with
EXC_BREAKPOINT (SIGTRAP)while initializing_EXRunningExtension._shared.
Environment
Host OS / version: WSL2; Windows 11 25H2 (10.0.26200), Ubuntu 26.04.1 LTS
iOS device: 27.0.1 (24A446), iPhone 15 Pro Max
Swift: 6.4 (swift-6.4-RELEASE), x86_64-unknown-linux-gnu · SDK: iphoneos27.0
xtool: 1.21.0
Steps to reproduce
- Run
xtool dev buildon a project with a WidgetKit extension (e.g.Examples/DemoExtensions). - Inspect the appex binary → no
__text, onlyU _NSExtensionMain(issue 1). - In
xtool/.xtool-tmp/Package.swift, drop"-Xlinker", "-e", "-Xlinker", "_NSExtensionMain", rebuild the extension product, copy it into the appex. xtool install <app>.
Expected
The extension launches and its widgets appear in the home-screen widget gallery.
Actual
The extension launches, WidgetKit resolves the bundle host, then the process traps:
exception.type = EXC_BREAKPOINT,signal = SIGTRAP,termination.code = 5exception.codes = [1, 0x19e541268]— the same fixed address on every crash- faulting thread:
com.apple.main-thread
closure #1 in closure #1 in ... static _EXRunningExtension._shared + 116
specialized static MainActor.assumeIsolated<A>(_:file:line:) + 140
closure #1 in closure #1 in ... static _EXRunningExtension._shared + 228
one-time initialization function for _shared + 16
_dispatch_client_callout + 16
_dispatch_once_callout + 32
static _EXRunningExtension.sharedInstance() + 112
static _EXExtension.bootstrap(with:) + 40
StudoWidgets.$main() + 40
main + 12
start + 6616
The crash is silent: a __attribute__((constructor)) that redirects
stderr/stdout into os_log arms (STUDO-STDERR armed) but captures no
message before the trap — consistent with a compiler-emitted brk #1, not a
fatalError (no _assertionFailure frames).
Evidence
- Default appex from
Examples/DemoExtensions: 49408 bytes, no__text, onlyU _NSExtensionMain. - After the entry fix: ~900 KB (debug) / ~487 KB (release),
_main+__swift5_entrypresent. chronodlogs:main [WidgetBundle]→WidgetHost - Optional(ResolvedWidgetBundleHost)→ crash.- Ruled out:
Info.plist(identical to Xcode's Widget Extension template),CFBundleSupportedPlatforms/UIDeviceFamily, missing__info_plist,-all_load, debug vs release, Mach-O load commands.
Cause (issue 1)
Sources/PackLib/Packer.swift, case .appExtension:
unsafeFlags([
// Set the entry point to Foundation`_NSExtensionMain
"-Xlinker", "-e", "-Xlinker", "_NSExtensionMain",
...
]),
For SwiftUI/WidgetKit extensions the entry point must be the main generated by @main; omitting this flag keeps the widget code.
Notes
SignerImpl.signforwards only the root app's entitlements to nested bundles (// TODO: #131).- Related: #45 (app extension support), #284 (app groups on free teams).
- 主要言語
- Swift
- スター
- 5.5k
- フォーク
- 163
- 平均マージ
- 19時間 33分
- マージ済み PR(30日)
- 25
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
xtool-org/xtool のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
Error: exited(127)オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
xtool-org/xtool#365 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
xtool-org/xtool#364 · リアクション 6 件 ·
メンテナーはふだん 1 日以内に返信
xtool-org/xtool の issue をすべて見る
似ている issue
-
product / auth product / databases product / functions product / messaging product / storage product / vcs
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
storage: eliminate force-unwraps and fatalError in continueStreamingUpload対応中かも @chingor13 が今日担当しました。 オープンapi: storage type: cleanup
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
googleapis/google-cloud-swift#1527 ·
メンテナーはふだん 1 日以内に返信
-
ci-failure ci:assertion test
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openwatersio/slackwater-ios#811 ·
メンテナーはふだん 1 日以内に返信
-
ai-assisted
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
swiftlang/swift-testing#1979 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
rust: add fuzz targets for the readers?対応中かも @manas765 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
foxglove/mcap#1907 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信