Module support in iOS Static Library - ios

I have multiple static iOS libraries (Objective-C) that I would like to add module support to.
By that I mean the use of #import statements instead of needing to use a bridging header to support swift.
Facebook, and Parse have recently added this feature to their SDKs but I can't find any documentation as to how they did it. Keep in mind that these SDKs STILL target iOS 7 so they are not simply dynamic frameworks (which would only support iOS8).
Can anyone explain exactly how I can go about doing this?

Related

NSBundle.allFrameworks doesn't return some of the frameworks

We are developing an SDK in Objective-C and as part of our service to our SDk consumers we have a tool that checks to see if all the required frameworks exist in the develop project.
In order for us to do so we use NSBundle.allFrameworks that should return all of the frameworks and we search for the required framework in the returned result.
We are seeing a weird behaviour with that call that changes between OS versions.
For example when we call NSBundle.allFrameworks on iOS the returned list doesn't contain some of the frameworks such as
MobileCoreServices, CoreGraphics, UIKit, SystemConfiguration
If we run the same call on an iOS 11 device the only framework that is missing is SystemConfiguration.
Is anyone familiar with this behaviour?
We would really love to provide that functionality for our users
According to the docs, it returns:
An array of all of the application’s bundles that represent frameworks. Only frameworks with one or more Objective-C classes in them are included.
And the Discussion section mentions that:
The returned array includes frameworks that are linked into an application when the application is built and bundles for frameworks that have been dynamically created.
This means that frameworks with at least one Objective-C class, and that are bundled within the app/linked against the app, are shown.
e.g. If both the app and the bundled frameworks are not linking against a specific framework, it won't appear in the list.

Does Swift support WebRTC?

Our team is in process of electing programming language to develop a new iOS application in which we have to write features to support video conversation.
The backend is written using WebRTC, now we have to decide which language to use in the iPhone app and we prefer Swift in this case.
However, I'm not sure Swift supports WebRTC or not.
My initial research show that we can implement the features using Objective-C. I found an example written in Objective-C which you can find the source code here.
However, I'm not sure about Swift. Does Swift also support WebRTC?
UPDATE 2023
Unfortunately, as of 2023 there still appears to be no completely Swift framework that implements the WebRTC protocol. Although the iOS framework hosted at webrtc.org can be fairly easily used in Swift apps, it is written mostly in objective C.
For those stumbling on this question, who just want to get webRTC running in your app this is still relatively easy using the cocoapod
UPDATE 2016
The easiest way is to get webRTC in your project is to simply install the CocoaPod using the directions at https://cocoapods.org/pods/WebRTC
If you have never used CocoaPods before you will need to first follow this guide: https://guides.cocoapods.org/using/getting-started.html
Original Answer
The simple answer to the question is that there are currently no open source libraries written in Swift conforming to the WebRTC protocol. You can still compile the code from the official WebRTC project into your app. Directions which may not lead to a successful build can be found here: https://webrtc.org/native-code/ios/
Finally, to clarify Omkar Guhilot's answer: Skylink is a company with a closed source SDK that is designed to work only with their paid stun-turn service, and https://github.com/alongubkin/phonertc requires cordova, which may not be ideal for many native ios developers.
Webrtc comes with Objective C interface. I dont think they will move to swift interface anytime soon. But You can always use them via bridging headers. I have written apprtc (webrtc's demo) in swift 2.3 version with help of bridging headers in github link with a description in this blog . I have planned to write 3.0 version and a swift wrappers over it.
Current version of webrtc framework doesn't require any pods or any extra bridging headers.
The framework can be generated by following instructions on this Link :
https://webrtc.github.io/webrtc-org/native-code/ios/
If you follow them correctly you will generate a framework add that framework in your project and follow the webrtc necessary steps and you will have a WEBRTC integrated project.
To know what all steps are necessary follow this link from appear.in
:
https://tech.appear.in/2015/05/25/Getting-started-with-WebRTC-on-iOS/
This will get you to a stage where you will be able to make calls between a browser and any iOS 8+ device
Yes swift supports WebRTC and there is one more library which you can use in swift link:- http://skylink.io/ios/
And the link that you have shared to which is written in Objective C, we should be able to use that as well in swift by creating a Bridging header
Have a look at this as well https://github.com/alongubkin/phonertc
Thanks
Omkar

Using CommonCrypto in Swift generates not safe for use in extensions warning

I've created a simple lib to use HMAC digest for Swift called "SweetHMAC". This lib is so simple, basically is a wrapper to CommonHMAC.h in Swift.
I can build and deploy any iOS project using SweetHMAC correctly but, seems by some security issue, my approach is not safe. There is the warning I receive after run the iOS tests for example.
warning: linking against dylib not safe for use in application extensions
This code is not safe enough to put in iOS AppStore, and the app can be rejected by that. For OSX, there is no problems.
I know, there are HMAC ports for Swift, but my challenge is to try to enable Swift to use CommonCrypto safely.
I have implemented this project using this approach and works fine!
My question is, how possible is to create and use use modules like CommonCrypto in Swift frameworks safely for iOS?
Looking at the documentation from Apple, the suggestion for said error is to make sure that the option of using "Require Only App-Extension-Safe API" is checked.
To configure an app extension target to use an embedded framework, set the target’s “Require Only App-Extension-Safe API” build setting to Yes. If you don’t, Xcode reminds you to do so by displaying the warning “linking against dylib not safe for use in application extensions”.
Here's the full documentation on extensions
It is also worth noting that parts of the CommonCrypto API might not be available, as per this discussion

Strip symbols from static library in Objective C

I have the following scenario:
An application I'm working on includes a library let's call it static library 1.
Static library 1 includes (among other functionality I must have) Google analytics , Facebook and Flurry in old versions.
In that app I intend to use a SDK I'm developing which also uses Google analytics , facebook and flurry.
Theoretically - I have no problems compiling a slim version of my SDK that will take those implementation from the static library 1 - Assuming we both use the same version of facebook and flurry. (Iv'e done so in the past and it works)
But since the library is old the version of the facebook and flurry sdks is older and I cannot use it.
Is there anyway to strip those symbols or to override them? I don't mind putting all the libraries at the project level or any other solution of that type.
Thanks in advance,
Liviu
Did you try this one? Looks quite easy...
http://atnan.com/blog/2012/01/12/avoiding-duplicate-symbol-errors-during-linking-by-removing-classes-from-static-libraries

Can an iOS static library contain classes/interfaces, that can be used/implemented by iOS code that is using the library?

I apologize if this is a dumb question, or if it does not make sense. I've written some Objective-C code before, but I am not very familiar with writing code for OS X or iOS; I'm pretty much a novice. Currently, I'm trying to port a project from OS X into iOS. The project compiles into a Framework, that other OS X projects can use.
I'm trying to do something similar for iOS. I understand that iOS does not support Frameworks that contain dylibs and that the solution is to create a static library. However, the OS X Framework has several classes (in .m files) that the implementing code uses, extends, or implements. All the examples I've seen for static libraries seem to define a header-file with some functions that can be compiled into a static library.
Is it possible to have classes inside the static library, that iOS code can use? Also, how can I tell if the code is using dynamic libraries?
Yes, static libraries can contain Objective-C classes.
In some cases, you will need to pass options to the linker to force it to include all of the classes and categories defined in a static library. See http://developer.apple.com/library/mac/#qa/qa1490/_index.html

Resources