Undeclared type 'CFMutableBitVector

Hello ,
I'm new to swift. current dev tools swift 4.2 on ubuntu 17.04 using only text mode things no xcode here ..
trying a little code that giving me undclared type when doing swift build
CFMutableBitVector is supposed to be part of foundation but i have no clue why this is giving error

import Foundation
struct CompressedGene {
let length: Int
private let bitVector: CFMutableBitVector

init(original: String) {
    length = original.count
    // default allocator, need 2 * length number of bits
    bitVector = CFBitVectorCreateMutable(kCFAllocatorDefault, length * 2)
    CFBitVectorSetCount(bitVector, length * 2) // fills the bit vector with 0s

}

}

thanks for replying

CFBitVector is part of Core Foundation (CF). CF is a supported API on Apple platforms but on other platforms it’s considered an implementation detail of Foundation. As Foundation doesn’t need CFBitVector, that part of CF never made it across.

See this post and this post by @millenomi.

If I were in your shoes I’d implement my own bit vector as a simple value type, using an array of Bool as the underlying storage. Later on, once you’ve got the rest of your code up and running, you can fix your type to store the data compactly.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

2 Likes