rjeczalik / notify

File system event notification library on steroids.
MIT License
900 stars 128 forks source link

FSEventStreamCreate is not available at ios #223

Open anatol opened 1 year ago

anatol commented 1 year ago

I am trying to compile the package with gomobile for ios platform

gomobile init
gomobile bind -target=ios,iossimulator -x -o My.xcframework

And I get following error, probably because following API is not available at iOS.

<path>/watcher_fsevents_cgo.go:172:9: could not determine kind of name for C.EventStreamCreate
<path>/watcher_fsevents_cgo.go:171:9: could not determine kind of name for C.FSEventStreamContext
<path>/watcher_fsevents_cgo.go:40:12: could not determine kind of name for C.FSEventStreamCreateFlags
<path>/watcher_fsevents_cgo.go:87:27: could not determine kind of name for C.FSEventStreamEventFlags
<path>/watcher_fsevents_cgo.go:88:27: could not determine kind of name for C.FSEventStreamEventId
<path>/watcher_fsevents_cgo.go:178:3: could not determine kind of name for C.FSEventStreamInvalidate
<path>/watcher_fsevents_cgo.go:35:15: could not determine kind of name for C.FSEventStreamRef
<path>/watcher_fsevents_cgo.go:176:2: could not determine kind of name for C.FSEventStreamScheduleWithRunLoop
<path>/watcher_fsevents_cgo.go:177:5: could not determine kind of name for C.FSEventStreamStart
<path>/watcher_fsevents_cgo.go:192:2: could not determine kind of name for C.FSEventStreamStop
<path>/watcher_fsevents_cgo.go:41:19: could not determine kind of name for C.FSEventsGetCurrentEventId
<path>/watcher_fsevents_cgo.go:40:39: could not determine kind of name for C.kFSEventStreamCreateFlagFileEvents
<path>/watcher_fsevents_cgo.go:40:78: could not determine kind of name for C.kFSEventStreamCreateFlagNoDefer
cgo: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang errors for preamble:
<path>/watcher_fsevents_cgo.go:17:8: error: unknown type name 'FSEventStreamRef'
static FSEventStreamRef EventStreamCreate(FSEventStreamContext * context, uintptr_t info, CFArrayRef paths, FSEventStreamEventId since, CFTimeInterval latency, FSEventStreamCreateFlags flags) {
       ^
<path>/watcher_fsevents_cgo.go:17:43: error: unknown type name 'FSEventStreamContext'
static FSEventStreamRef EventStreamCreate(FSEventStreamContext * context, uintptr_t info, CFArrayRef paths, FSEventStreamEventId since, CFTimeInterval latency, FSEventStreamCreateFlags flags) {
                                          ^
<path>/watcher_fsevents_cgo.go:17:109: error: unknown type name 'FSEventStreamEventId'
static FSEventStreamRef EventStreamCreate(FSEventStreamContext * context, uintptr_t info, CFArrayRef paths, FSEventStreamEventId since, CFTimeInterval latency, FSEventStreamCreateFlags flags) {
                                                                                                            ^
<path>/watcher_fsevents_cgo.go:17:161: error: unknown type name 'FSEventStreamCreateFlags'
static FSEventStreamRef EventStreamCreate(FSEventStreamContext * context, uintptr_t info, CFArrayRef paths, FSEventStreamEventId since, CFTimeInterval latency, FSEventStreamCreateFlags flags) {
                                                                                                                                                                ^
<path>/watcher_fsevents_cgo.go:19:9: error: call to undeclared function 'FSEventStreamCreate'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        return FSEventStreamCreate(NULL, (FSEventStreamCallback) gostream, context, paths, since, latency, flags);
               ^
<path>/watcher_fsevents_cgo.go:19:9: note: did you mean 'EventStreamCreate'?
<path>/watcher_fsevents_cgo.go:17:25: note: 'EventStreamCreate' declared here
static FSEventStreamRef EventStreamCreate(FSEventStreamContext * context, uintptr_t info, CFArrayRef paths, FSEventStreamEventId since, CFTimeInterval latency, FSEventStreamCreateFlags flags) {
                        ^
<path>/watcher_fsevents_cgo.go:19:36: error: use of undeclared identifier 'FSEventStreamCallback'; did you mean 'FSEventStreamCreate'?
        return FSEventStreamCreate(NULL, (FSEventStreamCallback) gostream, context, paths, since, latency, flags);
                                          ^~~~~~~~~~~~~~~~~~~~~
                                          FSEventStreamCreate
<path>/watcher_fsevents_cgo.go:19:9: note: 'FSEventStreamCreate' declared here
        return FSEventStreamCreate(NULL, (FSEventStreamCallback) gostream, context, paths, since, latency, flags);
               ^
<path>/watcher_fsevents_cgo.go:19:59: error: expected ')'
        return FSEventStreamCreate(NULL, (FSEventStreamCallback) gostream, context, paths, since, latency, flags);
                                                                 ^
<path>/watcher_fsevents_cgo.go:19:28: note: to match this '('
        return FSEventStreamCreate(NULL, (FSEventStreamCallback) gostream, context, paths, since, latency, flags);
                                  ^
7 errors generated.
ReallyLiri commented 1 year ago

FSEvents is not supported natively on iOS AFAIK, kqueue should work though.

anatol commented 1 year ago

Could notify be updated for that?

ReallyLiri commented 1 year ago

its not up to notify, its not supported by iOS. but kqueue as the notifier should work fine

anatol commented 1 year ago

Sure, could the build constrains be updated accordingly to avoid enabling fsevents on a platform that does not support it?

patryk4815 commented 8 months ago

@ReallyLiri ios can disable with build target. //go:build !ios