Can't compile RxCocoa for Apple Watch

222 views Asked by At

I've been trying to compile an already existing iOS project containing a target for an Apple Watch extension.

The project uses RxSwift/RxCocoa which, reading at the official documentation, is compatible with watchOS.

The project compiles and runs successfully on Apple Watch simulator, but it fails on a real Apple Watch, with the following error:

Cannot find 'CGRectType' in scope
Cannot find 'CGPointType' in scope
Cannot find 'CGSizeType' in scope

The reason of this is that these three constants, declared in a class extension inside RxCocoa, are declared like this:

#if arch(x86_64) || arch(arm64)
    let CGRectType = "{CGRect={CGPoint=dd}{CGSize=dd}}"
    let CGSizeType = "{CGSize=dd}"
    let CGPointType = "{CGPoint=dd}"
#elseif arch(i386) || arch(arm)
    let CGRectType = "{CGRect={CGPoint=ff}{CGSize=ff}}"
    let CGSizeType = "{CGSize=ff}"
    let CGPointType = "{CGPoint=ff}"
#endif

Do you know if there's any way to make it work, as this library is supposed to be compatible with watchOS?

1

There are 1 answers

2
cristallo On

I guess that you are still using am old version of the library (not compatible with recent version of the watchOS)

The right definition on the library should be something like

#if arch(x86_64) || arch(arm64)
    let CGRectType = "{CGRect={CGPoint=dd}{CGSize=dd}}"
    let CGSizeType = "{CGSize=dd}"
    let CGPointType = "{CGPoint=dd}"
#elseif arch(i386) || arch(arm) || arch(arm64_32)
    let CGRectType = "{CGRect={CGPoint=ff}{CGSize=ff}}"
    let CGSizeType = "{CGSize=ff}"
    let CGPointType = "{CGPoint=ff}"
#endif

According to this two discussion thread in the library site

Fix build for new arm64_32 architecture

Xcode 10 GM: Use of unresolved identifier 'CGRectType'

It should be fixed in the latest version of the library