Search code examples
iosreact-nativelottie

Compilation error after linking lottie-ios


I tried to link lottie-ios but I have a compilation error. Lottie works fine with the android emulator.

Here is what I did: 1. npm i --save [email protected] 2. react-native link lottie-ios 3. react-native link lottie-react-native 4. After this, open the Xcode project configuration and add the Lottie.framework as Embedded Binaries

I have multiple compilation errors starting by this one:

/Users/user/Code/CSULB/CECS_543/anacodiam_ios/node_modules/lottie-react-native/src/ios/../../../react-native/ReactCommon/fabric/graphics/platform/ios/float.h:8:10: fatal error: "limits" file not found
    #include <limits>
    While building module "UIKit" imported from /Users/user/Code/CSULB/CECS_543/anacodiam_ios/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTViewManager.h:8:
    While building module "Foundation" imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
    In file included from <module-includes>:1: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10: fatal error: could not build module "CoreFoundation"
    #include <CoreFoundation/CoreFoundation.h>

My React-native version:

react-native -V
0.57.4

Screenshots Here is my project settings (File > Project Settings): https://i.sstatic.net/h649V.jpg

My general settings: https://i.sstatic.net/FWBUJ.jpg

My Header Search paths: https://i.sstatic.net/svHCV.jpg

I added $(SRCROOT)/../node_modules/react-native/React/ as recommanded in this issue Github

And my build phases: https://i.sstatic.net/p6z99.jpg

Thank you in advance.


Solution

  • As Anhtu said, automatic linking might be broken for lottie. Also, I had the same compilation problem : you should update lottie-react-native to latest version (2.5.9 at this date), they fixed their iOS project header search path setting.

    In version 2.5.8, their project referenced React folder with recursive option, which caused the CodeFoundation build error. (this used to be recommended by ReactNative, but it has changed since : https://facebook.github.io/react-native/docs/linking-libraries-ios) They've removed this header search path since 2.5.9, and now this CoreFoundation error has gone !