How can I use ` use_frameworks!` to a specific cocoapods pod? - ios

I know if you are using Cocoapods, you should use all pods as framework or static libraries. It's not possible specify some pods using framework and the others using static library. But I just want to have a try to ask or discussion about this problem. Maybe there will be some tricky solutions. ^_^
I am working on a iOS project, Objective-C as the main development language. Now I want to import a swift framework using Cocoapods, I didn't use use_frameworks!, some problems occurs as expected. The Cocoapods version is 1.5.3, Swift 5.0, is there a way or a new version to solve this problem? How about Carthage?
Any discussion is appreciate!

CocoaPods 1.9.0 is adding support for specifying linkage on individual pods. Until then, the only option is Podfile hacks like this one.

Related

How to use a Swift library in a Flutter Application?

Recently I've developed a native ios library using Swift 5.
This library is being distributed using Cocoapods and now that is done I would like to know if there's any method to use that same library in a Flutter application from Cocoapods and which is the best way to do it.
What I've tried so far:
I tried creating a flutter demo app and moving to /ios for running pod init and later configuring my Podfile to point the source of the Pod and after that I did a pod install.
Apparently this works, because if I go to my Runner.xcworkspace and add
import MyLib
to the AppDelegate, it compiles.
The thing is, how do I access the methods and classes of the Pod from my Dart code? Is it possible or I have to manage that interaction directly from Swift?
Thank you very much.
Yes and no. You need to manually write down some boilerplate between Swift and Dart. But this can be simplified by some code generators, for example pigeon.
If you are using other languages like Rust instead of Swift, there does exist more advanced code generators that requires almost zero boilerplate. But there seems none for Swift.

React Native Bridge Library for existing Objective C Framework which depends on other iOS Frameworks

I have an Objective-C Framework, which depends on other third party Frameworks through CocoaPods.
i.e A-->B,C,D
I created a react-native-create-library bridge which wraps the code around Objective-C Framework A.
i.e React_Native_A-->A-->B,C,D
I tried creating an example app Example_React_Native_A which links the React_Native_A using the react_native link command. Hoping that it links to the other frameworks added using the CocoaPods.
Unfortunately, this doesn't work in this way. It won't even consider React_Native_A-->A link.
Is there any other way to generate the example app, so that it can link all the required frameworks i.e A-->B,C,D.
If anyone looking for the solution, the way is mentioned in the RNNearBee.podspec here. The wrapper podspec depends on the version of the react as per the local machine installed version and then it depends on the original native podspec.

iOS: Migrating Cocoapods from Dynamic Libraries to Static Libraries

I am trying to transition from dynamic libraries (via use_frameworks!) to static libraries in a project that the uses cocoapods to handle external dependencies. The project is a combo of swift & objc.
One of these dependencies is an internal swift cocoapod. However, when I try to build, I get the following message:
Cannot load underlying module <our_internal_cocoapod>
Additionally, the ProjectName-swift.h is not found, I am assuming it is not being generated.
Things I've tried:
1. cleaning & building
2. deleting derived data
3. reinstalling cocoa pods
All to no avail. How can I resolve this? Help greatly appreciated!
Static libraries don't provide module access by default.
CocoaPods 1.5.0 introduced use_modular_headers! to still provide module support with static libraries. Details in the release notes.
If you run into issues with that, you may want to try the 1.6.0 beta which has some bug fixes in this area.

An iOS (or OS X) project depends on two versions of a framework

I am writing a swift framework, which depends on Alamofire v3.x. Now I want to add my framework into a project, which depends on Alamofire v2.x. I am using Carthage to manage me project. It seems not possible to add two versions of the same framework in a project. Is there a way to solve such situation?
What you encountered is called dependency hell. Runtimes like .NET, Node etc. have solved the problem. Java, at least up to 8, will just pick the first version it finds at runtime and hope all other packages will work with it; they don't.
CocoaPods can detect dependency hell for you and error during pod install but that's it. I think Carthage does the same? Then users of your framework are stuck downgrading dependencies here and there until your framework and other dependent frameworks all use the same version of the shared dependency. As of right now, that's still the only option available to us AFAIK.
Apple did kind of solved dependency hell via Framework versioning. The framework would bundle up multiple versions of itself and when linking against the framework, the linker would record the full path (version is in the path) to the required version. But a framework bundling up multiple versions of itself was and is an incredibly silly idea and so never took off.

Cocoapod podspec to reference iOS and OSX projects

Are there any examples or suggestions on how to make a CocoaPod podspec that is used by both an iOS project and OSX project within a workspace? I'm working on a pod that uses bluetooth and I'm sure many will want both their OSX project and iOS project living in the same workspace referencing the same Pod.
There are several things I'm unsure about, such as changing the Base SDK between iOS and OSX, and how to make the project reference either an iOS or OSX target.
Anyways, any suggestions are welcome. Thanks in advance.
Thanks Keith. The correct answer is in the comments above. To see a sample go to github.com/PunchThrough/Bean-iOS-OSX-SDK/wiki

Resources