How to use react-native link and CocoaPods
Issue #476
React Native comes with a default React library, and most CocoaPods libraries for React Native has React as a dependency pod, which causes the conflict
Issue #476
React Native comes with a default React library, and most CocoaPods libraries for React Native has React as a dependency pod, which causes the conflict
Issue #196
CocoaPods will build and compile our frameworks every time whenever you are doing the clean build or run pod install or pod update for the project.
It will compile the source code of pods during the pod install process, and make CocoaPods use them. Which pod should be compiled is controlled by the flag in Podfile.
Issue #170
I’m using cocoapods 1.6.0.beta.2 in a React Native apps and it has been working fine. The pods that I need is Firebase
and FacebookSDK
. Today after pod install, I got error
1 | NoMethodError - undefined method `real_path' for nil:NilClass |
I then tried running pod deintegrate
to start from scratch, but that command fails as well.
My next try is with cocoapods 1.6.0
and cocoapods 1.6.1
but the problem still persists.
undefined method
in Ruby means that we are calling a method on an object that is nil. I like to track down problems via reading code, but this error is very vague.
Looking thorough at the log, I see CocoaPods has done fetching dependencies, but fails at the integration step, so it must be something wrong with my project file.
Then I trace back commits to project.pbxproj
to see if there’s anything wrong. It turns out that there was a commit that accidentally removes Pods-MyApp Staging.release.xcconfig
from project. That also comes with removal of
1 | baseConfigurationReference = B7FC69316CC27F11022F8A82 /* Pods-MyApp Staging.release.xcconfig */; |
As you know, CocoaPods uses xcconfig
files to declare pod related information like FRAMEWORK_SEARCH_PATHS
, OTHER_LDFLAGS
and other variables like
1 | PODS_BUILD_DIR = ${BUILD_DIR} |
And for a normal pod install
, CocoaPods adds some xcconfig
files to your project, and the path is Pods/Target Support Files/Pods-DeepDiffDemo
. There will always be debug.xcconfig
and release.xcconfig
for each of your project target.
If your project MyApp has a production target called MyApp Production
and MyApp Staging
, then you should have these files
1 | Pods-MyApp Staging.debug.xcconfig |
These are added to projects but not checked to any targets. Just like plist, you don’t need to add xcconfig files to target.
If you go to project Info page, you will see that these xcconfig files are selected
In my case, Pods-MyApp Staging.release.xcconfig
was somehow missing from project, hence all pod commands fail.
The fix is to re-add that file and select that xcconfig in project Info page
Issue #149
We’re using BuddyBuild as our CI. Today one of our dependencies gets a sweat update https://github.com/hyperoslo/BarcodeScanner/releases/tag/4.1.1. So we pod update BarcodeScanner
in one of our projects that depends on it. All is fine when running locally. So I make a Pull Request and wait for the build to kick off in BuddyBuild.
For some reason, BuddyBuild can’t pick up the right version of Cocoapods, hence can’t update the new pods.
1 | [!] The version of CocoaPods used to generate the lockfile (1.3.1) is higher than the version of the current executable (1.1.1). Incompatibility issues may arise. |
So I thought I could run some custom script to force BuddyBuild to update the pods. Start with https://docs.buddybuild.com/builds/custom_build_steps.html
I commit the file buddybuild_postclone.sh
with
1 | #!/usr/bin/env bash |
Didn’t work. I then update the script with
1 | #!/usr/bin/env bash |
Didn’t work. Taking a closer look at the log. I see
1 | Switching CocoaPods version to 1.1.1 |
It seems BuddyBuild is using cocoapods 1.1.1. Mine is 1.4.0.
So I need to specify the correct cocoapods version to make sure I and BuddyBuild are on the same page
1 | gem install bundler |
And in my Gemfile
1 | # frozen_string_literal: true |
Then run
1 | bundler install |
And check Gemfile.lock
to make sure everything is OK
Commit the changes, and now BuddyBuild is picking up the right cocoapods version, hence using the new pods
1 |
|