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

[🐛] The following Swift pods cannot yet be integrated as static libraries [has workaround / Need Expo instructions to close this] #6332

Closed
2 of 10 tasks
RodolfoGS opened this issue Jun 23, 2022 · 139 comments · Fixed by #6486
Labels
help: needs-triage Issue needs additional investigation/triaging. platform: expo type: bug New bug report

Comments

@RodolfoGS
Copy link

RodolfoGS commented Jun 23, 2022

[UPDATE: we have something that works below, but we need an Expo user to figure out how to correctly set two items in the Podfile in The Expo Way]

Issue

pod install not working with the following error:

[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `FirebaseCoreInternal` depends upon `GoogleUtilities`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

How to reproduce

  1. expo init Test --npm
  2. Select "Bare workflow -> minimal"
  3. cd Test
  4. npm i @react-native-firebase/analytics @react-native-firebase/app
  5. cd ios
  6. pod install
  7. Error appears

If your prefer I created a repo: https://github.com/RodolfoGS/FirebaseCoreInternal-issue

  1. git clone git@github.com:RodolfoGS/FirebaseCoreInternal-issue.git
  2. cd FirebaseCoreInternal-issue/
  3. npm i
  4. cd ios
  5. pod install
  6. Error happens

This happens with all Firebase dependences, I tested with:

  • @react-native-firebase/analytics
  • @react-native-firebase/app
  • @react-native-firebase/crashlytics
  • @react-native-firebase/dynamic-links
  • @react-native-firebase/remote-config

Project Files

Javascript

Click To Expand

package.json:

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@react-native-firebase/analytics": "^15.0.0",
    "@react-native-firebase/app": "^15.0.0",
    "expo": "~45.0.0",
    "expo-splash-screen": "~0.15.1",
    "expo-status-bar": "~1.3.0",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-native": "0.68.2",
    "react-native-web": "0.17.7"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

 OUTPUT GOES HERE
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 15.0.0
  • Firebase module(s) you're using that has the issue:
    • @react-native-firebase/analytics
  • Are you using TypeScript?
    • Y/N & VERSION


@mikehardy
Copy link
Collaborator

(re-posting/moving here, from #6323)

@RodolfoGS thanks posting a repro!

What happens if you affect this:

https://github.com/RodolfoGS/FirebaseCoreInternal-issue/blob/4c626b5cdcac40ec99a1c2b3fead2ae5db61670e/ios/Podfile#L16

Experiments to run:

1- make that line say nothing except use_frameworks! (that is: no linkage stuff after)
2- make that line say use_frameworks! :linkage => :dynamic (note! This should be same result as experiment 1, dynamic is the default)
3- make that line say use_frameworks! :linkage => :static

I'm not sure how exactly you would configure that in Podfile.properties.json so that you are doing it The Expo Way but based on the results of the experiments above we may have a working solution for cocoapods, then (assuming we find one that works) we can back that in to Podfile.properties.json

Note that use_frameworks interacts with Hermes and Flipper and react-native 0.69 with varying degrees of success depending on static or dynamic linkage. See reactwg/react-native-releases#21 (reply in thread) In general you should disable hermes and flipper if you use use_frameworks right now, and you should be on react-native 0.68.2 or lower, 0.69.0 won't work. (0.69.1 will have hermes and 0.69.1 working, but flipper will still not work pending a PR in the area...See reactwg/react-native-releases#23 (reply in thread))

@RodolfoGS
Copy link
Author

Results:

  1. pod install works in demo repo without another library installed, but failed if you install another library, like react-native-google-mobile-ads with the following error:
[!] The 'Pods-Test' target has transitive dependencies that include statically linked binaries: (__path__/Test/ios/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework-Current/GoogleMobileAds.xcframework and __path__/Test/ios/Pods/GoogleUserMessagingPlatform/Frameworks/Release/UserMessagingPlatform.xcframework)
  1. Same result as 1
  2. Same as 1

@mikehardy
Copy link
Collaborator

So that actually seems like 1 will work for react-native-firebase, I think that's a positive result and figuring out how to preserve that result while using the default Expo podfile and making it happen with Podfile.properties.json would be useful as a follow-up.

But now we move back to the other repo (mobile ads) to see what's going on there. I wonder if you reached in to node_modules/react-native-google-mobile-ads/ and tweaked the .podspec file here:

https://github.com/invertase/react-native-google-mobile-ads/blob/5d2048b530b798740c9fed392772568f909dd6b2/RNGoogleMobileAds.podspec#L43-L48

By setting $RNGoogleMobileAdsAsStaticFramework = true in your Podfile if that would let it work 🤔 - that was the solution for react-native-firebase and it appears to be implemented but just not documented in react-native-google-mobile-ads

@mikehardy
Copy link
Collaborator

@RodolfoGS $RNGoogleMobileAdsAsStaticFramework = true in the Podfile then reinstalling pods was the key for me. I reproduce your error when I do not have that set to true, and I build react-native-firebase + react-native-google-mobile-ads (with podspec patch to Google-Mobile-Ads-SDK 9.6.0!) with it.

I don't have time to play with Expo right now, but for Expo people on react-native-firebase:

1- need to determine what to put in Podfile.properties.json so it correctly sets use_frameworks! :linkage => :dynamic

Google Ads needs the Podfile variable set for static builds then it should all work

@RodolfoGS
Copy link
Author

I tested that and react-native-mobile-ads could be installed now with the combination of:

  • googleMobileAds: 9.6.0 +
  • use_frameworks! +
  • $RNGoogleMobileAdsAsStaticFramework = true

But I have problems with another libraries, maybe because they doesn't have the "$RNGoogleMobileAdsAsStaticFramework" hack.

The two libraries that I have the same problem are:

  • react-native-applovin-max
  • react-native-flurry-sdk

But I think that another users could have more issues with another libraries.

In the meanwhile I will stay in 14.11.1

@mikehardy
Copy link
Collaborator

Interesting, you could check their podspec and try to patch it, that variable that we add does a really simple change and it is patch-patchable really trivially as a test...

@mikehardy
Copy link
Collaborator

mikehardy commented Jun 24, 2022

The specific change in the affected libraries is just to add this:

s.static_framework = true

(the s. is a variable in the ruby block, it may be called something different but it is hopefully obvious whatever it is)

@lockieluke

This comment was marked as off-topic.

@mikehardy

This comment was marked as off-topic.

@lockieluke

This comment was marked as off-topic.

@mikehardy

This comment was marked as off-topic.

@nbonatsakis
Copy link

Does anyone know if there is a way to resolve this under the managed workflow using EAS?

@mikehardy
Copy link
Collaborator

@nbonatsakis I'm not sure how to do it in Expo terms but if you can:

  1. determine what to put in Podfile.properties.json so it correctly sets use_frameworks! :linkage => :dynamic

and

  1. figure out how to set $RNFirebaseAsStaticFramework = true

and

  1. set this variable for react-native-google-mobile-ads if you use that:

$RNGoogleMobileAdsAsStaticFramework = true

...and there are no other native libraries to patch then... should work? It's relatively easy to do that in a non-Expo context but I don't have Expo experience so I'm not sure

Otherwise, v14 here is already aging but it was state of the art just a month ago or so, open source is messy and compatibility is difficult but if you can't answer the "how" for 1 and 2 above, someone surely will before too long (I hope!)

@mikehardy mikehardy changed the title [🐛] The following Swift pods cannot yet be integrated as static libraries [🐛] The following Swift pods cannot yet be integrated as static libraries [has workaround / Need Expo instructions to close this] Jun 25, 2022
@nbonatsakis
Copy link

Hmm. I pre-built the project and changed the Podfile to include use_modular_headers! and that seemed to work. I was going to write a quick EAS config plugin to do this modification, any concerns about fixing it that way? (fewer steps).

@mikehardy
Copy link
Collaborator

I'm a very practical person with a strict requirement for automated solutions. If you can automate something that works 100% of the time every time, that works for me and we'll all do a happy dance!

@mikehardy
Copy link
Collaborator

Users have noted, when trying use_frameworks! and react-native 0.69.1 that builds to real devices will fail because the patches in 0.69.1 are incompatible with bitcode. Xcode 14 will deprecate bitcode, so simply disabling it appears to a reasonable solution, then react-native 0.69.1 is accessible in combo with the Podfile variables above

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end

@ahnafnafee
Copy link

ahnafnafee commented Jul 1, 2022

Temporary Workaround: This might be an issue with one of the new versions that was shipped. I was encountering the same error in 15.1.1 (was saying FirebaseCore instead of FirebaseCoreInternal for me) and once I downgraded to 14.11.0, the ios build started working without any issues.

@harterc1
Copy link

harterc1 commented Jul 2, 2022

This fixed it for me:

  1. Add expo-build-properties package
expo add expo-build-properties
  1. Update app.json to include:
{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}

@tux2nicolae
Copy link

Users have noted, when trying use_frameworks! and react-native 0.69.1 that builds to real devices will fail because the patches in 0.69.1 are incompatible with bitcode. Xcode 14 will deprecate bitcode, so simply disabling it appears to a reasonable solution, then react-native 0.69.1 is accessible in combo with the Podfile variables above

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end

mikehardy I have the same issue with bitecode but when i'll use your solution I get another error Undefined symbol: _OBJC_CLASS_$_FIRAnalytics

@mikehardy
Copy link
Collaborator

With apologies I'm traveling right now so haven't had time to do another batch of resolution / developer-experience-smoothing here, or in the related repo where I test things (discussion at mikehardy/rnfbdemo#10)

@mahdieh-dev
Copy link

This might be an issue with one of the new versions that was shipped. I was encountering the same error in 15.1.1 (was saying FirebaseCore instead of FirebaseCoreInternal for me) and once I downgraded to 14.11.0, the ios build started working without any issues.

This works 👍

@mikehardy
Copy link
Collaborator

Downgrading of course works, but that's the same as saying "the new version is a bit difficult so not using it avoids the difficulty", in other words it is a tautology --> 1 = 1. For anyone that needs to do this I do understand, but please pay attention to this issue for progress so you can successfully move on to future version versus being stuck forever on the old stuff

@krishkdev
Copy link

For expo based projects, make sure you have added this line of code in app.json as mentioned in https://rnfirebase.io/#altering-cocoapods-to-use-frameworks :

[
  "expo-build-properties",
  {
    "ios": {
      "useFrameworks": "static"
    }
  }
]

Hope it helps 😊

@yokozawa0701
Copy link

It worked following steps.

  1. I ran it as per the following comments
    [🐛] The following Swift pods cannot yet be integrated as static libraries [has workaround / Need Expo instructions to close this] #6332 (comment)

  2. I executed the following command before build.

$ npx expo prebuild --clean
  1. I built EAS with the following command.
$ npx expo run:ios

Hope it helps.

@blift
Copy link

blift commented Jul 21, 2023

Before you copy and paste some part of pod from above comments:

for example:

pod 'GoogleUtilities', :modular_headers => true

And still it not working on your side, please read again why you build was failed

Each project require different pod's to define. So if your prebuild fail still, please check again the log output what kind of pod's have to be defined in Podfile.

@yaylinda
Copy link

yaylinda commented Nov 30, 2023

Has anyone run into this again? I tried this solution, and a bunch of others like it:

    plugins: [
        '@react-native-firebase/app',
        [
            'expo-build-properties',
            {
                ios: {
                    deploymentTarget: '13.0',
                    useFrameworks: 'static',
                },
            },
        ],
    ],

But I still get the same error message over and over again when I run expo prebuild --clean

Command `pod install` failed.
└─ Cause: The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `FirebaseCoreInternal` depends upon `GoogleUtilities`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

I am using:

  • managed Expo, SDK 49
  • doing dev client build by running: expo prebuild --clean and then expo run:ios --device
  • using these firebase versions:
    "@react-native-firebase/app": "^18.7.1",
    "@react-native-firebase/auth": "^18.7.1",

things were working just fine until i added the @react-native-firebase deps 😢. any help would be very much appreciated! 🙏


UPDATE (~30 min later)

Wowwwwwww... i have literally spend HOURS on this build issue tonight, and have solved it. Apparently, app.json and app.config.js are not interchangeable!!!! (This only relates to Expo Managed builds btw.)

I had all my plugins in app.config.js. On a whim, I decided to move everything over to app.json and just delete app.config.js. THIS FIXED IT!!! Now running expo prebuild --clean works just fine 😤🥲🤦🏻‍♀️😭

@Nantris
Copy link

Nantris commented Jan 23, 2024

@yaylinda thanks for sharing your findings! I wonder if you could share how you managed the EAS secrets with this approach, since the app.json doesn't support environmental variables which seem a necessity to maintain the privacy of our Google Services Files. Or did you have to sacrifice that to make the build process work?

@mrkpatchaa
Copy link

@slapbox I think you can do the other way and move everything to app.config.js

@Nantris
Copy link

Nantris commented Jan 25, 2024

Unfortunately that's what I'm already doing and the build still fails with a related error.

@mrkpatchaa
Copy link

mrkpatchaa commented Jan 26, 2024

Hmmm strange @slapbox .
I have this in my app.config.js
Screenshot 2024-01-26 at 16 48 20
Screenshot 2024-01-26 at 16 48 36

And it's working for me.

My package.json script to prebuild "prebuild": "npx expo prebuild --clean",

@tyeetale
Copy link

tyeetale commented Mar 29, 2024

Has anyone got this working for Expo 50.0.14 & RN 0.73.6? I followed the instructions exactly with app.json looking like:

{
  "expo": {
    "name": "journey",
    "slug": "journey",
    "scheme": "journey",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/public/icon.png",
    "userInterfaceStyle": "dark",
    "splash": {
      "image": "./assets/public/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#000000"
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true,
      "googleServicesFile": "./firebase.plist",
      "bundleIdentifier": "com.test.journey"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/public/adaptive-icon.png",
        "backgroundColor": "#000000"
      },
      "googleServicesFile": "./firebase.json",
      "package": "com.test.journey"
    },
  },
  "plugins": [
    "@react-native-firebase/app",
    "@react-native-firebase/auth",
    [
      "expo-build-properties",
      {
        "ios": {
          "useFrameworks": "static"
        }
      }
    ]
  ]
}

and still seeing:

The Swift pod `FirebaseCoreInternal` depends upon `GoogleUtilities`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

@sg3510
Copy link

sg3510 commented Apr 8, 2024

I still have this issue in expo managed builds - any advice on what to do? my plugins looks exactly the same

@thiago-slb
Copy link

Add use_modular_headers! after your target 'yourproject' do

@Nantris
Copy link

Nantris commented Jun 12, 2024

use_modular_headers is neither recommended nor supported. That said, I'm not really seeing the alternative. Everything I try fails to build when it comes to iOS with React Native Firebase.

@Nantris
Copy link

Nantris commented Jun 12, 2024

@tyeetale did you start any discussion on the Expo issues tracker or their Discord? If so, could you link it here?

@mikehardy
Copy link
Collaborator

@Nantris use_frameworks is a valid build configuration, do a binary search on which other modules you have which you can exclude vs include until you narrow it down to the ones that fail. Make support requests to those modules to fix their issues with what is a valid build configuration or seek out other modules that implement similar functionality but work with a valid build style. The frameworks requirement comes through us from firebase-ios-sdk, which is a different / upstream repo from Google that we just wrap here, it is not possible for us to change it.

@furkantanyol
Copy link

This solved the issue for me
https://github.com/invertase/react-native-firebase/blob/main/docs/index.md#altering-cocoapods-to-use-frameworks

@mtflud
Copy link

mtflud commented Jul 4, 2024

Has anyone run into this again? I tried this solution, and a bunch of others like it:

    plugins: [
        '@react-native-firebase/app',
        [
            'expo-build-properties',
            {
                ios: {
                    deploymentTarget: '13.0',
                    useFrameworks: 'static',
                },
            },
        ],
    ],

But I still get the same error message over and over again when I run expo prebuild --clean

Command `pod install` failed.
└─ Cause: The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `FirebaseCoreInternal` depends upon `GoogleUtilities`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

I am using:

  • managed Expo, SDK 49
  • doing dev client build by running: expo prebuild --clean and then expo run:ios --device
  • using these firebase versions:
    "@react-native-firebase/app": "^18.7.1",
    "@react-native-firebase/auth": "^18.7.1",

things were working just fine until i added the @react-native-firebase deps 😢. any help would be very much appreciated! 🙏

UPDATE (~30 min later)

Wowwwwwww... i have literally spend HOURS on this build issue tonight, and have solved it. Apparently, app.json and app.config.js are not interchangeable!!!! (This only relates to Expo Managed builds btw.)

I had all my plugins in app.config.js. On a whim, I decided to move everything over to app.json and just delete app.config.js. THIS FIXED IT!!! Now running expo prebuild --clean works just fine 😤🥲🤦🏻‍♀️😭

For me it was the other way around. I have the plugins config inside app.json and was forgetting to include that inside my app.config.ts as well:

import { ConfigContext, ExpoConfig } from "@expo/config";

export default ({ config }: ConfigContext): Partial<ExpoConfig> => {
  // ... config overrides

  config.extra = {
    // ... config overrides
    ...config.extra,
    ...config.plugins, // <-- Was missing this spread
  };

  return config;
};

@hmadJutt
Copy link

adding these line ->
use_frameworks! :linkage => :static
$RNFirebaseAsStaticFramework = true

right before -> use_react_native! (in podfile) will fix the issue

@Nagibaba
Copy link

Don't use modular_headers. Just move use_frameworks! :linkage => :static to top right before target 'ApplicationName' do

@ucheNkadiCode
Copy link

ucheNkadiCode commented Aug 30, 2024

@hmadJutt and @Nagibaba - Does this mean if folks are using React Native 75 with Hermes enabled, installing the latest version of RN Firebase 20.4 should work? I lost track of the changes and didn't know if use_frameworks! still causes issues with Hermes and/or the new architecture

Any help is greatly appreciated :D

@Martyneris
Copy link

I am still getting this error in expo.dev when running eas build to make an internal development build :

The Swift pod FirebaseCoreInternaldepends uponGoogleUtilities, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set use_modular_headers!globally in your Podfile, or specify:modular_headers => true for particular dependencies.

I have followed the react-native-firebase setup for expo and added the necessary values to app.config.js :

plugins: [ 'expo-localization', 'expo-font', 'expo-tracking-transparency', '@react-native-firebase/app', '@react-native-firebase/analytics', [ 'expo-build-properties', { ios: { useFrameworks: 'static', ExtraIosPodDependency: { name: 'GoogleUtilities', modular_headers: true, }, extraPods: { name: 'GoogleUtilities', modular_headers: true, }, }, }, ] ]

Also tried using ExtraIosPodDependency and extraPods, but that didn't help.

"expo": "~51.0.31",
"@react-native-firebase/analytics": "^20.4.0",
"@react-native-firebase/app": "^20.4.0",

@ucheNkadiCode
Copy link

ucheNkadiCode commented Aug 31, 2024

I'm on bare metal react native 75.2 and I was able to get Firebase 20.4 to work without modular headers. It also runs on android! Excited to finally be off of RNFB 14.12 🎉

Package JSON

 "@react-native-firebase/analytics": "^20.4.0",
    "@react-native-firebase/app": "^20.4.0",
    "@react-native-firebase/auth": "^20.4.0",
    "@react-native-firebase/crashlytics": "^20.4.0",
    "@react-native-firebase/database": "^20.4.0",
    "@react-native-firebase/messaging": "^20.4.0",
    "@react-native-firebase/storage": "^20.4.0",
    "react": "18.3.1",
    "react-dom": "18.0.0",
    "react-native": "^0.75.2",

My Podfile

# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
 "react-native/scripts/react_native_pods.rb",
 {paths: [process.argv[1]]},
)', __dir__]).strip

# RCT_NEW_ARCH_ENABLED=1 pod install
# pod update or pod install without the flag to restore it
ENV['USE_HERMES'] = '1'
platform :ios, min_ios_version_supported
deployment_target = '13.0'
prepare_react_native_project!
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 'AppName' do
config = use_native_modules!

use_frameworks! :linkage => :static # SUPER IMPORTANT
$RNFirebaseAsStaticFramework = true # SUPER IMPORTANT ALSO

use_react_native!(
 :path => config[:reactNativePath],
 # An absolute path to your application root.
 :app_path => "#{Pod::Config.instance.installation_root}/.."
)

post_install do |installer|
 # https://github.com/facebook/react-native/blob/main/scripts/react_native_pods.rb#L197-L202
 react_native_post_install(
   installer,
   "../node_modules/react-native",
   :mac_catalyst_enabled => false,
   # :ccache_enabled => true
 )
 installer.pods_project.targets.each do |target|
   if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
     target.build_configurations.each do |config|
         config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
         config.build_settings['GCC_NO_COMMON_BLOCKS'] = 'NO'
     end
   end
 end
 installer.generated_projects.each do |project|
   project.targets.each do |target|
       target.build_configurations.each do |config|
           config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
       end
   end
   project.build_configurations.each do |config|
       config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
   end
 end
end
end

@Nantris
Copy link

Nantris commented Aug 31, 2024

That's so interesting! I wonder if there's any potential downsides to this or reason to think it couldn't be used with Expo (via a config plugin.)

Thanks for sharing @ucheNkadiCode!

@Armanoide
Copy link

Armanoide commented Sep 3, 2024

That's so interesting! I wonder if there's any potential downsides to this or reason to think it couldn't be used with Expo (via a config plugin.)

Thanks for sharing @ucheNkadiCode!

for those who looking for expo, here mine

(Expo ~50.0.14)

$RNFirebaseAnalyticsWithoutAdIdSupport=true


require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']

platform :ios, podfile_properties['ios.deploymentTarget'] || '13.4'
install! 'cocoapods',
  :deterministic_uuids => false

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,...), which will be excluded. To fix this,
# you can also exclude `react-native-flipper` in `react-native.config.js`
#
# ```js
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
#   }
# }
# ```
flipper_config = FlipperConfiguration.disabled
if ENV['NO_FLIPPER'] == '1' then
  # Explicitly disabled through environment variables
  flipper_config = FlipperConfiguration.disabled
elsif podfile_properties.key?('ios.flipper') then
  # Configure Flipper in Podfile.properties.json
  if podfile_properties['ios.flipper'] == 'true' then
    flipper_config = FlipperConfiguration.enabled(["Debug", "Release"])
  elsif podfile_properties['ios.flipper'] != 'false' then
    flipper_config = FlipperConfiguration.enabled(["Debug", "Release"], { 'Flipper' => podfile_properties['ios.flipper'] })
  end
end

pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseABTesting', :modular_headers => true
pod 'FirebaseCoreExtension', :modular_headers => true
pod 'FirebaseInstallations', :modular_headers => true
pod 'GoogleDataTransport', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'nanopb', :modular_headers => true
$RNFirebaseAsStaticFramework = true


target 'MyGreatBiggestHugeApp' do
  use_expo_modules!
  config = use_native_modules!

  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
  use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    # Note that if you have use_frameworks! enabled, Flipper will not work if enabled
    :flipper_configuration => flipper_config
  )

  post_install do |installer|
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )

    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|
      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
        resource_bundle_target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
end


@Nantris
Copy link

Nantris commented Sep 13, 2024

Thank you very much for sharing @Armanoide! Are you applying that config with an Expo plugin? Or otherwise how are you keeping it in source control? It's amazing you got this working!

@MatkoMilic
Copy link

This fixed it for me:

  1. Add expo-build-properties package
expo add expo-build-properties
  1. Update app.json to include:
{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}

For me this worked only after implementing it running expo rebuild and then it worked.

@peteasy-git
Copy link

@harterc1 struggling with this problem for several days.. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: needs-triage Issue needs additional investigation/triaging. platform: expo type: bug New bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.