react-native: Flipper & RN 0.62 - Build Failed: Use of undeclared identifier 'client'

Description

After upgrading to RN 0.62, I’m not able to build the app due to Flipper error in AppDelegate.m

image

I’m not actually sure what exactly is happening - I’m able to ‘jump to definition’ to every flipper file. Pods seems to be installed properly (I’m using the same pods as defined inside RN Podfile for 0.62 + my native dependencies

React Native version:

System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 1.60 GB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.5.0 - /var/folders/dd/xmqm6lfx7v9gjsdyxjq689l80000gn/T/yarn--1585258712841-0.029739773405819347/node
    Yarn: 1.21.1 - /var/folders/dd/xmqm6lfx7v9gjsdyxjq689l80000gn/T/yarn--1585258712841-0.029739773405819347/yarn
    npm: 6.13.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 27, 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-29 | Google APIs Intel x86 Atom, android-Q | Android TV Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.4/11E146 - /usr/bin/xcodebuild
  Languages:
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: ^0.62.0 => 0.62.0
  npmGlobalPackages:
    *react-native*: Not Found

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 61
  • Comments: 30 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Alright, I got it to build with following this instruction on iOS.

Make sure add this in your Podfile:

# 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
  file_name = Dir.glob("*.xcodeproj")[0]
  app_project = Xcodeproj::Project.open(file_name)
  app_project.native_targets.each do |target|
    target.build_configurations.each do |config|
      cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
      unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
        puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
        cflags << '-DFB_SONARKIT_ENABLED=1'
      end
      config.build_settings['OTHER_CFLAGS'] = cflags
    end
    app_project.save
  end
  installer.pods_project.save
end

After adding this if you do not have any Swift file in your project, you will see some nasty Swift compile error. Just add new Dummy.swift file to the project and click yes to when it asks you to add bridging or whatever.

I have the same problem. what I found is that you need to edit the project.pbxproj file and add this

image

Keep in mind that the structure of that file depends a lot on you project. so what I can tell you is that I searched for DEAD_CODE_STRIPPING = NO; and put the code there.

cd ios; pod repo update; cd ../; yarn; cd ios; pod install;

Alright, I got it to build with following this instruction on iOS.

Make sure add this in your Podfile:

# 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
  file_name = Dir.glob("*.xcodeproj")[0]
  app_project = Xcodeproj::Project.open(file_name)
  app_project.native_targets.each do |target|
    target.build_configurations.each do |config|
      cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
      unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
        puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
        cflags << '-DFB_SONARKIT_ENABLED=1'
      end
      config.build_settings['OTHER_CFLAGS'] = cflags
    end
    app_project.save
  end
  installer.pods_project.save
end

After adding this if you do not have any Swift file in your project, you will see some nasty Swift compile error. Just add new Dummy.swift file to the project and click yes to when it asks you to add bridging or whatever.

I added those and got some problems with swift symbols even tho I added the dummy.swift file and bridging header thing, until I added $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) to library search path and changed Podfile line 71

  target 'yallaLieferRNTests' do
    inherit! :complete
    # Pods for testing
  end

which is in the changes log btw! to https://react-native-community.github.io/upgrade-helper/?from=0.61.5&to=0.62.0

  target 'yallaLieferRNTests' do
    inherit! :search_paths
    # Pods for testing
  end

and it worked!

Make sure you run pod repo update in the ios dir

Also, if you’re blocked and not concerned with flipper right now, in your Podfile you can comment these lines out:

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

Missing this out also fixed my iOS crash on launch after a lot of headache

Screenshot 2020-04-12 at 18 00 12

I.e. https://github.com/react-native-community/upgrade-support/issues/13

For an easy upgrade experience of the Xcode project file, do the following…

@pvinis didn’t turn out to be as easy as it sounds 😄

@villanuevadani Sure, here’s how I got it working just now after upgrading from 0.61.5 to 0.62.2 (in this order):

After trying every solution an producing new errors finally I decided to create a new react native project and then copy the ios folder of newly created project and put it to my current project and also merge my old info.plist, podfile and some assets with new project. and hopefully all of errors gone. 😃

Alright, I got it to build with following this instruction on iOS.

Make sure add this in your Podfile:

# 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
  file_name = Dir.glob("*.xcodeproj")[0]
  app_project = Xcodeproj::Project.open(file_name)
  app_project.native_targets.each do |target|
    target.build_configurations.each do |config|
      cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
      unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
        puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
        cflags << '-DFB_SONARKIT_ENABLED=1'
      end
      config.build_settings['OTHER_CFLAGS'] = cflags
    end
    app_project.save
  end
  installer.pods_project.save
end

After adding this if you do not have any Swift file in your project, you will see some nasty Swift compile error. Just add new Dummy.swift file to the project and click yes to when it asks you to add bridging or whatever.

This should be in the official guide

@A-Tokyo, You should follow this guide https://reactnative.thenativebits.com/courses/upgrading-react-native/upgrade-to-react-native-0.62 and at the same time apply the steps in my comment above. (The tutorial I just sent will redirect to these steps as well)

If you switch to 0.63 immedietly it resolves these issues yes. However I had troubles with android with 0.63.0-rc0

You are welcome ( : Let me know if I can be of any more help

Alright, I got it to build with following this instruction on iOS.

Make sure add this in your Podfile:

# 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
  file_name = Dir.glob("*.xcodeproj")[0]
  app_project = Xcodeproj::Project.open(file_name)
  app_project.native_targets.each do |target|
    target.build_configurations.each do |config|
      cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
      unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
        puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
        cflags << '-DFB_SONARKIT_ENABLED=1'
      end
      config.build_settings['OTHER_CFLAGS'] = cflags
    end
    app_project.save
  end
  installer.pods_project.save
end

After adding this if you do not have any Swift file in your project, you will see some nasty Swift compile error. Just add new Dummy.swift file to the project and click yes to when it asks you to add bridging or whatever.

This helped me. Only thing is that there is no mention how to add that dummy swift file (for us iOS noobs). So here are the instructions for that https://stackoverflow.com/questions/50096025/it-gives-errors-when-using-swift-static-library-with-objective-c-project/56187043#56187043

Hi! I got the same problem in the update from the react-native version V0.61.5 to V0.62.2. A lot of the fixes explained here worked for me, but something keep me bugging my mind, so I created a new empty project and run it, the clean project worked like a charm, but it didn’t had any of this works around presented here. This made me realise that my configuration must have something wrong, so I end up checking some fields and comparing to the newly created clean project. My initial thought it was some bad import or path was wrong in my project, but it end up being a little bit more. This are the stuff that I changed in my project to the same or almost the same values has the clean project:

  • Removed any previous switch Bridging-Header’s (I didn’t need this) don’t forget to check it here (SWIFT_OBJC_BRIDGING_HEADER)
  • Library Search paths
  • Dead Code Stripping
  • Preprocessor Macros (I don’t this is required 😃 )
  • Enable Bitcode
  • Other C Flags
  • OTHER_SWIFT_FLAGS
  • Always Embed Swift Standard Libraries
  • Runpath Search Paths
  • Library Search Paths

Watch out some of this configurations where made in project level and other in target level and there’s a chance that this may not fit your needs or that it isn’t enough since this can change depending on the project it self.

Happy coding!! 😃 🎉

Alright, I got it to build with following this instruction on iOS. Make sure add this in your Podfile:

# 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
  file_name = Dir.glob("*.xcodeproj")[0]
  app_project = Xcodeproj::Project.open(file_name)
  app_project.native_targets.each do |target|
    target.build_configurations.each do |config|
      cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
      unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
        puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
        cflags << '-DFB_SONARKIT_ENABLED=1'
      end
      config.build_settings['OTHER_CFLAGS'] = cflags
    end
    app_project.save
  end
  installer.pods_project.save
end

After adding this if you do not have any Swift file in your project, you will see some nasty Swift compile error. Just add new Dummy.swift file to the project and click yes to when it asks you to add bridging or whatever.

This should be in the official guide

@jvink , I hope so (:. For now, I hope the above comment helps you. This is how I got it to build as well. Just get a new branch with a clean slate, follow this guide and it will work 💪

Also all of this is fixed in rn 0.63 and all RN pods were replaced with a single line acting as a blackbox 🚀

Can’t the upgrade-helper be updated to fix all these above issues? Been trying way too long and still fails builds.

Alright, I got it to build with following this instruction on iOS.

Make sure add this in your Podfile:

# 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
  file_name = Dir.glob("*.xcodeproj")[0]
  app_project = Xcodeproj::Project.open(file_name)
  app_project.native_targets.each do |target|
    target.build_configurations.each do |config|
      cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
      unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
        puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
        cflags << '-DFB_SONARKIT_ENABLED=1'
      end
      config.build_settings['OTHER_CFLAGS'] = cflags
    end
    app_project.save
  end
  installer.pods_project.save
end

After adding this if you do not have any Swift file in your project, you will see some nasty Swift compile error. Just add new Dummy.swift file to the project and click yes to when it asks you to add bridging or whatever.

I tried to follow this guide: https://github.com/react-native-community/upgrade-helper/issues/191 No luck. And then tried @jinshin1013 solution and it worked! Thanks a lot! PS: I did not revert the changes from the guide that I linked.