Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

enter image description here

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?

like image 495
Sergio Daniel L. García Avatar asked Oct 31 '22 05:10

Sergio Daniel L. García


2 Answers

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...

like image 75
Garret Avatar answered Nov 12 '22 12:11

Garret


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.

like image 34
Sergio Daniel L. García Avatar answered Nov 12 '22 12:11

Sergio Daniel L. García