Skip to content

Commit 0608a90

Browse files
committed
fix(ios):Enhance iOS build script with comprehensive error handling and diagnostics
1 parent e1dab6c commit 0608a90

File tree

1 file changed

+56
-9
lines changed

1 file changed

+56
-9
lines changed

openlist-lib/scripts/gobind_ios.sh

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,78 @@ if [ -f ../go.mod ]; then
3131
echo "Fixing iOS incompatible dependencies..."
3232
chmod +x scripts/fix_ios_dependencies.sh
3333
./scripts/fix_ios_dependencies.sh
34+
35+
# Update mobile packages
36+
echo "Updating mobile packages..."
3437
go get -u golang.org/x/mobile/...
3538
go install golang.org/x/mobile/cmd/gobind@latest
3639
go install golang.org/x/mobile/cmd/gomobile@latest
3740

41+
# Reinitialize gomobile
42+
echo "Reinitializing gomobile..."
43+
gomobile clean || true
44+
gomobile init
45+
46+
# Check module dependencies
47+
echo "Checking module dependencies..."
48+
go list -m all | grep mobile || echo "No mobile dependencies found"
49+
50+
# Verify gomobile tools
51+
echo "Verifying gomobile tools..."
52+
which gomobile
53+
which gobind
54+
gomobile version 2>/dev/null || echo "gomobile version failed"
55+
3856
# Set CGO environment for iOS
3957
export CGO_ENABLED=1
4058

4159
# Build for iOS with iOS-specific build tags to exclude incompatible packages
4260
echo "Starting iOS build from module root..."
4361
echo "CGO_ENABLED: $CGO_ENABLED"
4462

63+
# Check what's in the openlistlib directory
64+
echo "Checking openlistlib directory contents:"
65+
ls -la openlistlib/
66+
67+
# Try to build the package first to see if there are any issues
68+
echo "Testing basic build of openlistlib package..."
69+
go build -v ./openlistlib || {
70+
echo "Basic build failed, checking for issues..."
71+
go list -f '{{.ImportPath}}: {{.Error}}' ./openlistlib || true
72+
}
73+
4574
# Use build tags to exclude problematic packages on iOS
46-
gomobile bind -ldflags "-s -w" -v -target="ios" -tags="ios mobile" ./openlistlib 2>&1 | tee ios_build.log || {
75+
echo "Attempting gomobile bind with iOS tags..."
76+
gomobile bind -ldflags "-s -w" -v -target="ios" -tags="ios,mobile" ./openlistlib 2>&1 | tee ios_build.log
77+
78+
# Check the exit status
79+
if [ $? -ne 0 ]; then
4780
echo "Error: gomobile bind failed"
48-
echo "Build log:"
81+
echo "=== Build log ==="
4982
cat ios_build.log 2>/dev/null || echo "No build log available"
83+
echo "=== End build log ==="
84+
85+
# Try to get more specific error information
86+
echo "Checking for specific issues..."
5087

51-
# Try with different build tags to exclude problematic dependencies
52-
echo "Retrying with different build tags..."
53-
gomobile bind -ldflags "-s -w" -v -target="ios" -tags="ios,mobile,!darwin,!cgo" ./openlistlib 2>&1 | tee ios_build_retry.log || {
54-
echo "Retry also failed"
55-
cat ios_build_retry.log 2>/dev/null || echo "No retry log available"
88+
# Check if it's a dependency issue
89+
if grep -q "cannot find package\|no Go files\|build constraints exclude all Go files" ios_build.log; then
90+
echo "Detected dependency or build constraint issues"
91+
92+
# Try with minimal tags
93+
echo "Retrying with minimal build tags..."
94+
gomobile bind -ldflags "-s -w" -v -target="ios" ./openlistlib 2>&1 | tee ios_build_minimal.log
95+
96+
if [ $? -ne 0 ]; then
97+
echo "Minimal build also failed:"
98+
cat ios_build_minimal.log 2>/dev/null || echo "No minimal build log available"
99+
exit 1
100+
fi
101+
else
102+
echo "Unknown build error, exiting"
56103
exit 1
57-
}
58-
}
104+
fi
105+
fi
59106

60107
echo "Listing generated files:"
61108
ls -la *.xcframework 2>/dev/null || echo "No .xcframework files found"

0 commit comments

Comments
 (0)