AFContentTypeForPathExtension does not work when AFNetworking is built in CocoaPods workspace - afnetworking

I was try to build and keep the version of AFNetworking by CocoaPods, but I couldn't get the right mime-type when I using the appendPartWithFileURL method. The result of mime-type detection is always return #"application/octet-stream".
It seems like the __UTTYPE__ is not defined when building the AFNetworking project in CocoaPods workspace.
I had been tried to import the SystemConfiguration.h and MobileCoreService.h in the project-Prefix.pch in my project. Then, I can see the __UTTYPE__ is defined in my project, but the symbol in AFNetworking (CocoaPods workspace) is not defined.
For this observation, I tried to add the following code in the AFURLRequestSerialization.h, it seems work! But I'm not sure this is a good modification.
#if __IPHONE_OS_VERSION_MIN_REQUIRED
#import <MobileCoreServices/MobileCoreServices.h>
#else
#import <CoreServices/CoreServices.h>
#endif
Anyone has solution?
Here is my environment,
AFNetworking 2.0.2
CocoaPods 0.26.2
XCode 5.0
Mac OS X 10.8

Related

How to import framework into XCode project?

I get No such module 'BRLMPrinterKit' error.
I take a reference from official document https://support.brother.com/g/s/es/htmldoc/mobilesdk/guide/getting-started/getting-started-ios.html to import framework.
Here is my step:
drag BRLMPrinterKit.framework and BRLMPrinterKitW.framework into my framework folder
Check they are in Link Binary With Libraries (remove and drag again)
Check Framework Search Paths (I'm not sure it correct or not)
Check Header Search Paths (I'm not sure it correct or not)
Finally I clean and build get No such module 'BRLMPrinterKit' error.
I have no idea how to fix my import problem, any help would be appreciated. Thanks.
That's not a Swift module, so first, you need to create a bridging header, in which you import <BRLMPrinterKit/BRLMPrinterKit.h>, then you can use the BRLM classes in your Swift files.
Try using CocoaPods to install the framework, it's more convenient and faster.
Your framework supports installation using cocoapods
https://cocoapods.org/
https://github.com/jonathantribouharet/BRLMPrinterKit
using CocoaPods to install the 'BRLMPrinterKit' framework.
add the bridge file.(Targets > Build Settings > Swift Compiler - General > Objective-C Bridgeing Header)
the bridge file.h
#ifndef PtouchPrinterKit_Bridging_Header_h
#define PtouchPrinterKit_Bridging_Header_h
#import <BRLMPrinterKit/BRPtouchBluetoothManager.h>
#import <BRLMPrinterKit/BRPtouchDeviceInfo.h>
#import <BRLMPrinterKit/BRPtouchNetworkManager.h>
#import <BRLMPrinterKit/BRPtouchPrinter.h>
#import <BRLMPrinterKit/BRPtouchPrinterData.h>
#import <BRLMPrinterKit/BRPtouchPrinterKit.h>
#import <BRLMPrinterKit/BRPtouchPrintInfo.h>
#endif
then you can use the framework

GoogleMaps not found

I am trying to use google maps in my ios app my Xcode ver is 7.2 and swift ver is 2.1.1. I simply add GoogleMaps in my pod file everything is fine i added frameworks and libs which are required to support Googlemaps all fine, i am following this tut and according to this i have to add a bridging header file to include
#import <GoogleMaps/GoogleMaps.h>. My app already have one bridging header file because i am using facebook login as well so i put the import statement in the same file and in 'others linker flag -ObjC' is already there so after few required settings in storyboard i compiled my proj but i am getting this error "GoogleMaps/GoogleMaps.h" not found. I have searched for it and tried almost all the suggested ways on Stackoverflow but hard luck nothing worked yet.I will be really grateful if anyone could suggest me what i am doing wrong here.
Make sure your pod install went smoothly.
According to the tutorial,
You should see output similar to the following:
Downloading dependencies
Installing GoogleMaps (1.10.4)
Using SwiftyJSON (2.3.0)
Generating Pods project
Integrating client project
try
#import "GoogleMaps.h"
in your bridging header file

Xcode trying to compile Objective-C libraries as Swift

I have a iOS Swift Project on Xcode.
I've been working on it for a long while using external Objective-C libraries on my Swift code with no problem.
Suddenly, after Xcode got updated (I guess), I try to run my project and apparently it's trying to compile de external Objective-C as Swift, so, of course, it fails.
I attach an screenshot with the errors:
And this is my Bridging Header:
#define degreesToRadian(x) (M_PI * (x) / 180.0)
#import <Parse/Parse.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <Bolts/Bolts.h>
//#import <Facebook-iOS-SDK/FacebookSDK/FacebookSDK.h>
#import <ParseFacebookUtils/PFFacebookUtils.h>
#import <Bugsnag.h>
#import <M13Checkbox.h>
#ifndef VideoCloudBasicPlayer_VideoCloudBasicPlayer_Bridging_Header_h
#define VideoCloudBasicPlayer_VideoCloudBasicPlayer_Bridging_Header_h
#import "BCOVPlayerSDK.h"
#endif
Any ideas?
Hmm.. I had the same issue before.
After trying to clean and remove derived data, I fixed it by removing the old obj-c libraries and re-adding them to my project. There may be a setting in target to tell the ARC to read objective c, but I never found it.
My Obj-c libraries somehow lost their target membership and thought it was swift.
Commit your changes. Save your bridging header and remove the library and re-add the library, File - New - Target - (make sure Obj-C is set as language), then add your class files to the directory. It should compile...
It didn't work before due to I'm using Parse as my first Cocoapod dependency. So I erased it from my Podfile and installed it by drag and drop style.
Then, just after that my final solution to my issue when working with Cocoapods dependencies was to delete everything (except Parse), update the Cocoapods to the latest version, reinstall everything (while Xcode is closed).
PD:
The solution above works perfectly when using Drag-and-drop installed libraries.

Amazon SDK Pod won't compile?

I'm attempting to getting the Amazon iOS SDK integrated into my application and using the cocoapod to install it.
However, it won't compile, I'm getting an error inside of AmazonS3Client.h that says
'AWKRuntime/AmazonWebServiceClient.h' file not found
but it is clearly there in the Pod when I search for it.
Anyone else had this issue?
Note: This answer refers to a now deprecated version of the AWS SDK for iOS.
I ran into the same problem when migrating a project to CocoaPods. Without modifying any of the AWS header files, I was able to avoid by changing my header import lines from:
#import <AWSS3/AWSS3.h>
#import <AWSSNS/AWSSNS.h>
to:
#import <AmazonS3Client.h>
#import <AmazonSNSClient.h>
This works because all that AWSS3.h does is #define AWS_MULTI_FRAMEWORK and then #import "AmazonSNSClient.h", and AWS_MULTI_FRAMEWORK is responsible for the other header files expecting a different directory structure than what CocoaPods sets up.
To find out what file names you need to include, just look inside the AWS*.h file you were importing and then import the files named inside directly.
When using the cocoapod for AWS it has this in the separate framework headers:
#ifndef AWS_MULTI_FRAMEWORK
#define AWS_MULTI_FRAMEWORK
#endif
That makes it look to other frameworks instead of the relative path for the headers for shared frameworks.
If you comment those lines out, it will work.

Tons of strange parse errors in Xcode

I'm creating a project that needs ZipArchive so I added the library and did everything needed in order for it to work but when i tried compiling the project i got this errors:
It is not a problem with the linker. I added everything needed and I just cant seem to get rid of the errors
I have already seen these kinds of errors a million times when I was on Xcode 4.2. I bet you are on Xcode 4.2 right now when you compiled it.
If you want to use ZipArchive then upgrade your Xcode to latest 4.6 and all these errors will go away.
This is an old thread, but this ZipArchive library is still useful.
From a similar question, the problem is as follows:
The compiler will try to import Objective-C frameworks into C source code. The minizip c files (zip.c, unzip.c, etc.) will thus try to import Objective-C frameworks as well.
To prevent this c files from importing Objective-C frameworks, wrap the entire .pch file like so:
#ifdef __OBJC__
// Your .pch contents
#endif
Credits: https://stackoverflow.com/a/13234930/1938889
However, there is a Cocoa pod that has addressed all these issues:
https://github.com/mattconnolly/ZipArchive
Zip archive processing for Cocoa - iPhone and OS X http://code.google.com/p/ziparchive/

Resources