standalone react-native module with cocoapods dependency - ios

I have successfully built a react-native module within a react-native int project. Now I want to extract this module (standalone i.e react-native-my-custom-module) to its own repo, so I can reuse it in other projects and open-source it. I tried using https://github.com/frostney/react-native-create-library to create this standalone react-native module. However, the react-native module has a dependency on external SDK(installed using CocoaPods i.e pod 'Firebase/Core') and due to this, I believe it is Breaking.
What I Tried:
In the standalone Module Repo
Moved module logic(i.e .swift .h(header-bridge), .m) files
added $(SRCROOT)/../../../ios/Pods/** to the Header search Paths
No Pods dependencies(i.e no Podfile, Pods etc)(It made sense to not include Pods in the <react-native-my-custom-module> and instead install Pods in the Project.)
In the Project
yarn add <react-native-my-custom-module>
react-native link <react-native-my-custom-module>
added pod 'Firebase/Core' in Pod file and ran pod install
Tried to Build project but get an error that at the line import firebase Error: No such module 'Firebase'
Additionally, If I comment out the import statement import firebase and the code using the External SDK, the remaining methods and logic in the Native Module works(confirmed with JS).
Update: I also tried to install <react-native-my-custom-module> using CocoaPods instead on react-native link i.e by adding the following in my Project Pod file
pod 'RNCustomModule', path: '../node_modules/MyCustomReactNativeMidule/ios/RNCustomModule.podspec'
The Pods successfully get installed but I still get the same Error: No such module 'Firebase'

Related

The 'Pods runner target has transitive dependencies that include statically linked binaries (Users/..../LibraryX/LibraryX.framework)'

I'm building a Flutter Plugin for a native only available SDK . When it comes to the swift part, I've specified the pod in the .podspec file and now when I try to pod install in the Plugin's example app , I'm getting the above error . If the use_frameworks! is commented in the example app's Podfile , The error disappears but when present the error again arises.Also the same error does not come when putting the pod in the Podfile of the example app even with use_frameworks! directive. But I need to install it through the Plugin's .podspec file. I've also tried using s.static_framework=true and it works but an another error arises which is 'Include of non-modular header inside the framework module(Users/../LibraryA/LibraryA.framework/Headers/Xyz.h)' and couldn't solve this issue too.
What does the error exactly mean? Does it mean that the pod I'm trying to install is itself a static library or does it contain any static libraries as dependency?
Also why it gets installed when trying to install the pod in the Podfile with use_frameworks! but not in the .podspec file?
What are the ways through which I can fix this issue?

Install native iOS pod in flutter

I am facing an error while making a flutter plugin on the iOS side while using pods. The pods are installed successfully then also I am able to import them in the file.
The pod in my case which I am trying to use is Freshchat iOS SDK
Steps I have followed to install the pod
Start a new Flutter plugin project.
In .podspec file add s.dependency 'FreshchatSDK'
Run pod install in example/ios folder.
I got an error
The 'Pods-Runner' target has transitive dependencies that include statically linked binaries: (/Users/nimish/FlutterProjects/freshchat_flutter/freshchat_flutter/example/ios/Pods/FreshchatSDK/FreshchatSDK/libFDFreshchatSDK.a)
I removed use_frameworks! from podfile following this comment .
I ran pod install again and the pods were successfully installed and Pods folder was created which had FreshchatSDK folder in it.
Now I need to have use_frameworks! in my project because other plugins are not compiling because of this.
I added s.static_framework = true in .podspec and use_frameworks! in podfile. Now pod install ran successfully,
After I added the import #import "FreshchatSDK.h" in my Plugin.h file I got the error
error: include of non-modular header inside framework module
I tried this answer but was not able to resolve it.
Please help me resolve this. I'll be respectful of your time.
There is another flutter plugin available here but it has many issues and one unhandled case is making my iOS app crash so I want to make it my own.
There may be problems in the PodFile due to unmatched Targets.
When this happens to me, I used these simple steps.
Delete Podfile
Open Terminal at the specific file
Pod init
Open Podfile and adds Dependencies
Pod install

How can you use cocoapod framework into another cocoapod created locally?

Specifically:
Created a new project
Setup CocoaPods
To the Pod file under Pods I added a dependency (for ex.AlamoFire)
The main app which consumes the pods can import Alamofire
The local cocoapod which I created and added by using the following lines in the podfile:
target 'SomeValue' do
my_own_pod
pod 'CocoaPod_2', :path => '/LocalPath/To/PodSource'
end
Ran pod install and I added the AlamoFire Framework to the CocoaPod_2 under Pods -> General-> CocoaPod_2-> Linked Libraries & Binaries
At this point I was expecting that importing Alamofire in my CocoaPod_2 will work fine but its not.
Screenshot of the workspace :
MyProject.XCWorkspace
|_MyProject.App
|____Source Code files importing CocoaPod_1 (Embedded using CocoaPod)
|____Source Code files importing CocoaPod_2 (Embedded using CocoaPods, local Pod)
|_Pods
|____Podfile
|____Frameworks
|____Pods
|___CocoaPod_1
|___CocoaPod_1 Source Files
|____Source Code for Local Pod
|___CocoaPod_2
|____File contains statement (import cocoapod_1) <---Gives error ld: framework not found
You need to do the following two additional things:
You need to add a Podfile in your CocoaPod_2 followed by a pod install.
Also, you need to define a CocoaPod_2.podspec file in your CocoaPod_2
folder.
If you add Alamofire in both the Podfile and podspec file of CocoaPod_2, you don't need to add in the main app's Podfile. Only adding CocoaPod_2 entry in the app's Podfile will suffice.
I hope that helps!

Pod Install throwing error in terminal for Xcode project

I am trying to install cocoa pods into my project, so followed installation of pod file setup. So, latest pods installed to my system.
When I tried to install pod file to my project throwing following error.
But, pod file create with blank.
I have given following command and getting following error :
MacBook-Pro:Videos username$ pod install
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client projects
[!] Could not automatically select an Xcode workspace. Specify one in your Podfile like so:
workspace 'path/to/Workspace.xcworkspace'
And I tried Pod init also, if I try to open pod file, its showing empty pod file. And not even showing Target which is default pod file setup.
Anyone suggest me, how to fix this.
This is the general approach while installing pod. Make sure you follow these and it should work fine (I am assuming cocoa pods are installed on your system) So your issue lies in one of the following steps:
Go to the project root directory - cd root_directory_path
pod init
Open pod file and add required pods (See library installation guide. Each has one)
pod install
Empty pod does not get created usually. But even if it does, you can just copy the format of pod file contents into your file and install the pod.
As to your empty pod file, reinstall cocoa pods on your system. Also make sure pod is uninstalled from project/workspace you are working on. There might be a faulty installation earlier.

Parse SDK / CocoaPods

I have an objective C iOS app using the Parse SDK.
In the process of moving this app from Parse.com to a self hosted Parse-Server, I need to update the Parse SDK to the latest version. For this update I decided to go with CocoaPods.
This is the first time I touch CocoaPods (after reading and hearing so much good about it).
I found my way, following what I could read here and also based on a few CocoaPods tutorial I quickly viewed.
Having my project "ready", when buiding it I get this error:
#import <ParseUI/ParseUI.h> -----> File not found.
Obviously things have changed place. And I tried a couple of unsuccessful solutions.
So here is my question:
How do I need to change the settings of my project, now that I am using CocoaPods?
In order to use Cocoapods with parse and Parse UI you need to do the following steps:
Create a new file and name it Podfile. This file should be located on your IOS project root folder.
The Podfile should contain at least the following structure if you want to use parse IOS SDK and ParseUI
platform :ios, '8.0'
use_frameworks!
pod 'Parse'
pod 'ParseUI'
# Put more pods in here..
Notice to the platform, you may change it to the minimum version that your app can run on and the use_frameworks! will install all your pod as frameworks and this is mandatory if you like to consume Swift libraries.
Open terminal and navigate to your IOS root directory and enter pod install. This command will install all the pods and dependencies into your project.
After installing you will no longer use the IOS project file from now on you will use a new file which called workspace. The workspace will contain both your project files and the pods project/frameworks files.
Build your project, fix some error (if there are) and run it to make sure that it works as expected .
More CocoaPods commands that you need to know are:
pod update - update all your pods to the latest release or to the release that was mentioned in the Podfile
pod update update specific pod to the latest release or to the release that was mentioned in the Podfile
pod outdated - display out to date pods that are being used inside your project.

Resources