@@ -44,68 +44,71 @@ echo "Go version: $(go version)"
4444echo " GOPATH: $GOPATH "
4545echo " 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
9599gomobile 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
111114if [ ! -f * .go ]; then
0 commit comments