How to implement RabbitMq for ios? - ios

I'm trying to implement RabbitMQ into my ios project.
First of all, I tried it with https://github.com/profmaad/librabbitmq-objc
However, after several steps and it still didn't work, I got frustrated and switched to this one
https://github.com/EFEducationFirstMobile/librabbitmq-objc
It's like pre-support for IOS (Foundation insteads of Cocoa, ARC supported ...) and I just copied rabbitmq-c folder and wapper classes. It builds successfully.
Then I tried to run it with these line of codes:
AMQPConnection *connection = [[AMQPConnection alloc] init];
[connection connectToHost:#"123.45.678.90" onPort:12345];
[connection loginAsUser:#"test" withPassword:#"test" onVHost:#"/"];
AMQPChannel *channel = [connection openChannel];
but it throws this error at the second line:
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
fcntl$UNIX2003 called from function amqp_open_socket_noblock in image MyApp.
can anybody help me with this error ? thanks in advanced.

I am also using Objective-C wrapper for librabbitmq-c library. I am able to connect, create exchange, create queue, bind queue publish message using this library:
For using in iOS
Delete:
#import <Cocoa/Cocoa.h>
Use:
#import <Foundation/Foundation.h>
And if file not found using this:
# import <amqp.h>
Use this:
# import "amqp.h"
I hope this will almost solve your problem. You may get some error on uint64 fix it as Xcode suggests you. And it will work fine.

bug has been fixed by Dmitry Makarenko (lib's owner)

For a correct answer you can use this for iOS using objective-c, it's a pain but it's doable.
From my own research it seems like there have been a lot of people that have pulled this off, but they are all closed source projects that they will not share source code.
For your question you have to make sure you include the rabbitMQ-c source code in your project along with the wrapper. Take out all of the dealloc stuff that conflicts with ARC or turn ARC off for the wrapper.
And to answer your question, just change the cocoa\cocoa import lines to foundation\foundation.h.

The really hard to find ready, easy setup library for rabbitmq on iOS platform the problem is with implementation rabbitmq-c, so I try created own implementation wrapper with usage cocoapods. OLRabbitMQ ( https://github.com/open-rnd/OLRabbitMQ) is also wrapper but you can use cocoapods.

Related

How to wrap existing iOS code in a new Appcelerator module?

This seems like a basic request, but I can't find the answer to it anywhere. I want to wrap some existing iOS code that I wrote, in a Appcelerator module. That's it. Important points:
I am NOT wrapping a pre-existing 3rd party iOS SDK.
I wrote the iOS code being wrapped.
Code is verified as working within xcode.
There are no .a files. There are 2x .h files and 2x .m files though.
There are no UI elements in the iOS code as it is only designed to connect the native bluetooth hardware to the app.
I have created a generic appcelerator iOS module project, built it, and successfully called the generic ID function within my app.
I cannot figure out how to successfully edit the generic module so that it utilizes my code. Every attempt results in it refusing to compile, and it's maddening.
I do not have access to Hyperloop.
Once I can successfully build the wrapped module, I would call an initialization function which triggers a native bluetooth hardware search. Once connected, there are functions within the module to send commands to the hardware and receive data back. This is the official documentation I've followed so far:
http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Module_Quick_Start
That helped me build the blank module, include it in the app, and ensure that it worked by calling the built in test property. From there it stops short of actually telling me what I need to know. These are the closest things I've found so far, while still not being what I need:
http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Module_Project-section-43288810_iOSModuleProject-AddaThird-PartyFramework
appcelerator module for existing ios project sdk
Heck, I still don't even know if I can do this within studio or if I have to edit the generic module in Xcode. Help! :) Many thanks in advance.
so first of all, this is not best practice and will cause possible problems in the future when the SDK changes and your module still relies on outdated core API's.
Regarding your question, you could either create a new component that subclasses the existing class, e.g.
class TiMyModuleListViewProxy : TiUiListViewProxy {
}
and call it with
var myList = MyModule.createListView();
or you write a category to extend the existing API with your own logic, e.g.
#interface TiUIListViewProxy (MyListView)
- (void)setSomethingElse:(id)value;
#end
#implementation TiUIListViewProxy (MyListView)
- (void)setSomethingElse:(id)value
{
// Set the value of "somethingElse" now
}
#end
I would prefer the second option since it matches a better Objective-C code-style, but please still be aware of the possible core-changes that might effect your implementation in the feature. Thanks!

iOS: #import AnyModule not found after editing class using cocoapods

I have an Obj-C/Swift project setup that imports modules using cocoapods. In any class where I am importing a framework using the #import function I get the error message SomeModule not found. However, when I build/run it compiles fine, and the framework works and functions as expected.
The problem here is that it messes me up when I'm trying to write code below the error (i.e., objects appear as ints because the error above messes up the compiler; function auto complete doesn't work, etc). What's weird, if I cmd+s to save the class, the error messages go away. Then the second I start typing again, they reappear.
I've gone as far as removing all of my cocoapods and reinstalling them, but to no avail. This has only been an issue since installing xcode 8.
Anyone have any insight into this?
Thanks in advance.
Sorry for super late response - the only way I found to get around this was to use the "old" style of framework import; i.e., ... it seems like some Frameworks just don't play nicely with the #import declaration. #pablo-martinez
If someone has a better solution please feel free to share.

Compiler Errors Adding AFNetwork to Xcode

I've looked at all the questions on StackOverflow regarding this, and nothing has helped. I followed this tutorial for setting up the AFNetworking library with xcode to use for my project, however I am getting this error in the AFURLSessionManager.m file:
Semantic Issue: #synthesize of 'weak' property is only allowed in ARC or GC mode
and a yellow caution sign for the same file:
Semantic Issue: Method possibly missing a [super dealloc] call
I'm very lost at this point since I'm fairly new to iOS development to begin with, and adding this framework has been nothing but frustration.
why you don't use Cocoapods. With me that's the best one to import a library. Try and you will like it.

Generic implementation of 3rd party Libraries and Frameworks in Swift

I see there’s many libraries, open source, like Cocos2d, ShareKit, FormatterKit, etc. that seems up to date. (Check GitHub).
But still, implementation, snippets, samples and manual are intended to be written in Objective-C.
But, a method is a method… I think… If I get an instance of any framework/library of these and I call the method in a full Swift enviroment, would I be affected behind the scenes?
After June WWDC Swift gonna get serious, Apple is pushing hard, I’m just getting ready for the move and I don’t want my Apps to implement a soon-to-be deprecated library implementation in Objective-C.
I do not understand your question so much that I will regard your question as "Is it possible to use the Objective-C&Swiftin the same project?"
Yes, Apple claimed that developers can use Bridging-Header to implement double languages development, whatever your main developing language is ObjC or Swift. The specific details and theories about it you shall check from there.
Next I want to tell you some errors occurred in my project when I used Bridging-Header.
I always meet this kind of problem like import 'file not found'. I think you can try to check your file&folder hierarchy. Such as you have a root folder named Project, as is often the case, there is another Project in your previous Project, the root folder.
And Checking the Objective-C Bridging Header in the Build Setting. Sometime error can occurred for Project/Project/Bridging-Header.h. And the error can be corrected by changing the definition as Project/Bridging-Header.h.
If the location of Bridging-Header.h is not matching with the definition in the Build Setting, the error like import file not found will occur.
I just tell your my solution for Bridging issue I already met, I hope it can help you.

Theos preference loader + tweak error

I am making a cydia tweak with a preference bundle using theos in my iPhone
But I'm getting this error!
This is the code I have in:
PSListController
(I have no idea where is the error in my code. The code is too long to paste here. I made a link to my codes)
http://pastebin.com/gQvYvB89
How do I solve this problem?
This isn't an answer but it won't allow me to comment.
A good alternative to IOSOpenDev is Theos, this is more like you are used to as it works the same as on your iphone. You use the make command and have templates.
Installation is fairly involved but here is a good guide.
http://brandontreb.com/beginning-jailbroken-ios-development-getting-the-tools
You should add #import <UIKit/UIKit.h> at the beginning of the header file (this is a common thing: if you encounter a system defined class or protocol - basically every class that starts with NS or UI and some others - you should remove the header generated by class-dump and import the system header, this will save you a lot of headaches).
By the way, you should really NOT compile stuff on device because the GCC that there's on Cydia is very outdated (I think it's from the iOS 3.x days) and using Theos is a pain in the ass anyway: there is another framework that'll help you building preference bundles (and tweaks, siri extensions, toggles for SBSettings, ...), it's called iOSOpenDev and it lets you use Xcode for these projects, which is a MAJOR improvement over compiling on device from the command line (so without code completion, syntax highlighting and all those great improvements Xcode can give you).
PS: if you choose to move to iOSOpenDev feel free to ask for explanations, I have some experience with it ;)

Resources