-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: iOS with golang static lib webview load failure #7844
Comments
This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed. |
As for a reproduction - however you're loading this Go code would be really helpful. |
Yay, a human! If there's an intent to solve it I am happy to spend some labor. The Go library is using the I believe the Go runtime initialization causes this bug, because it occurred if I only loaded the framework without even invoking a single method from it (unsure if I left the import statements or not - may be a factor as well). But as far as Go code goes, a hello-world dummy should reproduce it. I'm suspecting the empty URL is confusing Foundation to use the wrong code path, even though technically it's allowed. The NSURL sibling API says:
My thinking was the safest option is to simply be more specific when using the URL API, in the case the path is otherwise empty. But, to be fair I don't know if my workaround works in every single case/setup. If it helps, I can pack up a hello-world xcframework and send it your way, in case you don't wanna get dirty with the go toolchain? |
I use Go, and I've used gomobile before in the past. If you want to create a reproduction of a Capacitor app with your framework along with a minimal go project that created the framework I can check it out as well. |
There is a reproduction in #7899, but it uses a very old Capacitor version, so should be updated to Capacitor 7 |
Is this known that golang/go#58225 causes this issue? |
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 7.0.1
@capacitor/core: 7.0.1
@capacitor/android: 7.0.1
@capacitor/ios: 7.0.1
Installed Dependencies:
@capacitor/android: not installed
@capacitor/cli: 7.0.1
@capacitor/core: 7.0.1
@capacitor/ios: 7.0.1
[success] iOS looking great! 👌
Other API Details
Platforms Affected
Current Behavior
I have custom native code to add a gomobile static lib as a framework. When I switched to use my bundled site in
public
for prod, it failed with:This happens in both simulator and physical iPhone (both iOS 18.2).
This error returns exactly one search result: #6974 . It's closed, but nevertheless:
serverUrl
it's not triggeredThe gomobile command used was:
gomobile bind -ldflags="-s" -target ios -tags ios -o ./ios/App/Pld.xcframework
Expected Behavior
Webview should load normally & peacefully.
Project Reproduction
it's not easy to do atm...
Additional Information
I managed to find a workaround through
MyViewController
(see docs for how to set it up). The actual fix is a one-liner, but to set it up is quite tedious, especially if you're not already using a custom view controller.My understanding is that the non-deterministic behavior of
URL(fileURLWithPath:)
occurs when the path is empty. Normally an empty path translates tofile:///
which is equivalent to passing/
.God knows what combination of things causes this to happen, but if Capacitor can avoid this non-determinism perhaps that's an improvement? It certainly is for me (and clearly, whoever posted that other issue). Happy to send a PR if so.
(Obligatory thanks for a great framework. I'm new to mobile dev and I can't thank the contributors enough.)
The text was updated successfully, but these errors were encountered: