From e3c26018f98ecae9ee23568821226c06faca22d9 Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Tue, 27 Jan 2026 21:10:47 -0300 Subject: [PATCH 01/11] Add netbird SDK project as submodule --- .gitmodules | 3 +++ libs/netbird | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 libs/netbird diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..93b8e0a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libs/netbird"] + path = libs/netbird + url = https://github.com/netbirdio/netbird diff --git a/libs/netbird b/libs/netbird new file mode 160000 index 0000000..2248ff3 --- /dev/null +++ b/libs/netbird @@ -0,0 +1 @@ +Subproject commit 2248ff392f659f4e941d8f337683f8e2344c60de From dfa0842baba31a2d76e57089e85668a972b0f1e2 Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Tue, 27 Jan 2026 21:13:59 -0300 Subject: [PATCH 02/11] Set netbird submodule to v0.64.2 tag --- libs/netbird | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/netbird b/libs/netbird index 2248ff3..06966da 160000 --- a/libs/netbird +++ b/libs/netbird @@ -1 +1 @@ -Subproject commit 2248ff392f659f4e941d8f337683f8e2344c60de +Subproject commit 06966da0121382297297d6838a90dd6e87d048ac From d624d8bb00e321571f76fffdbec891a7c9afa7e4 Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Tue, 27 Jan 2026 21:55:53 -0300 Subject: [PATCH 03/11] Change build-go-lib script to use submodule path Now it only receives an optional tag version. If it exists in the submodule's tag list, it will check out the submodule at the provided tag and build the NetBirdSDK over it --- build-go-lib.sh | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/build-go-lib.sh b/build-go-lib.sh index 7951e23..8cdb2f1 100755 --- a/build-go-lib.sh +++ b/build-go-lib.sh @@ -1,20 +1,51 @@ #!/bin/bash set -e +# Normalize semantic versions to drop a leading 'v' (e.g., v1.2.3 -> 1.2.3). +# Only strips if the string starts with 'v' followed by a digit, so it won't affect +# dev/ci strings or other non-semver values. +normalize_version() { + local ver="$1" + if [[ "$ver" =~ ^v[0-9] ]]; then + ver="${ver#v}" + fi + echo "$ver" +} + +# Checkout a git tag in the specified repository path +# Tries the tag as provided, then with 'v' prefix if needed +checkout_tag() { + local tag="$1" + local repo_path="$2" + + if git -C "$repo_path" rev-parse "refs/tags/$tag" >/dev/null 2>&1; then + git -C "$repo_path" checkout "$tag" + return 0 + fi + + # Try with 'v' prefix if not provided + if [[ ! "$tag" =~ ^v ]] && git -C "$repo_path" rev-parse "refs/tags/v$tag" >/dev/null 2>&1; then + git -C "$repo_path" checkout "v$tag" + return 0 + fi + + echo "Error: Tag '$tag' does not exist" >&2 + exit 1 +} + rn_app_path=$(pwd) -netbirdPath=$1 -if [ -z "${1+x}" ] -then - netbirdPath=${GOPATH}/src/github.com/netbirdio/netbird -fi +netbirdPath=$rn_app_path/libs/netbird -version=$2 -if [ -z "${2+x}" ] -then +if [ -n "$1" ]; then + checkout_tag "$1" "$netbirdPath" + version=$(normalize_version "$1") +else version=development fi -cd $netbirdPath +cd "$netbirdPath" + +echo "Building NetBirdSDK version: $version" gomobile-netbird init CGO_ENABLED=0 gomobile-netbird bind -target=ios,iossimulator,tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK From 30359ccafc141cb7acbefc4b90dc084c2d213700 Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Wed, 28 Jan 2026 10:26:54 -0300 Subject: [PATCH 04/11] Add some validation steps to build-go-lib Change gomobile-netbird usage to forked gomobile in $GOPATH temporarily (bind dependencies aren't being resolved) --- build-go-lib.sh | 61 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/build-go-lib.sh b/build-go-lib.sh index 8cdb2f1..0aa28f9 100755 --- a/build-go-lib.sh +++ b/build-go-lib.sh @@ -1,5 +1,13 @@ #!/bin/bash -set -e +# Script to build NetBird iOS/tvOS bindings using gomobile +# Usage: ./build-go-lib.sh [version] +# - If a version is provided, it will be used (with leading 'v' stripped if present). +# - If no version is provided: +# * Uses the latest Git tag if available (with leading 'v' stripped if present). +# * Otherwise, defaults to "dev-". +# - When running in GitHub Actions, uses "ci-" instead of "dev-". + +set -euo pipefail # Normalize semantic versions to drop a leading 'v' (e.g., v1.2.3 -> 1.2.3). # Only strips if the string starts with 'v' followed by a digit, so it won't affect @@ -33,21 +41,52 @@ checkout_tag() { exit 1 } +# Get version string, optionally checking out a tag if provided +get_version() { + local version_arg="${1:-}" + local repo_path="$2" + + if [ -n "$version_arg" ]; then + # Version provided - validate and checkout the tag + checkout_tag "$version_arg" "$repo_path" + normalize_version "$version_arg" + return + fi + + # No version provided - try to get the latest tag + local tag + tag=$(git -C "$repo_path" describe --tags --exact-match 2>/dev/null || true) + + if [ -n "$tag" ]; then + normalize_version "$tag" + return + fi + + # Fallback to dev/ci prefix with short hash + local short_hash + short_hash=$(git -C "$repo_path" rev-parse --short HEAD) + + if [ "${GITHUB_ACTIONS:-}" = "true" ]; then + echo "ci-$short_hash" + else + echo "dev-$short_hash" + fi +} + rn_app_path=$(pwd) netbirdPath=$rn_app_path/libs/netbird -if [ -n "$1" ]; then - checkout_tag "$1" "$netbirdPath" - version=$(normalize_version "$1") -else - version=development -fi +version=$(get_version "${1:-}" "$netbirdPath") cd "$netbirdPath" -echo "Building NetBirdSDK version: $version" +echo "Using version: $version" + +~/go/bin_gomobile_tvos/gomobile init +~/go/bin_gomobile_tvos/gomobile bind -target=ios,iossimulator,tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK + +#gomobile-netbird init +#gomobile-netbird bind -target=ios,iossimulator,tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK -gomobile-netbird init -CGO_ENABLED=0 gomobile-netbird bind -target=ios,iossimulator,tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK -cd - +cd - > /dev/null From a75c279a470d4beb77139418d6bf98946c7d5560 Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Fri, 30 Jan 2026 10:49:22 -0300 Subject: [PATCH 05/11] Separate build for iOS and tvOS in different scripts --- build-ios-lib.sh | 91 +++++++++++++++++++++++++++++++++++++++++++++++ build-tvos-lib.sh | 91 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100755 build-ios-lib.sh create mode 100644 build-tvos-lib.sh diff --git a/build-ios-lib.sh b/build-ios-lib.sh new file mode 100755 index 0000000..dbb4584 --- /dev/null +++ b/build-ios-lib.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# Script to build NetBird iOS/tvOS bindings using gomobile +# Usage: ./build-go-lib.sh [version] +# - If a version is provided, it will be used (with leading 'v' stripped if present). +# - If no version is provided: +# * Uses the latest Git tag if available (with leading 'v' stripped if present). +# * Otherwise, defaults to "dev-". +# - When running in GitHub Actions, uses "ci-" instead of "dev-". + +set -euo pipefail + +# Normalize semantic versions to drop a leading 'v' (e.g., v1.2.3 -> 1.2.3). +# Only strips if the string starts with 'v' followed by a digit, so it won't affect +# dev/ci strings or other non-semver values. +normalize_version() { + local ver="$1" + if [[ "$ver" =~ ^v[0-9] ]]; then + ver="${ver#v}" + fi + echo "$ver" +} + +# Checkout a git tag in the specified repository path +# Tries the tag as provided, then with 'v' prefix if needed +checkout_tag() { + local tag="$1" + local repo_path="$2" + + if git -C "$repo_path" rev-parse "refs/tags/$tag" >/dev/null 2>&1; then + git -C "$repo_path" checkout "$tag" + return 0 + fi + + # Try with 'v' prefix if not provided + if [[ ! "$tag" =~ ^v ]] && git -C "$repo_path" rev-parse "refs/tags/v$tag" >/dev/null 2>&1; then + git -C "$repo_path" checkout "v$tag" + return 0 + fi + + echo "Error: Tag '$tag' does not exist" >&2 + exit 1 +} + +# Get version string, optionally checking out a tag if provided +get_version() { + local version_arg="${1:-}" + local repo_path="$2" + + if [ -n "$version_arg" ]; then + # Version provided - validate and checkout the tag + checkout_tag "$version_arg" "$repo_path" + normalize_version "$version_arg" + return + fi + + # No version provided - try to get the latest tag + local tag + tag=$(git -C "$repo_path" describe --tags --exact-match 2>/dev/null || true) + + if [ -n "$tag" ]; then + normalize_version "$tag" + return + fi + + # Fallback to dev/ci prefix with short hash + local short_hash + short_hash=$(git -C "$repo_path" rev-parse --short HEAD) + + if [ "${GITHUB_ACTIONS:-}" = "true" ]; then + echo "ci-$short_hash" + else + echo "dev-$short_hash" + fi +} + +rn_app_path=$(pwd) +netbirdPath=$rn_app_path/libs/netbird + +version=$(get_version "${1:-}" "$netbirdPath") + +cd "$netbirdPath" + +echo "Using version: $version" + +#~/go/bin_gomobile_tvos/gomobile init +#~/go/bin_gomobile_tvos/gomobile bind -target=ios,iossimulator,tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK + +gomobile init +gomobile bind -target=ios,iossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK + +cd - > /dev/null diff --git a/build-tvos-lib.sh b/build-tvos-lib.sh new file mode 100644 index 0000000..da839f2 --- /dev/null +++ b/build-tvos-lib.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# Script to build NetBird iOS/tvOS bindings using gomobile +# Usage: ./build-go-lib.sh [version] +# - If a version is provided, it will be used (with leading 'v' stripped if present). +# - If no version is provided: +# * Uses the latest Git tag if available (with leading 'v' stripped if present). +# * Otherwise, defaults to "dev-". +# - When running in GitHub Actions, uses "ci-" instead of "dev-". + +set -euo pipefail + +# Normalize semantic versions to drop a leading 'v' (e.g., v1.2.3 -> 1.2.3). +# Only strips if the string starts with 'v' followed by a digit, so it won't affect +# dev/ci strings or other non-semver values. +normalize_version() { + local ver="$1" + if [[ "$ver" =~ ^v[0-9] ]]; then + ver="${ver#v}" + fi + echo "$ver" +} + +# Checkout a git tag in the specified repository path +# Tries the tag as provided, then with 'v' prefix if needed +checkout_tag() { + local tag="$1" + local repo_path="$2" + + if git -C "$repo_path" rev-parse "refs/tags/$tag" >/dev/null 2>&1; then + git -C "$repo_path" checkout "$tag" + return 0 + fi + + # Try with 'v' prefix if not provided + if [[ ! "$tag" =~ ^v ]] && git -C "$repo_path" rev-parse "refs/tags/v$tag" >/dev/null 2>&1; then + git -C "$repo_path" checkout "v$tag" + return 0 + fi + + echo "Error: Tag '$tag' does not exist" >&2 + exit 1 +} + +# Get version string, optionally checking out a tag if provided +get_version() { + local version_arg="${1:-}" + local repo_path="$2" + + if [ -n "$version_arg" ]; then + # Version provided - validate and checkout the tag + checkout_tag "$version_arg" "$repo_path" + normalize_version "$version_arg" + return + fi + + # No version provided - try to get the latest tag + local tag + tag=$(git -C "$repo_path" describe --tags --exact-match 2>/dev/null || true) + + if [ -n "$tag" ]; then + normalize_version "$tag" + return + fi + + # Fallback to dev/ci prefix with short hash + local short_hash + short_hash=$(git -C "$repo_path" rev-parse --short HEAD) + + if [ "${GITHUB_ACTIONS:-}" = "true" ]; then + echo "ci-$short_hash" + else + echo "dev-$short_hash" + fi +} + +rn_app_path=$(pwd) +netbirdPath=$rn_app_path/libs/netbird + +version=$(get_version "${1:-}" "$netbirdPath") + +cd "$netbirdPath" + +echo "Using version: $version" + +#~/go/bin_gomobile_tvos/gomobile init +#~/go/bin_gomobile_tvos/gomobile bind -target=tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK + +gomobile-netbird init +gomobile-netbird bind -target=tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK + +cd - > /dev/null \ No newline at end of file From c926cdf2191eecf896f827ce1296c4bd441748e4 Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Fri, 30 Jan 2026 10:50:43 -0300 Subject: [PATCH 06/11] Remove old build file --- build-go-lib.sh | 92 ------------------------------------------------- 1 file changed, 92 deletions(-) delete mode 100755 build-go-lib.sh diff --git a/build-go-lib.sh b/build-go-lib.sh deleted file mode 100755 index 0aa28f9..0000000 --- a/build-go-lib.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -# Script to build NetBird iOS/tvOS bindings using gomobile -# Usage: ./build-go-lib.sh [version] -# - If a version is provided, it will be used (with leading 'v' stripped if present). -# - If no version is provided: -# * Uses the latest Git tag if available (with leading 'v' stripped if present). -# * Otherwise, defaults to "dev-". -# - When running in GitHub Actions, uses "ci-" instead of "dev-". - -set -euo pipefail - -# Normalize semantic versions to drop a leading 'v' (e.g., v1.2.3 -> 1.2.3). -# Only strips if the string starts with 'v' followed by a digit, so it won't affect -# dev/ci strings or other non-semver values. -normalize_version() { - local ver="$1" - if [[ "$ver" =~ ^v[0-9] ]]; then - ver="${ver#v}" - fi - echo "$ver" -} - -# Checkout a git tag in the specified repository path -# Tries the tag as provided, then with 'v' prefix if needed -checkout_tag() { - local tag="$1" - local repo_path="$2" - - if git -C "$repo_path" rev-parse "refs/tags/$tag" >/dev/null 2>&1; then - git -C "$repo_path" checkout "$tag" - return 0 - fi - - # Try with 'v' prefix if not provided - if [[ ! "$tag" =~ ^v ]] && git -C "$repo_path" rev-parse "refs/tags/v$tag" >/dev/null 2>&1; then - git -C "$repo_path" checkout "v$tag" - return 0 - fi - - echo "Error: Tag '$tag' does not exist" >&2 - exit 1 -} - -# Get version string, optionally checking out a tag if provided -get_version() { - local version_arg="${1:-}" - local repo_path="$2" - - if [ -n "$version_arg" ]; then - # Version provided - validate and checkout the tag - checkout_tag "$version_arg" "$repo_path" - normalize_version "$version_arg" - return - fi - - # No version provided - try to get the latest tag - local tag - tag=$(git -C "$repo_path" describe --tags --exact-match 2>/dev/null || true) - - if [ -n "$tag" ]; then - normalize_version "$tag" - return - fi - - # Fallback to dev/ci prefix with short hash - local short_hash - short_hash=$(git -C "$repo_path" rev-parse --short HEAD) - - if [ "${GITHUB_ACTIONS:-}" = "true" ]; then - echo "ci-$short_hash" - else - echo "dev-$short_hash" - fi -} - -rn_app_path=$(pwd) -netbirdPath=$rn_app_path/libs/netbird - -version=$(get_version "${1:-}" "$netbirdPath") - -cd "$netbirdPath" - -echo "Using version: $version" - -~/go/bin_gomobile_tvos/gomobile init -~/go/bin_gomobile_tvos/gomobile bind -target=ios,iossimulator,tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK - -#gomobile-netbird init -#gomobile-netbird bind -target=ios,iossimulator,tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK - - -cd - > /dev/null From 5de97fe701ebfe07663ad037b2008ef756ec0294 Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Fri, 30 Jan 2026 11:01:53 -0300 Subject: [PATCH 07/11] Update submodule to v0.64.3 --- libs/netbird | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/netbird b/libs/netbird index 06966da..5333e55 160000 --- a/libs/netbird +++ b/libs/netbird @@ -1 +1 @@ -Subproject commit 06966da0121382297297d6838a90dd6e87d048ac +Subproject commit 5333e55a8134b7f0feb58777e92c32509abcd037 From 5f0373ce9bedb78a41178979f48c2d9af060d8df Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Fri, 30 Jan 2026 12:05:44 -0300 Subject: [PATCH 08/11] Add platform parameter to build-ios-lib.sh --- build-ios-lib.sh | 82 ++++++++++++++++++++++++++++++++++-------- build-tvos-lib.sh | 91 ----------------------------------------------- 2 files changed, 68 insertions(+), 105 deletions(-) delete mode 100644 build-tvos-lib.sh diff --git a/build-ios-lib.sh b/build-ios-lib.sh index dbb4584..7b73c14 100755 --- a/build-ios-lib.sh +++ b/build-ios-lib.sh @@ -1,11 +1,28 @@ #!/bin/bash # Script to build NetBird iOS/tvOS bindings using gomobile -# Usage: ./build-go-lib.sh [version] -# - If a version is provided, it will be used (with leading 'v' stripped if present). -# - If no version is provided: -# * Uses the latest Git tag if available (with leading 'v' stripped if present). -# * Otherwise, defaults to "dev-". -# - When running in GitHub Actions, uses "ci-" instead of "dev-". +# +# Usage: ./build-ios-lib.sh [platform] [version] +# +# Parameters: +# 1. platform (optional): Target platform(s) to build for +# - ios : Build for iOS and iOS Simulator only (uses standard gomobile) +# - tvos : Build for tvOS and tvOS Simulator only (uses gomobile-netbird) +# - both : Build for all platforms (uses gomobile-netbird) [default] +# +# 2. version (optional): Git tag to build +# - If provided, validates the tag exists in the submodule and checks it out +# - If omitted and current commit is exactly tagged, uses that tag +# - Otherwise, uses "dev-" (or "ci-" in GitHub Actions) +# - Leading 'v' is stripped from semver tags (v1.2.3 -> 1.2.3) +# +# Examples: +# ./build-ios-lib.sh # Build both platforms using current commit +# ./build-ios-lib.sh ios # Build iOS only using current commit +# ./build-ios-lib.sh tvos v0.64.1 # Build tvOS only using tag v0.64.1 +# ./build-ios-lib.sh both v0.64.1 # Build both platforms using tag v0.64.1 +# +# Output: +# Creates NetBirdSDK.xcframework in the current directory set -euo pipefail @@ -53,7 +70,7 @@ get_version() { return fi - # No version provided - try to get the latest tag + # No version provided - try to get an exact tag for current commit local tag tag=$(git -C "$repo_path" describe --tags --exact-match 2>/dev/null || true) @@ -76,16 +93,53 @@ get_version() { rn_app_path=$(pwd) netbirdPath=$rn_app_path/libs/netbird -version=$(get_version "${1:-}" "$netbirdPath") +# Parse arguments +platform="${1:-both}" +version_arg="${2:-}" -cd "$netbirdPath" +# Validate platform argument +case "$platform" in + ios|tvos|both) + ;; + *) + echo "Error: Invalid platform '$platform'. Must be 'ios', 'tvos', or 'both'." >&2 + exit 1 + ;; +esac -echo "Using version: $version" +# Get version (this also checks out the tag if provided) +version=$(get_version "$version_arg" "$netbirdPath") -#~/go/bin_gomobile_tvos/gomobile init -#~/go/bin_gomobile_tvos/gomobile bind -target=ios,iossimulator,tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK +cd "$netbirdPath" -gomobile init -gomobile bind -target=ios,iossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK +echo "Using version: $version" +echo "Building for platform: $platform" + +# Set targets and gomobile command based on platform +case "$platform" in + ios) + targets="ios,iossimulator" + gomobile_cmd="gomobile" + ;; + tvos) + targets="tvos,tvossimulator" + gomobile_cmd="gomobile-netbird" + ;; + both) + targets="ios,iossimulator,tvos,tvossimulator" + gomobile_cmd="gomobile-netbird" + ;; +esac + +# Initialize gomobile +$gomobile_cmd init + +# Build +CGO_ENABLED=0 $gomobile_cmd bind \ + -target="$targets" \ + -bundleid=io.netbird.framework \ + -ldflags="-X github.com/netbirdio/netbird/version.version=$version" \ + -o "$rn_app_path/NetBirdSDK.xcframework" \ + "$netbirdPath/client/ios/NetBirdSDK" cd - > /dev/null diff --git a/build-tvos-lib.sh b/build-tvos-lib.sh deleted file mode 100644 index da839f2..0000000 --- a/build-tvos-lib.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -# Script to build NetBird iOS/tvOS bindings using gomobile -# Usage: ./build-go-lib.sh [version] -# - If a version is provided, it will be used (with leading 'v' stripped if present). -# - If no version is provided: -# * Uses the latest Git tag if available (with leading 'v' stripped if present). -# * Otherwise, defaults to "dev-". -# - When running in GitHub Actions, uses "ci-" instead of "dev-". - -set -euo pipefail - -# Normalize semantic versions to drop a leading 'v' (e.g., v1.2.3 -> 1.2.3). -# Only strips if the string starts with 'v' followed by a digit, so it won't affect -# dev/ci strings or other non-semver values. -normalize_version() { - local ver="$1" - if [[ "$ver" =~ ^v[0-9] ]]; then - ver="${ver#v}" - fi - echo "$ver" -} - -# Checkout a git tag in the specified repository path -# Tries the tag as provided, then with 'v' prefix if needed -checkout_tag() { - local tag="$1" - local repo_path="$2" - - if git -C "$repo_path" rev-parse "refs/tags/$tag" >/dev/null 2>&1; then - git -C "$repo_path" checkout "$tag" - return 0 - fi - - # Try with 'v' prefix if not provided - if [[ ! "$tag" =~ ^v ]] && git -C "$repo_path" rev-parse "refs/tags/v$tag" >/dev/null 2>&1; then - git -C "$repo_path" checkout "v$tag" - return 0 - fi - - echo "Error: Tag '$tag' does not exist" >&2 - exit 1 -} - -# Get version string, optionally checking out a tag if provided -get_version() { - local version_arg="${1:-}" - local repo_path="$2" - - if [ -n "$version_arg" ]; then - # Version provided - validate and checkout the tag - checkout_tag "$version_arg" "$repo_path" - normalize_version "$version_arg" - return - fi - - # No version provided - try to get the latest tag - local tag - tag=$(git -C "$repo_path" describe --tags --exact-match 2>/dev/null || true) - - if [ -n "$tag" ]; then - normalize_version "$tag" - return - fi - - # Fallback to dev/ci prefix with short hash - local short_hash - short_hash=$(git -C "$repo_path" rev-parse --short HEAD) - - if [ "${GITHUB_ACTIONS:-}" = "true" ]; then - echo "ci-$short_hash" - else - echo "dev-$short_hash" - fi -} - -rn_app_path=$(pwd) -netbirdPath=$rn_app_path/libs/netbird - -version=$(get_version "${1:-}" "$netbirdPath") - -cd "$netbirdPath" - -echo "Using version: $version" - -#~/go/bin_gomobile_tvos/gomobile init -#~/go/bin_gomobile_tvos/gomobile bind -target=tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK - -gomobile-netbird init -gomobile-netbird bind -target=tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK - -cd - > /dev/null \ No newline at end of file From bd9fe9e8af5d39d63c48d52ecc6b149da551f542 Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Fri, 30 Jan 2026 12:38:24 -0300 Subject: [PATCH 09/11] Rename build-ios-lib.sh back to build-go-lib.sh --- build-ios-lib.sh => build-go-lib.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename build-ios-lib.sh => build-go-lib.sh (87%) diff --git a/build-ios-lib.sh b/build-go-lib.sh similarity index 87% rename from build-ios-lib.sh rename to build-go-lib.sh index 7b73c14..7d1f0dc 100755 --- a/build-ios-lib.sh +++ b/build-go-lib.sh @@ -1,7 +1,7 @@ #!/bin/bash # Script to build NetBird iOS/tvOS bindings using gomobile # -# Usage: ./build-ios-lib.sh [platform] [version] +# Usage: ./build-go-lib.sh [platform] [version] # # Parameters: # 1. platform (optional): Target platform(s) to build for @@ -16,10 +16,10 @@ # - Leading 'v' is stripped from semver tags (v1.2.3 -> 1.2.3) # # Examples: -# ./build-ios-lib.sh # Build both platforms using current commit -# ./build-ios-lib.sh ios # Build iOS only using current commit -# ./build-ios-lib.sh tvos v0.64.1 # Build tvOS only using tag v0.64.1 -# ./build-ios-lib.sh both v0.64.1 # Build both platforms using tag v0.64.1 +# ./build-go-lib.sh # Build both platforms using current commit +# ./build-go-lib.sh ios # Build iOS only using current commit +# ./build-go-lib.sh tvos v0.64.1 # Build tvOS only using tag v0.64.1 +# ./build-go-lib.sh both v0.64.1 # Build both platforms using tag v0.64.1 # # Output: # Creates NetBirdSDK.xcframework in the current directory @@ -90,8 +90,8 @@ get_version() { fi } -rn_app_path=$(pwd) -netbirdPath=$rn_app_path/libs/netbird +project_root=$(pwd) +netbirdPath=$project_root/libs/netbird # Parse arguments platform="${1:-both}" @@ -135,11 +135,11 @@ esac $gomobile_cmd init # Build -CGO_ENABLED=0 $gomobile_cmd bind \ +$gomobile_cmd bind \ -target="$targets" \ -bundleid=io.netbird.framework \ -ldflags="-X github.com/netbirdio/netbird/version.version=$version" \ - -o "$rn_app_path/NetBirdSDK.xcframework" \ + -o "$project_root/NetBirdSDK.xcframework" \ "$netbirdPath/client/ios/NetBirdSDK" cd - > /dev/null From bb141abd573ee52d994b1ebb90f99715f3f811f6 Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Fri, 30 Jan 2026 16:49:45 -0300 Subject: [PATCH 10/11] Adapt build to use submodule --- .github/workflows/build.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae64993..57d027f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,19 +28,22 @@ jobs: uses: actions/checkout@v4 with: repository: netbirdio/netbird - path: netbird + path: ios-client/libs/netbird - name: Setup Go uses: actions/setup-go@v5 with: go-version: '1.24' - cache-dependency-path: netbird/go.sum + cache-dependency-path: ios-client/libs/netbird/go.sum + + - name: Install gomobile + run: go install golang.org/x/mobile/cmd/gomobile@v0.0.0-20251113184115-a159579294ab - name: Install gomobile-netbird run: GOPROXY=direct go install github.com/netbirdio/gomobile-tvos-fork/cmd/gomobile-netbird@latest - name: Add gomobile-tvos-fork to netbird dependencies - working-directory: netbird + working-directory: ios-client/libs/netbird run: go get github.com/netbirdio/gomobile-tvos-fork@latest - name: Debug - List files before xcframework build @@ -51,7 +54,7 @@ jobs: - name: Build NetBirdSDK xcframework working-directory: ios-client - run: ./build-go-lib.sh ../netbird + run: ./build-go-lib.sh both - name: Debug - List files after xcframework build working-directory: ios-client From 653cbad26772a1f1886637f5b102de268de610f1 Mon Sep 17 00:00:00 2001 From: Diego Romar Date: Fri, 30 Jan 2026 17:05:46 -0300 Subject: [PATCH 11/11] Configure build to use the configured submodule commit --- .github/workflows/build.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57d027f..ea69c3f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,12 +23,13 @@ jobs: uses: actions/checkout@v4 with: path: ios-client + submodules: true - - name: Checkout netbird - uses: actions/checkout@v4 - with: - repository: netbirdio/netbird - path: ios-client/libs/netbird +# - name: Checkout netbird +# uses: actions/checkout@v4 +# with: +# repository: netbirdio/netbird +# path: ios-client/libs/netbird - name: Setup Go uses: actions/setup-go@v5