Compiler Errors Adding AFNetwork to Xcode - ios

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.

Related

Cannot find protocol declaration for *** in my 'MyApp-Swift.h'

I am working on a project that up to now, despite the mess, it was working ok. Today, believe it or not, I have been updating it to Swift 5.
The project has iOS and tvOS targets as well as frameworks, tests, and top selves extensions. The project also was started using Objective-C and over the years has become 90% Swift.
I am not sure at what point something went wrong but, when compiling, I get the following error for all my top self extensions (mostly all tvOS Targets).
I have found similar questions but I can't understand whats going on.
Any ideas?
You are probably missing an import StoreKit in the Swift files that define IAPHelper. Sometimes this gets imported transitively, and Swift doesn't necessarily need it, but the Swift bridging header does.
Ultimately you need to make sure there's an ObjC #import StoreKit; that is evaluated before this line of code.
First, I have to thank Rob for his tips. I wish he could get the points!
After troubleshooting with the tips provided:
Add StoreKit to your linked frameworks list. -> Didn't work
#import StoreKit; before #import <...-Swift.h> -> Showed error use of #import when modules are disabled
I also saw that "...-Swift.h" was only declared in the Build settings of my "...Topself" targets. Still quite unsure why as I would have thought the whole project still have ObjC dependencies... Still quite new to this challenge.
Furthermore, If I unfold the error I could see that there was some kind of error trying to find "...-Swift.h" file.
At this point, I remembered that I am using cocoapods (I don't like you, you don't like me relationship) and I hated to see the warning "...Overrides Enable modules (C - Objective-C)" so I set it to default for the whole project.
Turns out that that for all "...TopSelf" targets, the default value is NO.
By Overriding Enable modules (C - Objective-C) to YES, clean, and build, everything started working again.

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.

MGTwitterEngine currentNode is unavailable

I am using the MGTwitterEngine in an iOS app that was built by a third party. I have taken over development but have limited experience in objective c.
I am getting an error: 'currentNode' is unavailable.
This is in the MGTwitterXMLParser.m file. The interface has a weak link like this:
__weak NSMutableDictionary *currentNode;
I had to add the libOAuth.a file because it was missing and I am wondering if this is the cause. Do I need a certain version of libOAuth?
The weird part is that it worked with the new libOAuth.a until I updated XCode to the latest version which is 7.3. Is anyone having issues with MGTwitterEngine in 7.3?
UPDATE:
In XCode (I was compiling in AppCode) I now see that it says, "Declaration uses __weak, but ARC is disabled."
This is in MGTwitterXMLParser:
__weak NSMutableDictionary *currentNode;
My project has ARC enabled and I don't see any way to set ARC for the MGTwitterEngine or any individual files. Is there a way to do this?
Okay, the answer was simple once I understood the problem. I simply needed to discard the __weak for the NSMutableDictionary and it compiled.
Still need to test Twitter and look for any memory leaks. Also, not sure how the app ever compiled before with a __weak reference in a non-ARC file.

How to implement RabbitMq for 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.

AFNetworking Not Working with Xcode 5.1.1 and Cocoapods - Redefinition Issues

I have a project I which I need to use AFNetworking so after downloading the source files, importing them manually and struggling for hours with no luck I figured I'd use Cocoapods as it should surely be easier. Unfortunately not, I'm now getting lots of issues regarding redefinition of Enumerators, Duplicate interface definition and property has a previous declaration.
If anyone can help me with why I could be getting this and how I can get rid of the error it would be much appreciated. I was under the impression it is meant to be easy using Cocoapods but as of yet I haven't seen that!

Resources