I compiled libdispatch. This code is working:
import Dispatch
var lockQueue = dispatch_queue_create("com.test.async", nil);
But if I put this code to end file:
dispatch_async(lockQueue) {
print("test1");
}
I got an error:
use of unresolved identifier 'dispatch_async'
As I commented above, this appears to be a current limitation with the Swift Package Manager. It doesn't currently support the addition of the appropriate compile-time options, such as the ones needed to support blocks as inputs to GCD functions (-Xcc -fblocks
).
In the meantime, you can avoid the Swift Package Manager and compile your files directly using swiftc, with the appropriate options. An example is provided by sheffler in their test repository:
swiftc -v -o gcd4 Sources/main.swift -I .build/debug -j8 -Onone -g -Xcc -fblocks -Xcc -F-module-map=Packages/CDispatch-1.0.0/module.modulemap -I Packages/CDispatch-1.0.0 -I /usr/local/include
The -I
options will pull in your module maps for libdispatch, so adjust those to match where you've actually placed these system module directories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With