allevato / icu-swift

Swift APIs for ICU
Apache License 2.0
25 stars 6 forks source link

Cannot build icu-swift #9

Open davedelong opened 6 years ago

davedelong commented 6 years ago

I was assuming that a simple clone and swift build would get it building.

However, I'm getting a bunch of errors when I try to do so:

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "umbrella.h"
        ^
/Users/dave/Developer/ICU/icu-swift/.build/checkouts/icu4c-swift--3254461296892111381/umbrella.h:20:9: error: 'unicode/icudataver.h' file not found
#import <unicode/icudataver.h>
        ^
/Users/dave/Developer/ICU/icu-swift/Sources/ICU/BidiClass.swift:15:8: error: could not build Objective-C module 'ICU4C'
import ICU4C
...

I've been digging around and can't seem to locate the ICU headers anywhere on my macOS 10.13.3 system.

allevato commented 6 years ago

They aren't distributed by default in Xcode; you'll need to install icu4c from a package manager like Homebrew so that you can reference the headers.

yuriismith commented 6 years ago

@allevato I have performed brew install icu4c on my Ubuntu and when I build project it still says:

Compile Swift Module 'swift_executable' (1 sources)
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "umbrella.h"
         ^
/home/parallels/Documents/Projects/swift-executable/.build/checkouts/icu4c-swift.git--5453144961438204045/umbrella.h:27:9: error: 'unicode/ubiditransform.h' file not found
#import <unicode/ubiditransform.h>
        ^
/home/parallels/Documents/Projects/swift-executable/Sources/swift-executable/main.swift:1:8: error: could not build C module 'ICU4C'
import ICU4C
       ^
error: terminated(1): /home/parallels/usr/bin/swift-build-tool -f /home/parallels/Documents/Projects/swift-executable/.build/debug.yaml main

What can cause it?

allevato commented 6 years ago

@yuriismith Sorry for the extremely late reply. Unfortunately the ICU story on Linux is pretty rough. Each version of Ubuntu tends to be distributed with a different release of ICU, which may have different headers than the one I assumed here.

What's worse is that the system ICU is compiled with renaming enabled, meaning that the function names in the resulting binary have the library version number attached to the end (e.g., u_charAge_59). There are #defines in the headers to make it possible for C code to call them without the suffixes, but Swift's ClangImporter doesn't import those defines, so the only way for Swift to call the functions is to lock into a specific version and attach that suffix everywhere. Or we could provide some kind of shims, but we'd still need shims for every possible ICU version we wanted to use.

There's unfortunately not a good answer to this right now, which is why I started pushing to get more ICU functionality exposed in the standard library directly, such as with SE-0211.