Was trying to implement some Obj-C code into my Swift 2 project and decided that I was going to try a different method.
I deleted the files I added, including the newly created bridging header.
I went to build settings and removed the contents of the "Objective-C Bridging Header" setting and now I am getting bombarded with errors.
My project was running fine with no errors prior to the Obj-C fiasco.
Can someone help? See attached image for the errors I am getting.
According to the errors, your swift files (profileVeedVC.swift) still refer to the obj-c code. Remove the pod from your podfile and remove any references within the files.
Good luck!
Related
I have no debugging values in my console for my swift + obj-c app, and I get a really unhelpful message that explains why the debugger isn't working: "warning: Swift error in module XXX.". XXX is the name of my module, not a 3rd party that I include.
My app has been around since before Swift. I used the bridging header to start using Swift, and I recently used the Xcode tool to migrate all the Swift 2 files to Swift 3. (but I still have obj-c legacy in there). I use cocoapods, which may be contributing to the problem.
(lldb) po self
warning: Swift error in module XXX.
Debug info from this module will be unavailable in the debugger.
I tried following the second answer to this post and a couple others
I have found that suggest the same thing: remove duplicate imports.
I tried removing duplicate imports from my swift project. In fact if I run find . -name "*swift" | xargs grep "import" I get no results. So I went to the extreme of removing all imports from all of my swift files (and commenting out code to get it to compile) just to see if I can get my debugger to come back.
So...
Is there another solution to this problem?
Is there a way to get a more detailed error message?
Is it a problem to have duplicate headers in the my bridging header? For example, a lot of my obj-c files import UIKit, and I include a few of those files in the bridging header.
Just now I have encountered this problem.
This is my solution:
If you import 3rd repo by Cocoapods, and the repo is written by Objective-C, you need to import it by this way:
// System
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
// Directly add - Objective-C
#import "EaseUI.h"
// Cocoapods - Objcetive-C
#import MJRefresh;
You can refer to this issue in Github and this question.
I have a Swift 2 project running on Xcode 7. I'm using CocoaPods (v 0.38.2 with use_frameworks!) and have already managed to get those frameworks working:
CryptoSwift
Pluralize_swift
Both Pods are written in Swift, so no problems so far. They work as charm.
Now I'm trying to use SMPageControl which is written in Objective-C. I've seen it's possible to use Obj-C Pods with Swift 2, tried a lot of different combinations but I can't get it to work. SMPageControl class doesn't show on autocomplete suggestions, and obviously when I try to use it the compiler throws Use of undeclared type 'SMPageControl'.
What I have done so far:
Added pod 'SMPageControl' to my Podfile
Ran pod install (I can see the Pod source/framework on Xcode project tree)
Added SMPageControl.framework in Build Phases > Link Binary With Libraries (as I've done with the other frameworks that work)
Created PROJECT_NAME-Bridging-Header.h and added it on the project's Build Settings (I can tell it's working because it threw errors until I got to import SMPageControl correctly)
Added #import <SMPageControl/SMPageControl.h> to the file above
Up to here the project compiles without errors, but I can't get to use SMPageControl in my Swift classes. Tried import SMPageControl in the Swift file, but no luck (it doesn't even autocomplete). I understood it's possible, but I didn't find any example codes.
Is it really possible? If so, what am I missing?
Finally got it to work, it turns out that I was actually missing something.
Along with all steps above, it's needed to import the framework at the top of the Swift file:
import SMPageControl
Since Xcode was not providing any autocomplete I thought it wouldn't be possible to do that. Once I added the import statement, the project compiled successfully and I was able to use SMPageControl() class.
After successfully using my Xcode created Objective-C bridging header Xcode now returns a Swift Compiler error complaining that the bridging header does not exist.
I had been able to use the Xcode created bridging header all day yesterday before Xcode generated this error when the project was compiling. I have attempted to resolve the issue with the solutions here but have been unable to resolve the issue.
Any suggestions?
Thanks in advance.
I moved my project location and Xcode (v 6.4 ) still looked for the bridging header in the old folder location which was weird. The only way I fixed it was by using an absolute path to the bridging header (#Aggressor's solution of just dragging the file into the bridging header field populated the field with an absolute path) . Really hoping that later version of Xcode fix this - it seems like a stupid IDE bug to me...
Also ensure to check your project Tests target (if you have one) and do the same there
I've read a bunch of articles on adding a Swift bridging header to an Obj-c project:
Apple's docs
Bohemian Polymorph
SwiftCast
Using CocoaPods 0.36, I should see the Swift Compiler sections appear in Build Settings but they aren't? I search in the box for Swift or Bridging and nothing shows up. And I can't add a new Swift file to the project in this situation because I'm writing some reusable installation steps for a project (having the end user create a blank swift file and delete it after the fact is pretty janky).
What's the proper way to manually add a bridging header and configure the Build settings when using CocoaPods? What am I missing?
Bonus Points: I'm ultimately going to be scripting this. If you have an idea of how to do it programmatically, that's even better!
I have a an issue when trying to compile my project.
I have a standalone swift project. It works PERFECTLY.
I added it to an objective-c project (as a plugin). It also works perfectly.
My swift code has no problem what so ever.
Today I needed to change some behaviour in the app delegate file. So I needed to call some of my Swift code in there.
To do this I imported the "ProjectName-Swift.h" file that xcode generates.
No problem so far, it lets me call my Swift code with autocomplete.
However when I go to build I get an error:
Cannot find protocol declaration for 'PHPhotoLibraryChangeObserver'
The file this occurs in, is of course the PumpUp-Swift.h file. I don't create this, Xcode does. Do you know how I can fix this issue given that I can't edit this file?