Skip to content

Commit b60203c

Browse files
committed
fix(ios-ci):Implement aggressive gomobile setup with clean environment for iOS builds
1 parent 6a91b13 commit b60203c

File tree

2 files changed

+64
-57
lines changed

2 files changed

+64
-57
lines changed

.github/workflows/build.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,12 @@ jobs:
142142
run: |
143143
cd $GITHUB_WORKSPACE/openlist-lib/scripts
144144
chmod +x *.sh
145-
echo "Initializing gomobile..."
145+
echo "Initializing gomobile for iOS..."
146146
./init_gomobile.sh
147+
echo "Checking Go mobile installation..."
148+
go list -m golang.org/x/mobile 2>/dev/null || echo "mobile module not found"
149+
which gomobile || echo "gomobile not in PATH"
150+
which gobind || echo "gobind not in PATH"
147151
echo "Checking openlistlib directory..."
148152
ls -la ../openlistlib/ || echo "openlistlib directory not found"
149153
echo "Building iOS framework..."

openlist-lib/scripts/gobind_ios.sh

Lines changed: 59 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -44,68 +44,71 @@ echo "Go version: $(go version)"
4444
echo "GOPATH: $GOPATH"
4545
echo "GOROOT: $GOROOT"
4646

47-
# Check and fix gomobile bind dependencies for iOS
48-
echo "Checking gomobile bind dependencies..."
49-
50-
# Check if gobind command is available
51-
if ! command -v gobind &> /dev/null; then
52-
echo "gobind command not found, installing..."
53-
go install golang.org/x/mobile/cmd/gobind@latest || {
54-
echo "Failed to install gobind"
55-
exit 1
56-
}
57-
fi
47+
# Fix gomobile bind dependencies for iOS - aggressive approach
48+
echo "Fixing gomobile bind dependencies for iOS..."
5849

59-
# Go to the module root to install dependencies
60-
if [ -f ../go.mod ]; then
61-
echo "Installing dependencies in module root..."
62-
cd ..
63-
64-
# Install bind packages in the module context
65-
go get golang.org/x/mobile/bind@latest || {
66-
echo "Failed to install golang.org/x/mobile/bind"
67-
exit 1
68-
}
69-
70-
go get golang.org/x/mobile/bind/objc@latest || {
71-
echo "Failed to install golang.org/x/mobile/bind/objc"
72-
exit 1
73-
}
74-
75-
# Ensure all dependencies are downloaded
76-
go mod download
77-
go mod tidy
78-
79-
cd openlistlib
80-
else
81-
echo "No go.mod found, installing packages globally..."
82-
go get golang.org/x/mobile/bind@latest || {
83-
echo "Failed to install golang.org/x/mobile/bind"
84-
exit 1
85-
}
86-
87-
go get golang.org/x/mobile/bind/objc@latest || {
88-
echo "Failed to install golang.org/x/mobile/bind/objc"
89-
exit 1
90-
}
91-
fi
50+
# Set up Go environment explicitly
51+
export GOPATH="${HOME}/go"
52+
export PATH="${GOPATH}/bin:${PATH}"
53+
echo "GOPATH set to: $GOPATH"
54+
echo "PATH updated to include: ${GOPATH}/bin"
9255

93-
# Ensure gomobile is properly initialized for iOS
94-
echo "Re-initializing gomobile for iOS..."
56+
# Clean everything first
57+
echo "Cleaning Go caches and gomobile..."
58+
go clean -cache
59+
go clean -modcache || true
60+
rm -rf "${GOPATH}/pkg/mod/golang.org/x/mobile*" || true
61+
62+
# Save current directory
63+
CURRENT_DIR=$(pwd)
64+
65+
# Create a clean temporary workspace
66+
TEMP_DIR=$(mktemp -d)
67+
echo "Using temporary directory: $TEMP_DIR"
68+
cd "$TEMP_DIR"
69+
70+
# Set up a clean module environment
71+
echo "Setting up clean module environment..."
72+
go mod init temp-gomobile-fix
73+
74+
# Force install all mobile-related packages
75+
echo "Force installing all golang.org/x/mobile packages..."
76+
go get -u golang.org/x/mobile@latest
77+
go get -u golang.org/x/mobile/cmd/gomobile@latest
78+
go get -u golang.org/x/mobile/cmd/gobind@latest
79+
go get -u golang.org/x/mobile/bind@latest
80+
go get -u golang.org/x/mobile/bind/objc@latest
81+
82+
# Install tools to GOPATH/bin
83+
echo "Installing tools to GOPATH/bin..."
84+
go install golang.org/x/mobile/cmd/gomobile@latest
85+
go install golang.org/x/mobile/cmd/gobind@latest
86+
87+
# Return to original directory
88+
cd "$CURRENT_DIR"
89+
rm -rf "$TEMP_DIR"
90+
91+
# Verify tools are in PATH
92+
echo "Verifying tool installation..."
93+
echo "gomobile path: $(which gomobile 2>/dev/null || echo 'NOT FOUND')"
94+
echo "gobind path: $(which gobind 2>/dev/null || echo 'NOT FOUND')"
95+
96+
# Clean and reinitialize gomobile
97+
echo "Reinitializing gomobile..."
98+
gomobile clean 2>/dev/null || true
9599
gomobile init || {
96100
echo "Failed to initialize gomobile"
97-
exit 1
101+
echo "Trying alternative initialization..."
102+
103+
# Try to manually set up gomobile
104+
mkdir -p "${GOPATH}/pkg/gomobile"
105+
gomobile init -ndk="" || {
106+
echo "Alternative initialization also failed"
107+
exit 1
108+
}
98109
}
99110

100-
# Verify bind packages are available
101-
echo "Verifying bind packages..."
102-
if ! go list golang.org/x/mobile/bind >/dev/null 2>&1; then
103-
echo "Warning: golang.org/x/mobile/bind still not available"
104-
fi
105-
106-
if ! go list golang.org/x/mobile/bind/objc >/dev/null 2>&1; then
107-
echo "Warning: golang.org/x/mobile/bind/objc still not available"
108-
fi
111+
echo "Gomobile setup completed"
109112

110113
# Check if this directory has Go files suitable for binding
111114
if [ ! -f *.go ]; then

0 commit comments

Comments
 (0)