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

Error when compiling iOS project after Firebase installation #390

Closed
eduardorfreitas93 opened this issue Jun 23, 2023 · 5 comments
Closed
Labels
area:repack The issue is about logic/code inside of Re.Pack. Stale status:confirmed The issue has been reviewed and all necessary information is provided. type:bug A bug report.

Comments

@eduardorfreitas93
Copy link

Environment

dependencies:
"@react-native-firebase/app": "^18.1.0", "@callstack/repack": "^3.2.0", "react-native": "0.70.8"

Lib Firebase https://rnfirebase.io/

Description

There is an error when compiling the project on iOS after installing Firebase. The project was running fine before attempting to install Firebase.

The following build commands failed:
CompileC /Users/user/Library/Developer/Xcode/DerivedData/RepackDemo-cm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/callstack-repack.build/Objects-normal/arm64/ScriptManager.o /Users/user/Documents/rn-repack/RepackDemo/node_modules/@callstack/repack/ios/ScriptManager.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'callstack-repack' from project 'Pods')
(1 failure)

Captura de Tela 2023-06-23 às 14 59 06

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, min_ios_version_supported
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

target 'RepackDemo' do
  config = use_native_modules!

  use_frameworks! :linkage => :static <-- Added this to Firebase.

  pod 'FirebaseCore', :modular_headers => true <-- Added this to Firebase.

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    # :flipper_configuration => flipper_config,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

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

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end
@faropolo
Copy link

Same to me!

@jbroma
Copy link
Member

jbroma commented Jun 26, 2023

Looks like we need to add compatibility with use_frameworks! directive, for now please use this temporary fix:

  # add this inside Podfile, inside your app target
  pre_install do |installer|
    installer.pod_targets.each do |pod|
      if pod.name.eql?('callstack-repack')
        def pod.build_type
          Pod::BuildType.static_library
        end
      end
    end
  end

Please let me know where this allows you to build your app without issues from Re.Pack

@jbroma jbroma added type:bug A bug report. area:repack The issue is about logic/code inside of Re.Pack. status:confirmed The issue has been reviewed and all necessary information is provided. labels Jun 26, 2023
@RafikiTiki
Copy link
Member

I don't know if it'll be possible for us to solve the issue from within Repack. I tried to see how other libraries have tackled this issue, and currently, there isn't a community-wide agreed-upon solution. The most frequently mentioned solution is to change how the Firebase libraries are built into the final app bundle, and it's the only solution that makes it possible to use Firebase libs together with Flipper in the same project.

I would like to add that I'm not a native iOS developer so I might be missing something and it's quite possible that a small configuration change in Repack will make it compatible with apps using use_frameworks! directive and without it as well.

Copy link

github-actions bot commented Dec 6, 2023

This issue has been marked as stale because it has been inactive for 30 days. Please update this issue or it will be automatically closed in 14 days.

@github-actions github-actions bot added the Stale label Dec 6, 2023
Copy link

This issue has been automatically closed because it has been inactive for more than 14 days. Please reopen if you want to add more context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:repack The issue is about logic/code inside of Re.Pack. Stale status:confirmed The issue has been reviewed and all necessary information is provided. type:bug A bug report.
Projects
None yet
Development

No branches or pull requests

4 participants