React-native: Cannot build React Native 0.55.3 with Xcode 8 due to RCTLayout typedefs

Created on 19 Apr 2018  路  11Comments  路  Source: facebook/react-native

Environment

Environment:
  OS: macOS Sierra 10.12.6
  Node: 9.11.1
  Yarn: 1.5.1
  npm: 5.6.0
  Watchman: 4.7.0
  Xcode: Xcode 8.3.2 Build version 8E2002
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: ^16.3.2 => 16.3.2
  react-native: ^0.55.3 => 0.55.3

Steps to Reproduce

Either build the project with xcode using yarn run react-native run-ios or build the project in Xcode.

Expected Behavior

A successful build.

Actual Behavior

The build fails on a few RCTLayout typedefs.

In file included from /[redacted]/node_modules/react-native/React/Views/RCTShadowView+Internal.m:8:
In file included from /[redacted]/node_modules/react-native/React/Views/RCTShadowView+Layout.h:10:
In file included from /[redacted]/node_modules/react-native/React/Views/RCTShadowView.h:11:
/[redacted]/node_modules/react-native/React/Views/RCTLayout.h:30:43: error: expected ';' after top level declarator
typedef struct CG_BOXABLE RCTLayoutMetrics RCTLayoutMetrics;
                                          ^
                                          ;
/[redacted]/node_modules/react-native/React/Views/RCTLayout.h:30:44: warning: declaration does not declare anything [-Wmissing-declarations]
typedef struct CG_BOXABLE RCTLayoutMetrics RCTLayoutMetrics;
                                           ^~~~~~~~~~~~~~~~
/[redacted]/node_modules/react-native/React/Views/RCTLayout.h:37:43: error: expected ';' after top level declarator
typedef struct CG_BOXABLE RCTLayoutContext RCTLayoutContext;
                                          ^
                                          ;
/[redacted]/node_modules/react-native/React/Views/RCTLayout.h:37:44: warning: declaration does not declare anything [-Wmissing-declarations]
typedef struct CG_BOXABLE RCTLayoutContext RCTLayoutContext;
                                           ^~~~~~~~~~~~~~~~
/[redacted]/node_modules/react-native/React/Views/RCTLayout.h:39:74: error: variable has incomplete type 'RCTLayoutMetrics' (aka 'struct CG_BOXABLE')
static inline BOOL RCTLayoutMetricsEqualToLayoutMetrics(RCTLayoutMetrics a, RCTLayoutMetrics b)
                                                                         ^
/[redacted]/node_modules/react-native/React/Views/RCTLayout.h:30:16: note: forward declaration of 'struct CG_BOXABLE'
typedef struct CG_BOXABLE RCTLayoutMetrics RCTLayoutMetrics;
               ^
/[redacted]/node_modules/react-native/React/Views/RCTLayout.h:39:94: error: variable has incomplete type 'RCTLayoutMetrics' (aka 'struct CG_BOXABLE')
static inline BOOL RCTLayoutMetricsEqualToLayoutMetrics(RCTLayoutMetrics a, RCTLayoutMetrics b)
                                                                                             ^
/[redacted]/node_modules/react-native/React/Views/RCTLayout.h:30:16: note: forward declaration of 'struct CG_BOXABLE'
typedef struct CG_BOXABLE RCTLayoutMetrics RCTLayoutMetrics;
               ^
/[redacted]/node_modules/react-native/React/Views/RCTLayout.h:39:74: warning: unused parameter 'a' [-Wunused-parameter]
static inline BOOL RCTLayoutMetricsEqualToLayoutMetrics(RCTLayoutMetrics a, RCTLayoutMetrics b)
                                                                         ^
/[redacted]/node_modules/react-native/React/Views/RCTLayout.h:39:94: warning: unused parameter 'b' [-Wunused-parameter]
static inline BOOL RCTLayoutMetricsEqualToLayoutMetrics(RCTLayoutMetrics a, RCTLayoutMetrics b)

                                                                                           ^
4 warnings and 4 errors generated.

There are two reproductions of the same problem in #18793 (by @DarkSector and @f3ist), but since the title of that issue is incorrect (it fails in the Xcode GUI as well as on the command line), the original reproduction case is messy due to third-party dependencies, and an old version of RN is used, I decided to create a new issue.

Locked

Most helpful comment

Guys, if you're using cocoapods in your projects, just try to renew your pods

All 11 comments

Same issue for me.

Environment:
  OS: macOS X El Capitan 10.11.6
  Node: 8.11.1
  npm: 6.0.0
  Watchman: 4.9.0
  Xcode: Xcode 8.2.1 Build version 8C1002
Packages: (wanted => installed)
react-native-cli: 2.0.1
  react-native: ^0.55.3 => 0.55.3

THE ERROR MESSAGE I GET:
/Users//Desktop/AwesomeProject/node_modules/react-native/React/Views/RCTLayout.h:30:44: warning: declaration does not declare anything [-Wmissing-declarations]
typedef struct CG_BOXABLE RCTLayoutMetrics RCTLayoutMetrics;
^~~~
/Users//Desktop/AwesomeProject/node_modules/react-native/React/Views/RCTLayout.h:37:43: error: expected ';' after top level declarator
typedef struct CG_BOXABLE RCTLayoutContext RCTLayoutContext;
^
;
/Users//Desktop/AwesomeProject/node_modules/react-native/React/Views/RCTLayout.h:37:44: warning: declaration does not declare anything [-Wmissing-declarations]
typedef struct CG_BOXABLE RCTLayoutContext RCTLayoutContext;
^~~~
/Users//Desktop/AwesomeProject/node_modules/react-native/React/Views/RCTLayout.h:39:74: error: variable has incomplete type 'RCTLayoutMetrics' (aka 'struct CG_BOXABLE')
static inline BOOL RCTLayoutMetricsEqualToLayoutMetrics(RCTLayoutMetrics a, RCTLayoutMetrics b)
^
/Users//Desktop/AwesomeProject/node_modules/react-native/React/Views/RCTLayout.h:30:16: note: forward declaration of 'struct CG_BOXABLE'
typedef struct CG_BOXABLE RCTLayoutMetrics RCTLayoutMetrics;

  ^

/Users//Desktop/AwesomeProject/node_modules/react-native/React/Views/RCTLayout.h:39:94: error: variable has incomplete type 'RCTLayoutMetrics' (aka 'struct CG_BOXABLE')
static inline BOOL RCTLayoutMetricsEqualToLayoutMetrics(RCTLayoutMetrics a, RCTLayoutMetrics b)
^
/Users//Desktop/AwesomeProject/node_modules/react-native/React/Views/RCTLayout.h:30:16: note: forward declaration of 'struct CG_BOXABLE'
typedef struct CG_BOXABLE RCTLayoutMetrics RCTLayoutMetrics;
^
/Users//Desktop/AwesomeProject/node_modules/react-native/React/Views/RCTLayout.h:39:74: warning: unused parameter 'a' [-Wunused-parameter]
static inline BOOL RCTLayoutMetricsEqualToLayoutMetrics(RCTLayoutMetrics a, RCTLayoutMetrics b)
^
/Users//Desktop/AwesomeProject/node_modules/react-native/React/Views/RCTLayout.h:39:94: warning: unused parameter 'b' [-Wunused-parameter]
static inline BOOL RCTLayoutMetricsEqualToLayoutMetrics(RCTLayoutMetrics a, RCTLayoutMetrics b)
^
4 warnings and 4 errors generated.

* BUILD FAILED *

The following build commands failed:
CompileC /Users//Desktop/AwesomeProject/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTShadowView+Internal.o Views/RCTShadowView+Internal.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/AwesomeProject.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/AwesomeProject.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

I solved this issue by upgrading to High Sierra and upgrading XCode to latest.

I didn't upgrade to High Sierra, but installed the latest version compatible with Sierra, XCode 9.2. It can be downloaded here.

I cant upgrade to sierra (macbook pro late 2009), so how to solve it?

this is due to the newer version of react native use some new feature of xcode sdk, it should fixed when upgrade new version xcode in theory,

So it also means 0.55 documentation is wrong because it said "If you have already installed Xcode on your system, make sure it is version 8 or higher."

Guys, if you're using cocoapods in your projects, just try to renew your pods

Closing as resolved. Please use Xcode 9.

This can easily be fixed by using a custom macro in the form of

#if __has_attribute(objc_boxable)
#define RCT_BOXABLE __attribute__((objc_boxable))
#else
#define RCT_BOXABLE
#endif

@hramos ^

@stephenkopylov renewing the pods fixed my issue!! Thanks..

Was this page helpful?
0 / 5 - 0 ratings