facebook / flipper

A desktop debugging platform for mobile developers.
https://fbflipper.com/
MIT License
13.31k stars 954 forks source link

Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t') when building latest react-native rc with macOS target #834

Closed mgcrea closed 4 years ago

mgcrea commented 4 years ago

🐛 Bug Report

Looks like there is a blocking build issue in flipper that is preventing the new macOS target to work when building with the latest react-native release candidate (0.62.0.rc-3) that embeds flipper.

Exact error:

[...]/SandboxProject_62RC3/ios/Pods/Headers/Private/Flipper-Folly/folly/portability/Time.h:51:17: Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

To Reproduce

npx react-native init SandboxProject_62RC3 --version 0.62.0-rc.3
xed ios/
Screenshot 2020-02-26 at 19 00 47

Expected Behavior

Working build

mweststrate commented 4 years ago

We fixed all known build issues last weeks, so bumping to rc.5 and bumping the Flipper version in your podfile to 0.33.1 should fix the issue. Would you mind verifying?

mgcrea commented 4 years ago

Unfortunately I'm still hitting the same issue, (using rc.5 and bumping Flipper version from 0.30.2 to 0.33.1).

[...]/SandboxProject_62RC5/ios/Pods/Headers/Private/Flipper-Folly/folly/portability/Time.h:51:17: Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')
▶ cat ios/Podfile.lock | grep -i flipper
  - Flipper (0.33.1):
    - Flipper-Folly (~> 2.1)
    - Flipper-RSocket (~> 1.0)
  - Flipper-DoubleConversion (1.1.7)
  - Flipper-Folly (2.1.1):
    - Flipper-DoubleConversion
    - Flipper-Glog
  - Flipper-Glog (0.3.6)
  - Flipper-PeerTalk (0.0.4)
  - Flipper-RSocket (1.0.0):
    - Flipper-Folly (~> 2.0)
  - FlipperKit (0.33.1):
    - FlipperKit/Core (= 0.33.1)
  - FlipperKit/Core (0.33.1):
    - Flipper (~> 0.33.1)
    - FlipperKit/CppBridge
    - FlipperKit/FBCxxFollyDynamicConvert
    - FlipperKit/FBDefines
    - FlipperKit/FKPortForwarding
  - FlipperKit/CppBridge (0.33.1):
    - Flipper (~> 0.33.1)
  - FlipperKit/FBCxxFollyDynamicConvert (0.33.1):
    - Flipper-Folly (~> 2.1)
  - FlipperKit/FBDefines (0.33.1)
  - FlipperKit/FKPortForwarding (0.33.1):
    - Flipper-PeerTalk (~> 0.0.4)
  - FlipperKit/FlipperKitHighlightOverlay (0.33.1)
  - FlipperKit/FlipperKitLayoutPlugin (0.33.1):
    - FlipperKit/Core
    - FlipperKit/FlipperKitHighlightOverlay
    - FlipperKit/FlipperKitLayoutTextSearchable
  - FlipperKit/FlipperKitLayoutTextSearchable (0.33.1)
  - FlipperKit/FlipperKitNetworkPlugin (0.33.1):
    - FlipperKit/Core
  - FlipperKit/FlipperKitReactPlugin (0.33.1):
    - FlipperKit/Core
  - FlipperKit/FlipperKitUserDefaultsPlugin (0.33.1):
    - FlipperKit/Core
  - FlipperKit/SKIOSNetworkPlugin (0.33.1):
    - FlipperKit/Core
    - FlipperKit/FlipperKitNetworkPlugin
  - FlipperKit (~> 0.33.1)
  - FlipperKit/FlipperKitLayoutPlugin (~> 0.33.1)
  - FlipperKit/FlipperKitReactPlugin (~> 0.33.1)
  - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.33.1)
  - FlipperKit/SKIOSNetworkPlugin (~> 0.33.1)
    - Flipper
    - Flipper-DoubleConversion
    - Flipper-Folly
    - Flipper-Glog
    - Flipper-PeerTalk
    - Flipper-RSocket
    - FlipperKit
  Flipper: 6c1f484f9a88d30ab3e272800d53688439e50f69
  Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41
  Flipper-Folly: 2de3d03e0acc7064d5e4ed9f730e2f217486f162
  Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6
  Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
  Flipper-RSocket: 1260a31c05c238eabfa9bb8a64e3983049048371
  FlipperKit: 6dc9b8f4ef60d9e5ded7f0264db299c91f18832e
ouabing commented 4 years ago

I encounter this issue even when not targeting MacOS with react-native 0.62.0.

image

Previous definition is in iOS 13.2 header file iOS 13.2 > usr/include > time.h > clockid_t .

> cat Podfile.lock | grep -i flipper
  - Flipper (0.35.0):
    - Flipper-Folly (~> 2.1)
    - Flipper-RSocket (~> 1.0)
  - Flipper-DoubleConversion (1.1.7)
  - Flipper-Folly (2.1.1):
    - Flipper-DoubleConversion
    - Flipper-Glog
  - Flipper-Glog (0.3.6)
  - Flipper-PeerTalk (0.0.4)
  - Flipper-RSocket (1.0.0):
    - Flipper-Folly (~> 2.0)
  - FlipperKit (0.35.0):
    - FlipperKit/Core (= 0.35.0)
  - FlipperKit/Core (0.35.0):
    - Flipper (~> 0.35.0)
    - FlipperKit/CppBridge
    - FlipperKit/FBCxxFollyDynamicConvert
    - FlipperKit/FBDefines
    - FlipperKit/FKPortForwarding
  - FlipperKit/CppBridge (0.35.0):
    - Flipper (~> 0.35.0)
  - FlipperKit/FBCxxFollyDynamicConvert (0.35.0):
    - Flipper-Folly (~> 2.1)
  - FlipperKit/FBDefines (0.35.0)
  - FlipperKit/FKPortForwarding (0.35.0):
    - Flipper-PeerTalk (~> 0.0.4)
  - FlipperKit/FlipperKitHighlightOverlay (0.35.0)
  - FlipperKit/FlipperKitLayoutPlugin (0.35.0):
    - FlipperKit/Core
    - FlipperKit/FlipperKitHighlightOverlay
    - FlipperKit/FlipperKitLayoutTextSearchable
  - FlipperKit/FlipperKitLayoutTextSearchable (0.35.0)
  - FlipperKit/FlipperKitNetworkPlugin (0.35.0):
    - FlipperKit/Core
  - FlipperKit/FlipperKitReactPlugin (0.35.0):
    - FlipperKit/Core
  - FlipperKit/FlipperKitUserDefaultsPlugin (0.35.0):
    - FlipperKit/Core
  - FlipperKit/SKIOSNetworkPlugin (0.35.0):
    - FlipperKit/Core
    - FlipperKit/FlipperKitNetworkPlugin
  - FlipperKit (~> 0.35.0)
  - FlipperKit/FlipperKitLayoutPlugin (~> 0.35.0)
  - FlipperKit/FlipperKitReactPlugin (~> 0.35.0)
  - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.35.0)
  - FlipperKit/SKIOSNetworkPlugin (~> 0.35.0)
    - Flipper
    - Flipper-DoubleConversion
    - Flipper-Folly
    - Flipper-Glog
    - Flipper-PeerTalk
    - Flipper-RSocket
    - FlipperKit
  Flipper: fec57c9ad921e8153f394980d3169aff51010513
  Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41
  Flipper-Folly: 2de3d03e0acc7064d5e4ed9f730e2f217486f162
  Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6
  Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
  Flipper-RSocket: 1260a31c05c238eabfa9bb8a64e3983049048371
  FlipperKit: 7c830ab52167e33faa1a8aac76834a89e73af08f
kirill-konshin commented 4 years ago

Any workaround? I'm getting same thing Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t') with "react-native": "0.62.0" on a Mac target.

On a side note, error only occurs when running from XCode, it works when I run it like this: xcodebuild -workspace XXX.xcworkspace -configuration Debug -scheme XXX -destination id=XXXX-XXXX"

kesha-antonov commented 4 years ago

Same

ericschaal commented 4 years ago

Same :(

EDIT: Found a quick&dirty workaround Looking a few lines above theclockit_t typedef in Flipper-Foly Time.h

// OSX is a pain. The XCode 8 SDK always declares clock_gettime
// even if the target OS version doesn't support it, so you get
// an error at runtime because it can't resolve the symbol. We
// solve that by pretending we have it here in the header and
// then enable our implementation on the source side so that
// gets linked in instead.
#if __MACH__ &&                                                \
    (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 || \
     __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0)

#ifdef FOLLY_HAVE_CLOCK_GETTIME
#undef FOLLY_HAVE_CLOCK_GETTIME
#endif

#define FOLLY_HAVE_CLOCK_GETTIME 1
#define FOLLY_FORCE_CLOCK_GETTIME_DEFINITION 1

#endif

I changed __IPHONE_10_0 to __IPHONE_12_0 (as my target iOS version is 11) and got it working. I guess the same can be done for MAC_OS_X_VERSION_10_12 to MAC_OS_X_VERSION_10_15 if you are targeting macOS.

passy commented 4 years ago

cc @priteshrnandgaonkar Can you take a look?

cayodonatti commented 4 years ago

Same here for react-native 0.62. Only happens when I change my iOS deployment target from 9.0 to 10.3 (or anything above 9.0). Deployment target change is needed to install some dependencies for my project.

kirill-konshin commented 4 years ago

@cayodonatti in my case even 9.0 fails.

ifsnow commented 4 years ago

In my case, After changing iOS Deployment Target of Flipper-Folly Pods to "iOS 9.0", this error disappeared. time_error

kirill-konshin commented 4 years ago

image image

ifsnow commented 4 years ago

@kirill-konshin Did you change the values of other Pods? Default values are as follows.

Try changing these values, too. I hope it works out.

kirill-konshin commented 4 years ago

Yes, all of them

priteshrnandgaonkar commented 4 years ago

I created a brand new react-native app on version 0.62 and it built successfully and connected to Flipper. I will need more specific repro steps so that I can look into it.

Bytw with 0.62 version RN supports Flipper out of the box. You don't have to do anything, so don't update the podfile's, it is done automatically.

Looking forward for detailed repro steps so that I can look into it.

cayodonatti commented 4 years ago

@priteshrnandgaonkar this is what needs to be changed to repro:

platform :ios, '10.3' # was 9.0
require_relative '../../../node_modules/@react-native-community/cli-platform-ios/native_modules'

def add_flipper_pods!
  version = '~> 0.33.1'
  pod 'FlipperKit', version, :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitLayoutPlugin', version, :configuration => 'Debug'
  pod 'FlipperKit/SKIOSNetworkPlugin', version, :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitUserDefaultsPlugin', version, :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitReactPlugin', version, :configuration => 'Debug'
end

# Post Install processing for Flipper
def flipper_post_install(installer)
  installer.pods_project.targets.each do |target|
    if target.name == 'YogaKit'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.1'
      end
    end
  end
end

target 'v1' do
  # Pods for v1
  pod 'FBLazyVector', :path => "../../../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../../../node_modules/react-native/Libraries/FBReactNativeSpec"

  ...

  use_native_modules!

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  add_flipper_pods!
  post_install do |installer|
    flipper_post_install(installer)

    # this post build is necessary for other dependencies to work, since they use api's not available in 9.0 
    installer.pods_project.targets.each do |t|
      t.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.3'
          config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
      end
    end
  end
end

target 'v1-tvOS' do
  # Pods for v1-tvOS

  target 'v1-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

Also had to change the main project to 10.3

cayodonatti commented 4 years ago

Btw, I maintain my project since react-native 0.55 and this was never an issue. Deployment target version change is needed for a very big amount of libs in the RN ecosystem

priteshrnandgaonkar commented 4 years ago

@cayodonatti I changed the deployment target of the app to 10.3 and it built for me. I just built created the brand new react native app and updated the deployment target.

cayodonatti commented 4 years ago

@priteshrnandgaonkar you need to add the postbuild hook, else it doesn't change the deployment target for the dependencies

installer.pods_project.targets.each do |t|
      t.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.3'
      end
    end
priteshrnandgaonkar commented 4 years ago

@cayodonatti I was able to repro it with your podfile changes. I am looking into it.

priteshrnandgaonkar commented 4 years ago

@cayodonatti Why do you have to update the dependencies to 10.3. Ideally one shouldn't update the deployment target of dependencies, isn't it ?

cayodonatti commented 4 years ago

@priteshrnandgaonkar In my specific case, I have two dependencies that require bumping of deployment targets:

react-native-onesignal react-native-ble-plx

I'm by no means an iOS developer, so I wouldn't know why that's needed. From personal experience, if I do not bump deployment target for all dependencies CocoaPods doesn't let me even install them and complains that some dependencies have different deployment target requirements than the project.

Also, this fix posted above fixes the issue for me:

Same :(

EDIT: Found a quick&dirty workaround Looking a few lines above theclockit_t typedef in Flipper-Foly Time.h

// OSX is a pain. The XCode 8 SDK always declares clock_gettime
// even if the target OS version doesn't support it, so you get
// an error at runtime because it can't resolve the symbol. We
// solve that by pretending we have it here in the header and
// then enable our implementation on the source side so that
// gets linked in instead.
#if __MACH__ &&                                                \
    (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 || \
     __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0)

#ifdef FOLLY_HAVE_CLOCK_GETTIME
#undef FOLLY_HAVE_CLOCK_GETTIME
#endif

#define FOLLY_HAVE_CLOCK_GETTIME 1
#define FOLLY_FORCE_CLOCK_GETTIME_DEFINITION 1

#endif

I changed __IPHONE_10_0 to __IPHONE_12_0 (as my target iOS version is 11) and got it working. I guess the same can be done for MAC_OS_X_VERSION_10_12 to MAC_OS_X_VERSION_10_15 if you are targeting macOS.

Which leads me to think this could be a macro issue.

priteshrnandgaonkar commented 4 years ago

@cayodonatti, there shouldn't be a need to update the deployment targets of dependencies, it feels like the way you are integrating those libraries may not be correct. You can change the platform :ios, '10.3' # was 9.0 to 10.3 and it will work, but changing the iOS deployment target of dependencies seems unnecessary.

cayodonatti commented 4 years ago

@priteshrnandgaonkar I dug up my old code, and found the specific dep that requires iOS 10: https://github.com/Adyen/adyen-ios/blob/master/Adyen.podspec

It's a native pod which I built my own bridge for. Anyway, this does not change the fact that I need to set my project to iOS 10+, since this is a payment thing and is needed for the app functionality.

As I said, with the change above it works as intended.

Edit: just adding to it, it is a very simple bridge which doesn't fiddle with any config on the native part. It's just the Adyen pod that has a strict requirement of iOS 10+, prolly because of some encrypt thing they use which was added later than 9.0.

priteshrnandgaonkar commented 4 years ago

Still I will see if just changing your app's deployment target to 10+ works or not ? I don't think there should be a need to change all the deps to 10+ due to that.

cayodonatti commented 4 years ago

I'll test it and report ASAP. I think I did a bunch of changes at once and didn't test it thoroughly, will do it now.

Thank you very much for the help

kirill-konshin commented 4 years ago

I have installed my project from scratch from template, I have no custom pods or anything special. Yet no matter which target I set I get same error.

image

I commented out this line and got this:

ld: warning: directory not found for option '-L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/usr/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/maccatalyst'
ld: in /xxx/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a(cryptlib.o), building for Mac Catalyst, but linking in object file built for iOS Simulator, file '/xxx/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a' for architecture x86_64
cayodonatti commented 4 years ago

@priteshrnandgaonkar just confirming: the post-install hook is not really needed, and my project just ran fine without it with some minor adjustments. Thank you for your patience and for the help!

Andreychikov-Vasiliy commented 4 years ago

@cayodonatti Can you summarise how to fix issue or do a quick&dirty workaround?

IronTony commented 4 years ago

Yes please. Because Flipper has too many problems on iOS

bensie commented 4 years ago

FWIW my quick-and-dirty workaround is adding this during build phase to patch that file on the fly (we target 11.4):

sed -i '' 's/     __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0/     __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_12_0/' Pods/Flipper-Folly/folly/portability/Time.h
davidlondono commented 4 years ago

I changed Podfile for platform :ios, '10.3' nothing changed the __IPHONE_12_0 nothing Clean build nothing Change projet target to iOS 10.3 nothing

priteshrnandgaonkar commented 4 years ago

I am not able to repro this unless I change the target iOS version of the Flipper dependencies, which shouldn't be necessary. Changing the target iOS version of the Flipper dependency shouldn't be necessary.

If just changing the target iOS version of the app causes the above problem, then please provide me with a reproducible sample. I will take a look, closing this issue till then.

bnolan commented 4 years ago

Commented out that line and it compiled.

//typedef uint8_t clockid_t;
extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts);
extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts);
#endif
0xmtn commented 4 years ago

I have this exact same issue. Here is the stack:

MacOS: 10.15.4
Xcode: 11.4
RN: 0.62.0-rc.5
RN Cli: 4.8.0

iOS app works just fine. But when I select mac as a target build fails.

First it failed with Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t').

Then I commented out the the following line:

//typedef uint8_t clockid_t;
extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts);
extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts);
#endif

Then tried to build again and got the following error:

ld: warning: directory not found for option '-L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/usr/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/maccatalyst'
ld: in /Users/jh/Documents/projects/VST/Trial3/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a(cryptlib.o), building for Mac Catalyst, but linking in object file built for iOS Simulator, file '/Users/jh/Documents/projects/VST/Trial3/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is the default boilerplate app created via react-native init.

Does ReactNative support Project Catalyst at all? If yes, should I do something to properly migrate to mac target?

exotexot commented 4 years ago

Having the same problem. I also want to say that as Flipper was introduced as an integral part of react-native, it only introduced problems.

I'm even using a 3rd-party SDK and Flipper causes issues there. Is there a way to completely strip Flipper out of your RN project?

mweststrate commented 4 years ago

If you are using react-native-flipper, make sure to upgrade to 0.45.

Pretty sure flipper can be stripped out by removing the call to add_flipper_pods and flipper_post_install in your Podfile.

For any further follow up questions, please open a new issue as this one is closed.

baveku commented 4 years ago
sed -i '' 's/     __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0/     __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_12_0/' Pods/Flipper-Folly/folly/portability/Time.h

It's worked

zvs001 commented 4 years ago

Fixed xD

#use_flipper!
#post_install do |installer|
#  flipper_post_install(installer)
#end
sauhardar commented 3 years ago

Fixed xD

#use_flipper!
#post_install do |installer|
#  flipper_post_install(installer)
#end

Are there any drawbacks of commenting out these lines?

zvs001 commented 3 years ago

@sauhardar Many projects have it in Podfile because it comes with react-native tutorial. Most developers don't really use it. So when it creates problem, easier to remove it than search for workarounds.

I didn't get any drawbacks.

OmranElmasry commented 3 years ago

you'll just need to update XCode to latest, it is working on XCode 12.4

hayanisaid commented 3 years ago

For me I had to comment these lines in Podfile and it worked!

#   use_flipper!
#   post_install do |installer|
#     flipper_post_install(installer)
#   end
dpwiese commented 3 years ago

I'd also never previously used Flipper, nor have I spent the time yet to figure out whether I should be using it. 🙂

Simarrajput12 commented 3 years ago

Just comment these lines in Pods file

use_flipper!

post_install do |installer|

flipper_post_install(installer)

end

then run this command cd ios && pod install

kroegen commented 3 years ago

For me I had to comment these lines in Podfile and it worked!

#   use_flipper!
#   post_install do |installer|
#     flipper_post_install(installer)
#   end

One more thing everyone forget to mention: don't forget to update repo

cd ios && pod install --repo-update 

At least this command did the trick for me

danielrangelsa commented 3 years ago

Para mim tive que comentar essas linhas no Podfile e funcionou!

#   use_flipper!
#   post_install do |installer|
#     flipper_post_install(installer)
#   end

Mais uma coisa que todos esquecem de mencionar: não se esqueça de atualizar o repo

cd ios && pod install --repo-update 

Pelo menos este comando funcionou para mim

This works for me! thx bro!

roysG commented 3 years ago

Amazing solution!!

yagudaev commented 3 years ago

Same issue ejected from expo today using:

expo prebuild -p ios

It wouldn't build even after upgrading flipper to the latest 0.87.0. Does flipper support iOS 14.5? Is that the issue.

Commenting out flipper did fix the issue. Would be great to be able to actually use flipper as it seems pretty useful

JustMoze commented 3 years ago

Same issue ejected from expo today using:

expo prebuild -p ios

It wouldn't build even after upgrading flipper to the latest 0.87.0. Does flipper support iOS 14.5? Is that the issue.

Commenting out flipper did fix the issue. Would be great to be able to actually use flipper as it seems pretty useful

I got the same error when upgraded xcode, which now supports iOS 14.5

singh-prabh commented 3 years ago

same issue