mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-08-02 17:18:36 +02:00
chore(repo): improve contributor experience
This commit is contained in:
+26
-59
@@ -1,78 +1,45 @@
|
||||
#!/bin/bash
|
||||
# Build script for iOS XCFramework
|
||||
# This script compiles the Go backend to XCFramework for iOS
|
||||
# Must be run on macOS with Xcode installed
|
||||
#!/usr/bin/env bash
|
||||
# Build the Go backend XCFramework used by SpotiFLAC Mobile on iOS.
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
GO_BACKEND_DIR="$PROJECT_DIR/go_backend"
|
||||
IOS_DIR="$PROJECT_DIR/ios"
|
||||
OUTPUT_DIR="$IOS_DIR/Frameworks"
|
||||
OUTPUT_DIR="$PROJECT_DIR/ios/Frameworks"
|
||||
|
||||
echo "=== SpotiFLAC iOS Build Script ==="
|
||||
echo "Project directory: $PROJECT_DIR"
|
||||
echo "Go backend directory: $GO_BACKEND_DIR"
|
||||
echo "Output directory: $OUTPUT_DIR"
|
||||
echo "SpotiFLAC Mobile iOS backend build"
|
||||
echo "Project: $PROJECT_DIR"
|
||||
echo "Output: $OUTPUT_DIR"
|
||||
|
||||
# Check if running on macOS
|
||||
if [[ "$(uname)" != "Darwin" ]]; then
|
||||
echo "Error: This script must be run on macOS"
|
||||
exit 1
|
||||
echo "Error: this script must run on macOS with Xcode installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Go is installed
|
||||
if ! command -v go &> /dev/null; then
|
||||
echo "Error: Go is not installed. Please install Go first."
|
||||
exit 1
|
||||
if ! command -v go >/dev/null 2>&1; then
|
||||
echo "Error: Go is not installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Go version: $(go version)"
|
||||
cd "$GO_BACKEND_DIR"
|
||||
go mod download
|
||||
|
||||
# Check if gomobile is installed
|
||||
if ! command -v gomobile &> /dev/null; then
|
||||
echo "Installing gomobile..."
|
||||
go install golang.org/x/mobile/cmd/gomobile@latest
|
||||
go install golang.org/x/mobile/cmd/gobind@latest
|
||||
fi
|
||||
|
||||
# Initialize gomobile (required for iOS builds)
|
||||
echo "Initializing gomobile..."
|
||||
# Running inside the module installs the x/mobile revision pinned by go.mod.
|
||||
go install golang.org/x/mobile/cmd/gomobile
|
||||
export PATH="$(go env GOPATH)/bin:$PATH"
|
||||
gomobile init
|
||||
|
||||
# Create output directory
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
gomobile bind \
|
||||
-target=ios \
|
||||
-tags ios \
|
||||
-o "$OUTPUT_DIR/Gobackend.xcframework" \
|
||||
.
|
||||
|
||||
# Navigate to Go backend directory
|
||||
cd "$GO_BACKEND_DIR"
|
||||
|
||||
# Download dependencies
|
||||
echo "Downloading Go dependencies..."
|
||||
go mod download
|
||||
go mod tidy
|
||||
|
||||
# Build XCFramework for iOS
|
||||
echo "Building XCFramework for iOS..."
|
||||
gomobile bind -target=ios -o "$OUTPUT_DIR/Gobackend.xcframework" .
|
||||
|
||||
# Verify output
|
||||
if [ -d "$OUTPUT_DIR/Gobackend.xcframework" ]; then
|
||||
echo "✅ Successfully built Gobackend.xcframework"
|
||||
echo "Output: $OUTPUT_DIR/Gobackend.xcframework"
|
||||
|
||||
# List architectures
|
||||
echo ""
|
||||
echo "Architectures included:"
|
||||
ls -la "$OUTPUT_DIR/Gobackend.xcframework/"
|
||||
else
|
||||
echo "❌ Failed to build XCFramework"
|
||||
exit 1
|
||||
if [[ ! -d "$OUTPUT_DIR/Gobackend.xcframework" ]]; then
|
||||
echo "Error: Gobackend.xcframework was not created." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Build Complete ==="
|
||||
echo "Next steps:"
|
||||
echo "1. Open ios/Runner.xcworkspace in Xcode"
|
||||
echo "2. Add Gobackend.xcframework to the project"
|
||||
echo "3. Build and run the app"
|
||||
echo "Built $OUTPUT_DIR/Gobackend.xcframework"
|
||||
|
||||
Reference in New Issue
Block a user