golang/go
GitHub で見るx/mobile: Add support for callback blocks in ObjC reverse bindings with matching Go function signatures
Open
#35,967 opened on 2019年12月4日
FeatureRequestNeedsInvestigationhelp wantedmobile
Repository metrics
- Stars
- (133,883 stars)
- PR merge metrics
- (30d に merged PR はありません)
説明
What version of Go are you using (go version)?
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
What did you do?
Attempted to use a function pointer as a block parameter in ObjC reverse bindings
What did you expect to see?
I hoped it would work
What did you see instead?
Compilation error: implicit type "void" not found
Assume the function:
import (
"ObjC/UserNotifications"
"ObjC/UserNotifications/UNUserNotificationCenter"
)
func testBinding() {
unc := UNUserNotificationCenter.CurrentNotificationCenter()
handler := func(settings *UserNotifications.UNNotificationSettings) {
// TODO
}
unc.GetNotificationSettingsWithCompletionHandler(handler)
}
Getting reference to the UNUserNotificationCenter singleton compiles and works. However, simply referencing the GetNotificationSettingsWithCompletionHandler function causes a compiler error when trying to understand the method signature looking for a completion handler.
GOMOBILE=/Users/dave/go/pkg/gomobile
WORK=/var/folders/4j/j8tb1q2s4kd3rdn0v_hzh_6m0000gn/T/gomobile-work-846542795
GOOS=darwin CGO_ENABLED=1 /Users/dave/go/bin/gobind -lang=go,objc -outdir=$WORK -tags=ios poc/poc
rm -r -f "$WORK"
gomobile: /Users/dave/go/bin/gobind -lang=go,objc -outdir=/var/folders/4j/j8tb1q2s4kd3rdn0v_hzh_6m0000gn/T/gomobile-work-846542795 -tags=ios poc/poc failed: exit status 1
2019/12/04 13:30:59 implicit type "void" not found