Skip to content

Commit d8f08bb

Browse files
committed
add: backward compatibility for <= Xcode15
1 parent 17399b7 commit d8f08bb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ios/Classes/SwiftFlutterSystemProxyPlugin.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,20 @@ public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin {
105105
CFRunLoopStop(CFRunLoopGetCurrent());
106106
}, &context);
107107
let runLoop = CFRunLoopGetCurrent();
108-
CFRunLoopAddSource(runLoop, runLoopSource, CFRunLoopMode.defaultMode);
108+
CFRunLoopAddSource(runLoop, getRunLoopSource(runLoopSource), CFRunLoopMode.defaultMode);
109109
CFRunLoopRun();
110110
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runLoopSource, CFRunLoopMode.defaultMode);
111111
})
112112
}
113113

114+
//For backward compatibility <= XCode 15
115+
static func getRunLoopSource<T>(_ runLoopSource: T) -> CFRunLoopSource {
116+
if let unmanagedValue = runLoopSource as? Unmanaged<CFRunLoopSource> {
117+
return unmanagedValue.takeUnretainedValue()
118+
} else {
119+
return runLoopSource as! CFRunLoopSource
120+
}
121+
}
122+
114123
}
115124

0 commit comments

Comments
 (0)