Extract the generated protobufs into its own Swift package

This change modifies the process for generating and integrating the Meshtastic protobufs into the client application.

* The generated Swift code is now in a local SPM package `MeshtasticProtobufs`
* An Xcode Workspace file `Meshtastic.xcworkspace` was created to more easily manage the new build targets.
* The code generation script for the protos was modified to generate the Swift code into the new location.
* The README.md was updated to reflect these changes.

NOTE: After merging this PR, do not open the project file `Meshtastic.xcodeproj`. You must use the workspace `Meshtastic.xcworkspace`

Extracting out the generated protobuf code into its own library enables several opportunities for the project. This is just a first step, but with some more modularization, a standalone Apple Watch app or other targets starts to become a little bit more achievable to implement.

After extracting the protobufs into a Swift package, I validate these changes by building and running the Meshtastic app to an iPhone 15 Pro Max, and tried changing some settings on a local node. I then messaged back and forth using two local nodes connected to two different iOS devices.
This commit is contained in:
Blake McAnally 2024-06-07 22:09:20 -05:00
parent 2bc48b1c60
commit 58da532d32
88 changed files with 2218 additions and 2212 deletions

18
scripts/gen_protos.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
# simple sanity checking for repo
if [ ! -d "./protobufs" ]; then
echo 'Please check out the protobuf submodule by running: `git submodule update --init`'
exit
fi
# simple sanity checking for executable
if [ ! -x "$(which protoc)" ]; then
echo 'Please install swift-protobuf by running: `brew install swift-protobuf`'
exit
fi
protoc --proto_path=./protobufs --swift_opt=Visibility=Public --swift_out=./MeshtasticProtobufs/Sources ./protobufs/meshtastic/*.proto
echo "Done generating the swift files from the proto files."
echo "Build, test, and commit changes."

4
scripts/thebenternify.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
sed -i '' -e 's/GCH7VS5Y9R/6YF6QJH524/g' ./Meshtastic.xcodeproj/project.pbxproj
sed -i '' -e 's/gvh.Meshtastic/thebentern.Meshtastic/g' ./Meshtastic.xcodeproj/project.pbxproj

4
scripts/unthebenternify.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
sed -i '' -e 's/6YF6QJH524/GCH7VS5Y9R/g' ./Meshtastic.xcodeproj/project.pbxproj
sed -i '' -e 's/thebentern.Meshtastic/gvh.Meshtastic/g' ./Meshtastic.xcodeproj/project.pbxproj