How to get `react-native link` to link my library via Cocoapods? - ios

I am writing a new library for React Native that uses native components for iOS and Android. It depends on another native library via Cocoapods, and contains a .podspec file. When I try to link it to a test project using react-native link, it successfully adds the source project as a library, but doesn't install the dependency via Cocoapods.
It looks like there are ways to customize the link behavior via rnpm keys in the package.json file, but I can't find any info on what those should be (it's also unclear if those are used by the newer link command, or are a holdover from the actual rnpm days.) If there are docs on that that you know of, please pass them along!
Otherwise, my main question is this: how can I get react-native link to install my dependency via Cocoapods, or do I need to reinvent that wheel?
Thanks in advance!

Related

Do I still need CocoaPod installation?

I am new to XCode and Swift. Trying to create a simple project that uses MQTT protocol. For that, there is a Swift library CocoaMQTT and there are directions on how to integrate it in an XCode project:
Installation
To integrate CocoaMQTT into your Xcode project using CocoaPods,
you need to modify you Podfile like the followings:
use_frameworks!
target 'Example' do
pod 'CocoaMQTT' end
Then, run the following command:
$ pod install
At last, import "CocoaMQTT" to your project:
import CocoaMQTT
The directives above are not straight forward to me as for a newbie, and I followed another way by importing the CocoaMQTT package through the XCode main menu: File -> Add Packages. Once the package was downloaded, I saw that the package (and the other dependencies) were automatically added to my project in the file navigator:
Question: do I still need to do CocoaPad installation as described above, or importing the package as I did is the new and sufficient way to integrate the library into the project? The Podfile that is mentioned in the instructions cannot be modified in XCode.
[Swift package] is the new and sufficient way
Correct. The library is now installed in your project and there is no further work to do.
In general, Swift packages supersede Cocoapods. Wherever possible, if a library offers a Swift package installation, you'll probably want to use that rather than Cocoapods.
In this particular case, you should file an issue on the documentation. They have added Swift Package as an alternative way of installing this library but they have forgotten to add that information to the instructions in the Readme.

Exact steps needed to migrate a react native android app to iOS

I've written a react-native app and compiled it for android.
Now I wish to compile my app for iOS.
I've searched the internet and found a lot of documentation about adding react-native components to an existing iOS app project, but couldn't find a concrete guide/explanation on how to take an existing react-native project(with many components, packages installed etc) and add the relevant iOS configuration.
I guess that I somehow should create an iOS project through xCode,then probably copy some project files into my ios folder of my project, create a podfile corresponding to my packages in package.json, install the required stuff using pod install and then maybe I can run it using the react-native run-ios command, but I'm really not sure whether I'm correct and to do these steps.
If someone can clarify to me what are the required steps I'll be grateful! (And I think other people might find it useful as well)

How to import external iOS framework in flutter plugin?

I'm doing a flutter plugin for stream video by using RTSP protocol. I had no problem develop it for Android, but in iOS things are more complex. I have to use an external library (SGPlayer) for getting the player work. I also downloaded the demo that uses this library and seems to work. This library is NOT on Cocoapods and I need to import it directly into the plugin project from my file system. the downloaded and compiled file structure of the plugin that I would like to use looks like this:
My problem is adding the ".framework" extension file correctly to the iOS project in a way that I can use it to develop the flutter plugin (iOS part).
UPDATE:
I built the project with the framework by using instructions at this link: https://github.com/flutter/flutter/issues/17978
The problem now is that while compiling the framework it change the umbrella header because, I think, it's not using the framework module.modulemap but another one. The result is that is importing just some header and implementations, and not all.
1.Place myFramework.framework to iOS plugin folder /ios ex: myPlugin/ios
2.Update iOS plugin file: myPlugin/ios/myPlugin.podspec
Adding the below line at the bottom of the file, above 'end'
s.vendored_frameworks = 'myFramework.framework'
In Terminal : cd to myPlugin/example/ios
run command
pod install
or
pod update
Now we can find the iOS plugin code by open iOS project (example/ios/Runner.xcworkspace) in XCode and go to
#Lorenzo you can pack your plugin and make private CocoaPod or Carthage repo.
Here is a good article howtos

Can't integrate localytics-react-native on iOS

I'm trying to integrate the localytics-react-native package to my already existing app and successfully integrated it on android but I can't pass the build phase on iOS.
I followed this documentation to do so.
After linking it manually, I followed every step on the localytics documentation.
On the second step 2. Add dependency, the libLLLocalytics.a is already in the Linked Frameworks and Libraries section so I skipped this step.
I managed to go trought every step without problem but at the end it doesn't build and I get this error :
We are managing our natives librairies with cocoapods and and it's the first librairie I have to install without it. Is there a specific configuration I have to do to support the two way of managing them ?
I also tried to follow the iOS specific documentation and install the library with pods. It builds but on the JS side when I try to import LLLocalytics, it returns me undefined.
Versions :
react-native: 0.57.7
react: 16.6.3
localytics-react-native: 2.3.1
pod --version : 1.4.0
If anybody can help me, I thank you in advance.
In Xcode, go to [target] -> Build Settings -> Search Paths -> Header Search Paths and add the directory where the dependency is located. The linker just doesn't know where to find the header yet.

Instaling without cocoapods

https://github.com/IBM-Swift/Swift-SMTP
Im sorry if this is a dumb question but I am trying to install this inside my app and there is no documentation on how to add it. I always use cocoapods but it seems this can't be used for this project. Could anyone help me I need this functionality
That particular project/repo uses Swift Package Manager, so in Terminal cd into the project root:
$ swift package generate-xcodeproj
This will create an .xcodeproject which you'll then open and build. Once you've done that just drag the built framework into the project you'd like to include it in and use the import:
import SwiftSMTP

Resources