A swift implementation of East Asian Width caculator for String, according to EastAsianWidth.txt from UCD 9.0.
import EastAsianWidth
print("\u{6771}".eastAsianLength()) //"東" is Wide, so it will print 2
Take a look at EastAsianWidthTests.swift for the other cases.