Publish my own CocoaPod Framework - ios

I'm about to create a cocoaPod for a small iOS Framework for our customer. I have 2 questions about it.
1) I'm depending on another framework that is also available via cocoaPod. Could it happen that the original author removes the lib and therefor could kill my framework as well or is this secured?
2) I'm using Swift as the language of choice? Let's say one is importing an Obj-C Pod into a Swift project, he needs a bridging header. With the other way around, using a swift cocoapod with obj-c, does the user need to do anything to make this run?
Thanks

Yes, and hopefully the dependent framework doesn't remove his framework (its very rare they do it)
The bridging header is fine unless you use advanced generics (inheritance of a base generic class) as methods might not be available while converting to Objective-C.

Related

Converting objective-c frameworks and third party code to swift

I know those objective-c files must be converted to swift manually (with some help from several online converting tools),
the question is...
how about frameworks that're added to the project?
And third parties written in objective-c added via cocoapods?
Do I need to remove those frameworks, re-add third parties of their swift version, or let Xcode warn me with any possible error?
Maybe just keep them and add some bridge file to cope with those?
Need some information before I mess everything up...
Any link or file guide would be appreciated!
Obj-c frameworks can all be used in swift and will automatically be bridged to swift so you can access them from swift code (create an obj-c bridge, google it). You can add your own .h files to this obj-c bridge file too and use your obj-c code in swift. There's no need to search for swift libraries or anything.

Swift Cocoa Touch Framework containing another Framework

I'm trying to build a framework that implements a REST API which I want to reuse and share. To handle the network access, I want to use Alamofire inside this API framework. Everything works so far except that my test app, which actually uses my API framework, won't build because Alamofire is missing.
In the app's target I can set "Embedded Binaries" to include my API Framework. If I also include Alamofire there, it works.
Now I wonder if there is a way to put the Alamofire framework into my API framework so that the app only has to include one framework. The API framework's target->general settings don't have the section "Embedded Binaries". But maybe this can be done in another way. Or is this not a good approach at all?
Thanks for your help!
--- UPDATE ---
Of course it is possible to add the source files of the Alamofire framework in my API framework. This way my app only has to import the API framework. But I still wonder if it's possible to include the Alamofire framework in my API framework.
Half a year later I learned that this is simply not meant to work this way in Xcode with iOS frameworks. If a framework depends on other 3rd party frameworks, you need to import those frameworks into your own target. I'm using Xcode 8 beta 3 and nothing changed so far and probably won't in the future.
I think the reason is simple: If the above would be possible, you could end up having one framework included several times in your project, because some of your frameworks include other frameworks include other frameworks include other frameworks include other frameworks include other frameworks...
I think you get the point :P

Creating framework that requires (depends on) another framework

I'd like to create a framework using Cocoa Touch Framework Project in Swift. However, I'm building this framework on top of another framework called RNCryptor, which is Objective-C based. I've seen various tutorials on how to create a framework in Xcode but none has covered a framework with its own dependency.
I tried to create a framework project and then using CocoaPods to manage its dependencies. However, there are errors appeared: 'Check Dependencies' Unable to run command...'
So the question is: is it possible to create a framework on top of another framework in Xcode. And if so, how?
Frameworks should never embed other frameworks directly. This leads to collisions if the importing project or any other framework also includes that framework. Instead, you need to tell your consumer that they also need to include your dependency. CocoaPods will do this for you automatically, so you should let it. (If you're having trouble with CocoaPods dependencies, you should ask a question about that and get it cleared up. The whole point of CocoaPods is to manage these kinds of things.)
Note that I will be releasing the Swift version of RNCryptor into beta today (or tomorrow, but I really hope today). This version bridges to ObjC and will be the preferred version going forward. (The ObjC version will continue to be available of course for projects that cannot or don't want to include Swift.)

Building a Swift framework with references to Objective-C code

I'm working on an iOS project written in Swift, and I would like to take some classes out of the regular "app" project, and bundle it into a reusable Swift framework instead (and maybe make it publicly available on Github and via Cocoapods).
I'm running into issues because frameworks seemingly can't have Objective-C bridging headers, but in order to compile my framework code, I need to reference several Objective-C classes (in this case: the Google Maps iOS SDK).
I've also added GoogleMaps.framework as a linked library in my framework project, but then, how can I "import" it from Swift code?
Is this even possible with the current tools and Swift version, and how should I proceed?
Thanks.
It wasn't that complicated, actually... I was just doing some things wrong.
First, bridging headers are not required in that setting: the Google Maps iOS SDK is provided as a regular .framework file, so the development language has no impact on how it can be imported in Swift. Apple clearly mentions it in the documentation: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html, "Importing external frameworks".
It's as easy as adding the framework to the "Link binary with libraries" section of the project settings. Do not forget to also add depending libraries and frameworks (in GoogleMaps.framework's case, there are quite a few).
Then, in Swift code, the framework classes should be available simply by doing:
import GoogleMaps
No bridging header, no dealing with "non-modular header etc." errors.

Cocoapods - Hide implementation?

I have a iOS library that I created. Quite now I shipped this lib in a .framework file with only some .h files.
Now I would like to use Cocoapods instead of the framework.
Is it possible to hide the .m files and expose only some header files (like with the framework)?
According to this question I don't understand the relation between the podspec settings source_files and public_header_files.
I assumed that public_header_files would be my needed option, but I don't understand what this property is doing.
Edit:
I think I misunderstood the design of Cocoapods. public_header_files seems to make sense when using the use_framework! setting.
Maybe I'm trying Carthage instead.
For the Objective-C static framework, it is possible, you can try cocoapods-packager.
For Swift framework, so far it is impossible to use cocoapods-packager because of no volunteers. You can find the detailed information here:
But there is another way to Hide implementation of Swift framework when distributing it

Resources