2
votes

So I've been facing a really weird problem with React Native. I installed a library via Cocoapods for picking images from the camera roll/photo Library and cropping the image as well, it is a silver bullet for this kind of usage. But then, it installs alongside React Native version 11, but this version of React Native was not what I wanted so I had to install React Native via Cocoapods as well so I can have the React Native version I'm using. Now all installed well and if I try to build in my Dev environment everything works fine but when I try to archive, I get the error for duplicate symbols for WebSocket, Image (the library requires you to add RCTImage as a subspec in Cocoapods for React Native), RCTText, etc. basically all the subspecs you're required to add if installing React Native via Cocoapods according to the React Native docs. So I figured I'll need to remove the manually linked libraries from my project, so I did that, but that only resulted in me now having another error when building for dev saying WebSocket, Linking, Network, etc are missing. Basically all the subspecs you're adding via Cocoapods, so I don't understand, if I install React Native and all its subspecs via Cocoapods (I'm also running in the workspace) shouldn't my project use the installed pods and not the linked libraries? I've been on this for like 3 weeks now.

Here is my pods list. enter image description here

Here is my linked binaries list. enter image description here

Please, what do I do? I've been stuck for 3 weeks now, have tried almost any solution online but nothing has changed.

Thanks in advance.

2

2 Answers

2
votes

I have solved the problem, only thing is I think you should use this carefully because I don't fully understand what it does. So within the docs, there is this Cocoapods code snippet that when you add to the Pods file after your target ends resolves this problem. Here is the code snippet.

# very important to have, unless you removed React dependencies for Libraries 
# and you rely on Cocoapods to manage it
post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

If you know exactly what this does please post another answer with this code snippet and an explanation so I can make the answer to the question, or better yet, edit the answer with the explanation, or leave a comment below so I can update my answer. From the looks of the above code snippet, though I'd say this is removing React and it's Subspecs from the installed pods, right after installation, I might be wrong.

Now when you're done with the installation, you'll get another error when you try to build saying react-native or React could not be resolved because it is in multiple locations and that you should delete one of them, to resolve this new error, simply go to the Pods directory and delete the React folder, that is [project-root]/ios/Pods/React once you do this, your application will build for development and also archive for production.

This problem I faced stands as a result of not properly reading installation guides, there may be small discrepancies between how it's usually done and how it's done for the library you're installing, so try and give a little more attention to detail.

0
votes

For me,

  • delete all Link Binary With Libraries (From Build Phase)
  • delete Podfile.lock
  • run pod install
  • Wait for Indexing In Xcode
  • command+shift+k (Clear the project)

build again and fix it.