How to include libsignal-protocol-c in my Swift iOS app? - ios

I would like to write something like import SignalProtocol at the top of one of my Swift files and then be able to call the C functions from libsignal-protocol-c.
libsignal-protocol-c's README says: "When integrating into actual applications, you should not need anything beyond CMake. Alternatively, you may integrate the code using a build system of your choice."
I think I'd like to use the Swift Package Manager to integrate libsignal-protocol-c into my Swift iOS app. Is there a way to automatically generate a manifest file, ie, Package.swift, and a module map, ie, a module.modulemap file, from libsignal-protocol-c's CMake files? Or if I need to create these files manually, what should they include? Otherwise, how would I do this with CMake?
How to import and use libsignal-protocol-c in an existing .xcodeProj? is a similar question but for Objective-C projects.

I'm not sure its an answer but I'm going to start using https://github.com/christophhagen/LibSignalProtocolSwift. Seems like a good start.

Related

Add custom framework to Standard Library in Xcode

I've looked everywhere and no article gives me exactly the solution I'm looking for.
Is there a way to "install" a custom framework into Xcode?
For example, let's say I've created a framework called 'MyAwesomeFramework' which is really reusable (for example contains a lot of useful UIView extensions). Now what I want to do is be able to just create any new project and type import MyAwesomeFramework to use it, instead of having to add the respective Xcode Project to the project I want to use it in.
Apple Documentation
There are a few different options. You can manually add them via drag and drop or use one of many framework managers such as Carthage or Cocoapods.
Whatever method you choose has a few steps and can be a bit daunting initially so I’d recommend following a tutorial of some sort(I used YouTube). If done correctly you will be able to just import like you would do any other library.

Whirlyglobe private API complain during app submission

I have a simple app which uses whirlyglobe framework (2.2). Otherwise, it is pretty basic program with Apple frameworks.
When I tried to validate the app (and during the distribution, Xcode complains that my app is using private API; specifically it calls "rootElement", and "attributeForFont:". I suspect these functions are part of WhilyGlobe component distribution.
What is the easiest way to remove those files from the framework? Do I need to have the source and compile the framework myself? Or is there a simpler way?
Solved. Here is what I did:
1) Searched in github repository of WhirlyGlobe and found the file that uses the functions which caused issue.
2) I did not need the functionality provided by the file that had the functions.
3) Removed the references (class instantiation) to the file from my project.
That's actually part of the KissXML framework and the implementation is in there. I suspect Apple's test is in error.
In any case, if you're not using the WMS functionality, you can probably drop it out just fine.

Use two versions of the same library

I'm working in a iOS project that includes a static library created by another company.
The library include an old version of AFNeworking and I don't have any source files.
Now i need to use a more recent (and less bugged) version of afneworking, but i cannot include the same class twice in the project (of course) because all the "duplicate symbols".
I understand that it's impossible replacing the version included in the library, but how can i include another version along the old one?
There is a (easy) way to refactor the entire framework before include in my project?
thanks
You'll have to repackage the static library to remove the embedded AFNetworking files.
Unpack the library with:
$ ar x libwhatever.a
And re-package it, including all files except the AFNetworking object files:
$ ar cr libwhatever.a file1.o ... fileN.o
You will then have to link your executable with the new AFNetworking static library and hope that there haven't been API changes which will break the code in libwhatever.a. If there are then I doubt there is much you can do.
I'm afraid this isn't easy to do. Very few environments allow you to link against two separate versions of the same framework at the same time, and Xcode / iOS is not one of them.
As I see it, you have three options:
1) Link against their library and use the same version of AFNetworking they use.
2) Link against their library, and manually load the newer version of AFNetworking and pull symbols from it. Be warned: this will get ugly fast and future maintainers will wonder what you were smoking.
3) Get them to update their library.
On a side note, I don't know the circumstances here, but in general they should be providing you with sources. It's a very backwards practice to provide only a static (static!) library and no way to know what it's doing inside. You'll have to sign a software license agreement and whatnot to protect their interests.
The best and most proper way of handling this would be to contact the the creator of the static library and get them to resolve the situation. They could resolve it either by updating the embedded version of AFNetworking, removing their dependence on AFNetworking, or adding a prefix for their embedded copy of AFNetworking. The last one is probably a good idea anyway when a third party library embeds a different library, because otherwise it would be impossible to use two libraries simultaneously that both include the same third party library.
You could also refactor the copy of AFNetworking that you include yourself to change the names of classes to have a prefix, although this should be unnecessary, as the static library vendor should have done this themselves already.
Lastly, you could find a different library that accomplishes the same thing as your current one but that doesn't embed AFNetworking.

appcelerator module for existing ios project sdk

I want to use into my titanium project the functionalities provided by an existing sdk (deezer sdk).
I know I must deal with modules, so I found a lot of tutorials that explain well how to create a titanium module from scratch. But I didn't find something about to explain how to "wrap" an existing ios project within a titanium module. I just need the login/signup functionality and to retrieve the logged user (functionalities provided by the deezer ios sdk, of course).
can anybody help me on how to proceed?
thanks in advance
Dario
After creating the vanilla module, you have to include the framework you are wrapping (so deezer SDK) inside the bundle. Then follow these steps to add the framework to the compiler directives. Essentially you just add this:
OTHER_LDFLAGS=$(inherited) -framework DeezerSDK
To the module.xconfig file. Just check what the exact name is of the SDK.
After that, you can use the DeezerSDK just like you would in regular native Xcode development.
EDIT:
If the library is just a *.a file, then you can model what Titanium did for the Google Admob module. Its best to just inspect their project, bt essentially all that you need to do is create the vanilla titanium module, drop in the *.a file, and the headers, and then use it just like a native project.

iOS How to use private API?

I don't want to submit this app to AppStore. I've tried for many times but met so many problems :(
I use class-dump to get all the header files of UIKit.framework. In the UIApplication.h generated by class-dump, I saw the method I want to use----launchApplicationWithIdentifier.
Then I put UIApplication.h in my project and import it. Compile, I got a lot of "Redefinition of enumerator...." error because in the UIKit.framework I use previous, there's another UIApplication.h. But this file doesn't have the method launchApplicationWithIdentifier.
If I delete the previous UIKit.framework and import the folder generated by class-dump. Then it appears like a framework but if I unfold it, it's empty.
Then I want to make all generated header files a framework file ant replace the previous UIKit.framework. But I don't know how. As we can see, under the system framework directory, there's a file which has the same name as the framework and has a 'executed shell script' icon. How can I made this file?
I really got confused. Someone can give me a hand? Thank you.
Just specify the private methods in a category interface above the class implementation where you want to use it, like this:
#interface UIApplication (Private)
- (BOOL)launchApplicationWithIdentifier:(id)identifier suspended:(BOOL)suspended;
#end
Don't import the whole class-dump file and link with the original UIKit framework.
You must be very careful when using private API. These methods can change or be removed in future iOS versions!
Check if the method really exists with respondsToSelector: at runtime and be prepared for the case that it does not exist.
I used a secret MapKit feature in my own application and I knew that the private methods only exist in iOS 5. So my app still works in all iOS versions but this feature is only available in iOS 5 (Apple removed or changed it in iOS 6 beta 1).

Resources