lugg / react-native-config

Bring some 12 factor love to your mobile apps!
MIT License
4.81k stars 658 forks source link

Issue moving to React Native 0.60.x #363

Open bneigher opened 5 years ago

bneigher commented 5 years ago

It's been a slow and tedious effort for the react native update, seems that there is a roadblock with the ios pod setup.

package.json

{
   ...
   "react-native": "^0.60.3",
   "react-native-config": "^0.11.7",
   ...
}

Podfile

target 'MyApp' do 
  ...
  pod 'react-native-config', :path => '../node_modules/react-native-config'
  ...
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    targets_to_ignore = %w(React)

    if targets_to_ignore.include? target.name
      target.remove_from_project
    end

    if target.name == 'react-native-config'
      phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
      phase.shell_script = "cd ../../"\
                           " && RNC_ROOT=./node_modules/react-native-config/"\
                           " && export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
                           " && export BUILD_DIR=$RNC_ROOT/ios/ReactNativeConfig"\
                           " && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby"

      target.build_phases << phase
      target.build_phases.move(phase,0)
    end
  end
end

Build Path Headers:

Error:

ld: library not found for -lReactNativeConfig clang: error: linker command failed with exit code 1 (use -v to see invocation)

Tried to manually react-native link, no dice. Is anyone else seeing this?

bsonntag commented 5 years ago

I'm also having trouble upgrading because of this module. Manually linking didn't solve it for me either.

marceloch2 commented 5 years ago

@bsonntag The manual link was not working here also, but after a cd android && ./gradlew clean, the command react-native run-android works again.

bsonntag commented 5 years ago

@marceloch2 I have no issues with Android, it's only the iOS build that is failing.

bneigher commented 5 years ago

Update on my keyboard mashing.

I ended up using react-native init and then manually adding the dependencies into my app and the react-native-config issue disappeared. I think this problem is related to stale references to linked dependencies and the root issue is not specific to react-native-config.

While it was time consuming to do brain surgery from my old to new react native project - I think for the 0.5x to 0.6x transition may be a big enough change to do it this way.

GertjanReynaert commented 5 years ago

I had the same issue, but got it solved by removing the preprocessing step like it's described in the diff of this readme change: https://github.com/luggit/react-native-config/commit/1eb6ac01991210ddad2989857359a0f6ee35d734

wynch commented 5 years ago

Are there any plans to release a new version on npm with that bugfix ?

jamalx31 commented 5 years ago

@GertjanReynaert thanks that was the issue, just to add that you need the github master in your package.json not the npm version

edwinwong90 commented 5 years ago

I had the same issue, mine is a bit weird. It works on debug mode but not release mode (Android).

package.json

"react-native": "0.60.4",
"react-native-config": "^0.11.7"

Im using auto-linking. when I ran ENVFILE=.env.prod react-native run-android --variant=release. It did shows "Reading env from: .env.prod"

So weird!!

haithngn commented 5 years ago

react-native link react-native-config

then update Pod for iOS, Gradle Sync for android. It worked for me!

ammichael commented 4 years ago

Happens exactly the same to me. Did you find a solution, @edwinwong90?

MrAlekhin commented 4 years ago

Guys! is there any update for that?

Update IT STARTED WORKING "react-native": "0.61.5", "react-native-config": "^0.12.0" After spending so much time trying to setup Autolink, I said "fuck it"

ShaneMatthias commented 4 years ago

I had the same issue, but got it solved by removing the preprocessing step like it's described in the diff of this readme change: 1eb6ac0

GOD... This saved me! I was stuck on this for days! Thank you for showing me how dumb I can be :)

badsyntax commented 3 years ago

I had the same issue, but got it solved by removing the preprocessing step like it's described in the diff of this readme change: 1eb6ac0

i feel blind and stupid. can anyone link to the code changes in the diff that refer to the preprocessing step?

badsyntax commented 3 years ago

In my case, I was getting the same error on a semi-fresh react-native project when compiling on an Apple M1 chip.

I was able to "resolve" this by excluding the arm64 arch in my podfile. I see this as a workaround, as I don't have a good understanding of why it's failing on the Apple M1:

target 'MyProject' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  use_flipper!({ 'Flipper-Folly' => '2.3.0' })
  post_install do |installer|
    flipper_post_install(installer)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
        config.build_settings['EXCLUDED_ARCHS'] = 'arm64'
        config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
      end
    end
  end
end

I'm not sure if this is the correct approach but it seems to have solved the "ld: library not found for -lReactNativeConfig" error and I can use the library without problems now.