coder / coder/coder-desktop-macos

Investigate why app & system extension shared dependencies fail to embed

Open
#149 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
29
Forks
8
Avg merge
18h 14m
Merged PRs (30d)
4

Description

In both #145 and #98, I've encountered an issue with release builds of the app. These issues arose when a dependency was required by both the App target (or any of it's dependencies), and the system extension target (and any of it's dependencies).

In #98, the issue occurred when protobuf definitions were added directly to the app target, or a new framework target that would be depended on by the app target. They were previously working fine being depended on by just VPNLib (which the system extension depends on).
In the first case, the network extension would crash. In the second case, the app would crash.
The crash reason was:

Library not loaded: @rpath/SwiftProtobuf.framework/Versions/A/SwiftProtobuf

Other users have reported this issue https://github.com/apple/swift-protobuf/issues/1506#issuecomment-2435125065

In #143, the issue occured when InternalCollectionsUtilities was depended on by both the App target, and the VPN target (via another framework, VPNLib). When a library that depended on swift-collections was added to the app target, the network extension would crash on startup with the error:

Library not loaded: @rpath/InternalCollectionsUtilities.framework/Versions/A/InternalCollectionsUtilities

FWICT, xcode is making some form of optimisation where it constructs a framework for code shared between two different targets. This poses an issue with a system extension, which is copied and executed outside of the app bundle. A copy of the system extension always lives in the app bundle, so it's trivial for the app to depend on a framework present within the system extension bundle (we already do this), but not the other way around. If there was some way to tell xcode to embed this new framework within the system extension bundle, we wouldn't have this issue.

Instead, the workaround we've gone with is to simply put everything that would cause this issue in VPNLib, as to minimise the number of times we depend on any one package.

This issue doesn't require immediate action, and is more so for book-keeping. It would be good to post this alongside an MRE on the Apple developer forums and in Apple feedback assistant.

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 by reproducing the release-build failures described in issues #145, #98, and #143, focusing on dependencies shared by the App and VPN system extension targets. Prepare a minimal reproducible example showing the missing embedded framework, then document the result for the Apple Developer Forums and Feedback Assistant as described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.