Rename Environment -> TAKEnvironment to avoid SwiftUI collision

The bare `Environment` message name clashes with SwiftUI's `@Environment`
property wrapper, which is used by every SwiftUI view in an iOS consumer
app. Importing the generated proto module (e.g. `MeshtasticProtobufs`)
made `Environment` ambiguous in all 78 files of Meshtastic-Apple that
reference `@Environment(\.scenePhase)` or similar, breaking the build.

Field name `environment` on TAKPacketV2 stays unchanged — only the
message type is renamed. Wire format is unaffected (proto3 encodes by
tag number, not type name), but all generated code and source-level
references must be regenerated.

The `TAK` prefix matches the convention used by the outer TAKPacketV2
wrapper and is unambiguous across Swift (no SwiftUI/WeatherKit clash),
Kotlin, Python, TypeScript, and C# targets.
This commit is contained in:
Ben Meadors 2026-04-15 16:29:03 -05:00
parent da33d0ea72
commit 3ce7c51068

View file

@ -1732,8 +1732,16 @@ message TaskRequest {
* promotes it to a first-class structured field.
*
* Target wire cost: ~6-8 bytes compressed with a fully populated instance.
*
* Named `TAKEnvironment` (not just `Environment`) because the bare name
* collides with `SwiftUI.Environment` every SwiftUI view in a consuming
* iOS app uses the `@Environment` property wrapper, and importing the
* generated proto module would make `Environment` ambiguous in every one
* of those files. The `TAK` prefix matches the convention used by the
* outer `TAKPacketV2` wrapper and is unambiguous across all target
* languages (Swift, Kotlin, Python, TypeScript, C#).
*/
message Environment {
message TAKEnvironment {
/*
* Temperature in deci-degrees Celsius. 225 = 22.5°C.
* Range covers -50°C to +50°C (-500 to +500) which spans every realistic
@ -1939,8 +1947,10 @@ message TAKPacketV2 {
/*
* Observed weather conditions (temperature, wind). From <environment>.
* Type is `TAKEnvironment`, not `Environment`, to avoid colliding with
* SwiftUI's `@Environment` property wrapper in iOS consumers.
*/
optional Environment environment = 25;
optional TAKEnvironment environment = 25;
/*
* Sensor field-of-view cone (camera, FLIR, laser, etc.). From <sensor>.
*/