Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't make an iOS build [0.65.0] #32046

Closed
realtril opened this issue Aug 19, 2021 · 33 comments
Closed

Can't make an iOS build [0.65.0] #32046

realtril opened this issue Aug 19, 2021 · 33 comments
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.

Comments

@realtril
Copy link

realtril commented Aug 19, 2021

Description

This is what i have in my Podfile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '13.2'

target 'Test' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
  end


  pod 'React-Core', :path => '../node_modules/react-native'

end

React Native version:

System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 2.99 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
    Yarn: Not Found
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
    Watchman: 2021.08.02.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0
      System Images: android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7486908
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_292 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: ^0.65.0 => 0.65.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

pod update/pod install/pod install --repo-update

##Problem that i am facing
Screen Shot 2021-08-19 at 11 59 30 AM

Expected Results

App should build without any issues.

@octsiri
Copy link

octsiri commented Aug 19, 2021

Have you try to delete the Podfile.lock and generate it again by pod install?

@realtril
Copy link
Author

Have you try to delete the Podfile.lock and generate it again by pod install?

Yes, of course

@smartameer
Copy link

smartameer commented Aug 19, 2021

@realtril,

pod 'React-Core', :path => '../node_modules/react-native'

In your pod file you have duplicate react-native dependency.
You are already using use_react_native which will add React-Core Pod. No need to specify explicitly. Remove the above line and it will work.

@luism3861
Copy link
Contributor

luism3861 commented Aug 19, 2021

Have you try to delete the Podfile.lock and generate it again by pod install?

You should never delete Podfile.lock.

@realtril
Copy link
Author

realtril commented Aug 19, 2021

@smartameer have slightly updated Podfile due to your comment and deployment_target I receive
but now i have this problem while building

Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

IOS_VERSION = '11.0'

platform :ios, '11.0'

target 'test' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

   # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!({ 'Flipper' => '0.92.0', 'Flipper-Folly' => '2.6.7',  'Flipper-RSocket' => '1.4.3' })


  post_install do |installer|
    react_native_post_install(installer)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      end
    end

  end

end

@YaoHuiJi
Copy link

@smartameer have slightly updated Podfile due to your comment and deployment_target I receive
but now i have this problem while building

Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

IOS_VERSION = '11.0'

platform :ios, '11.0'

target 'test' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

   # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!({ 'Flipper' => '0.92.0', 'Flipper-Folly' => '2.6.7',  'Flipper-RSocket' => '1.4.3' })


  post_install do |installer|
    react_native_post_install(installer)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      end
    end

  end

end

just the same build error after I upgrade RN from 0.64.0 to 0.65.0, changing deployment target of RCT-Folly does not work, only show this error

Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

@john-dufrene-dev
Copy link

Same error with fresh 0.65 version and xcode 12.5, RCT-FOLLY problem as mentionned before, impossible to build for release

@mikehardy
Copy link
Contributor

Changing iPHONEOS_DEPLOYMENT_TARGET is an anti-pattern at this point.
Stop changing that build setting. Remove that part from your post-install.

@daveslutzkin
Copy link

daveslutzkin commented Aug 19, 2021

@realtril @YaoHuiJi @john-dufrene-dev fix for me was as described here:

facebook/flipper#834 (comment)

Basically you need to make sure that the deployment target for RCT-Folly stays at 9.0, but the comments there describe it better than me.

@daveslutzkin
Copy link

@mikehardy I think we started changing iPHONEOS_DEPLOYMENT_TARGET because otherwise we get warnings from Xcode. Have the warnings gone away or are they just bogus?

@john-dufrene-dev
Copy link

@daveslutzkin thanks for your answer, could you explain how to change that, I'm new with react native, thanks in advance

@realtril
Copy link
Author

realtril commented Aug 19, 2021

@realtril @YaoHuiJi @john-dufrene-dev fix for me was as described here:

facebook/flipper#834 (comment)

Basically you need to make sure that the deployment target for RCT-Folly stays at 9.0, but the comments there describe it better than me.

should i do something like that? @mikehardy @daveslutzkin

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'


platform :ios, '11.0'

target 'test' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  use_flipper!({ 'Flipper' => '0.92.0', 'Flipper-Folly' => '2.6.7',  'Flipper-RSocket' => '1.4.3' })

  post_install do |installer|
    react_native_post_install(installer)
    case target.name
    when 'RCT-Folly'
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
      end
    end

  end

end

@mikehardy
Copy link
Contributor

The warnings are still there, they are not bogus, but neither are they important.
The warnings are saying "hey, your iOS minimum for your apps is higher than your libraries"
Does that matter? Not at all.
Is it noisy? Yes.
Ask me how I know: I had this post_install, to quiet the noise, it was nice. But then the build started breaking like this, so I removed the post_install change, the build works, my logs are noisy again.

Build working >> noise 🤷

@mikehardy
Copy link
Contributor

My take on it now is: if it's possible that some libraries have version dependent behavior, and I was just trying to quiet noise but they actually depend on their build settings not changing, do I really know more than all the library authors? I do not. I should probably leave their build settings alone.

@john-dufrene-dev
Copy link

This is my change as mentionned on previous comment :

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'

target 'default' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

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

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!({ 'Flipper' => '0.92.0', 'Flipper-Folly' => '2.6.7',  'Flipper-RSocket' => '1.4.3' })

  post_install do |installer|
    react_native_post_install(installer)

    installer.pods_project.targets.each do |target|  
      case target.name
      when 'RCT-Folly'
        target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
        end
      end
    end
  end
end

With debug mode it's working, but when trying to build for release I have this error, if someone have an idea how to resolve that, I'm on a clean react-native project with xcode 12.5

Capture d’écran 2021-08-19 à 23 28 06

@daveslutzkin
Copy link

daveslutzkin commented Aug 19, 2021

@john-dufrene-dev

@daveslutzkin thanks for your answer, could you explain how to change that, I'm new with react native, thanks in advance

If your Podfile has a section that says something like this:

post_install do |installer|
  react_native_post_install(installer)
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
    end
  end
end

Then either:

  • Remove the section:
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
    end
  end

Or make it:

post_install do |installer|
  react_native_post_install(installer)
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
    end
  end
  case target.name
    when 'RCT-Folly'
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
      end
    end
  end
end

@YaoHuiJi
Copy link

YaoHuiJi commented Aug 20, 2021

thanks, but no luck for me too, everything works well in debug mode, but not release mode, I changed the Podfile but got another error as @john-dufrene-dev mentioned above
Thread-local storage is not supported for the current target

I have checked the IPHONEOS_DEPLOYMENT_TARGET of "RCT_Folly" in xcode, it's 9.0.

also I have a warning when I run "pod install"
[!] FBReactNativeSpec has added 1 script phase. Please inspect before executing a build. See https://guides.cocoapods.org/syntax/podspec.html#script_phases for more information.
I just ignore it, don't know if it's the reason I got the error Thread-local storage is not supported for the current target

@mikehardy
Copy link
Contributor

If you just do npx react-native init TestProject && cd TestProject && yarn ios it works, right?

Don't worry about the cocoapods warning about adding FBReactNativeSpec, that's normal. That's cocoapods warning you that a script was added, in case you have security concerns with the script.

In this case, it's a necessary part of react-native iOS compiling, so it's good to be aware (thanks Cocoapods!) but it's not a problem.

@luism3861
Copy link
Contributor

If you just do npx react-native init TestProject && cd TestProject && yarn ios it works, right?

Don't worry about the cocoapods warning about adding FBReactNativeSpec, that's normal. That's cocoapods warning you that a script was added, in case you have security concerns with the script.

In this case, it's a necessary part of react-native iOS compiling, so it's good to be aware (thanks Cocoapods!) but it's not a problem.

I always disabled flipper because has a lot of issues when you create a new project mostly version cocoa pods etc etc it is a good idea?

@mikehardy
Copy link
Contributor

I think it used to be. I did the same. Now it appears that chunks of it are integral to the react-native build for iOS. I no longer think it can easily be avoided.

@smartameer
Copy link

smartameer commented Aug 20, 2021

@realtril this helped me,
After tweaking post_install it built successfully. I have commented some code, enable and try out if that works for you. For me enabling or disabling has the same affect.

and not to say but delete Pods, Podfile.lock before installing again
If it fails, try to build via xcode and paste error.

# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# use_flipper!()

post_install do |installer|
  react_native_post_install(installer)
  installer.pods_project.targets.each do |target|
    # if target.name == "React"
    #   target.remove_from_project
    # end
    # target.build_configurations.each do |config|
    #   config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
    # end
    if (target.name&.eql?('FBReactNativeSpec'))
      target.build_phases.each do |build_phase|
        if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
          target.build_phases.move(build_phase, 0)
        end
      end
    end
  end
end

@luism3861
Copy link
Contributor

image

delete flipper in Podfile file, delete Pods and then install again pod install, clean your Xcode and run again your app

@Noitham
Copy link

Noitham commented Aug 23, 2021

In my case, the issue still exists even though removing flipper

@mikehardy
Copy link
Contributor

Parts of flipper are still included now no matter what in react-native 0.65 especially if you want hermes on ios.

Here's my full set of hacks.

  post_install do |installer|
    react_native_post_install(installer)

    # Apple Silicon builds require a library path tweak for Swift library discovery or "symbol not found" for swift things
    installer.aggregate_targets.each do |aggregate_target| 
      aggregate_target.user_project.native_targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
        end
      end
      aggregate_target.user_project.save
    end

     # Flipper requires a crude patch to bump up iOS deployment target, or "error: thread-local storage is not supported for the current target"
    # I'm not aware of any other way to fix this one other than bumping iOS deployment target to match react-native (iOS 11 now)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
       end
    end

    # ...but if you bump iOS deployment target, Flipper barfs again "Time.h:52:17: error: typedef redefinition with different types"
    # We need to make one crude patch to RCT-Folly - set `__IPHONE_10_0` to our iOS target + 1
    # https://github.com/facebook/flipper/issues/834 - 84 comments and still going...
    `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
  end

@ryanSN
Copy link

ryanSN commented Sep 29, 2021

This is what I had to do to get it all to work with Xcode 13, React Native 0.65.0 Also did a upgrade from 0.61.2
Commented out use_flipper!() but still got the RCT-Folly error, this allows the app to build and go on a ios 15 sim.

post_install do |installer|
    react_native_post_install(installer)

    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
        case target.name
        when 'RCT-Folly'
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
        end
      end

      if (target.name&.eql?('FBReactNativeSpec'))
        target.build_phases.each do |build_phase|
          if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
            target.build_phases.move(build_phase, 0)
          end
        end
      end
    end
  end

@YaoHuiJi
Copy link

YaoHuiJi commented Oct 3, 2021

I tried 0.66 today, now everything works even with default Podfile, you do not need those changes mentioned in this issue and you can enable Flipper too. a big thanks to all developers💗

@mikehardy
Copy link
Contributor

@fkgozali this is closable

@fkgozali
Copy link
Contributor

fkgozali commented Oct 4, 2021

closing since we have addressed this in the latest release

@fkgozali fkgozali closed this as completed Oct 4, 2021
@realtril
Copy link
Author

realtril commented Oct 19, 2021

hi @YaoHuiJi ! since you have already successfully updated to 0.66, could you please show what you have in a Podfile?

@YaoHuiJi
Copy link

@realtril here is my Podfile, I replaced the target name to 'xxx', no other changes. I use realm-js, so I have to disable hermes.

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'

target 'xxx' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
  pod 'Permission-PhotoLibraryAddOnly', :path => "#{permissions_path}/PhotoLibraryAddOnly"

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

   # Enables Flipper.
   #
   # Note that if you have use_frameworks! enabled, Flipper will not work and
   # you should disable these next few lines.
   #use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })
   use_flipper!()

   post_install do |installer|
     react_native_post_install(installer)
     __apply_Xcode_12_5_M1_post_install_workaround(installer)
   end
end

@realtril
Copy link
Author

@YaoHuiJi thank you!

@realtril
Copy link
Author

@YaoHuiJi please also show what you in build.gradle and app/build.gradle

@YaoHuiJi
Copy link

@YaoHuiJi please also show what you in build.gradle and app/build.gradle

Sorry, I'm just working on the iOS version right now

@facebook facebook locked as resolved and limited conversation to collaborators Oct 4, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests