Cannot find protocol declaration for 'PHPhotoLibraryChangeObserver' - objective-c

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?

Related

In a mixed objc/swift module, Xcode always tries to include the module itself

This one is not easy to explain, but is also very annoying.
I'm working on a Cocoapods framework (in development mode) with objc and swift sources. Let's call it the "SuperCompoment" framework
Xcode auto generates the SuperComponent-Swift.h file, to make Objc classes visible from Swift ones.
Some Objc classes also includes Swift classes.
At compile time, in the SuperComponent-Swift.h, Xcode adds the line
#import <SuperComponent/SuperComponent.h>
... and fails to compile with the message: SuperComponent/SuperComponent.h file not found
Xcode tries to include the framework inside the framework itself!
If I manually edit the auto-generated file by commenting the #import, the project compiles perfectly. But Xcode auto-generates the file after each clean and before archiving the project!
Any clue?
I don't know why Xcode automaticaly adds the #import <SuperComponent/SuperComponent.h> line (since it do work without it), but if i'm kind with him by adding an empty SuperComponent.h file at the root of my framework, it compiles gracefully.

PojectName-Swift.h Not found while using Both Swift and ObjC codebase

I had a perfectly working ObjC project integrated with Apple WatchKit App with Multiple Targets. Only one of the Targets is linked with the WatchKit App.
I am moving my classes to swift and hence there are ModuleName-Swift.h files being used in my code.
Followed steps given in ModuleName-Swift.h file not found in xcode8 and I have ensured to add the “$(PROJECT_NAME)-Swift.h” under Projects > Build Settings > Objective-C Generated Interface header name.
But when I go to the build settings - it shows as Objective-C generated interface header name for the project target and Swift_ObjC_Interface_header_name for WatchKitApp Target
Error thrown by compiler : ProjectName-Swift.h file Not found
Is this causing the error? Not sure what I am Missing.
This is how I've linked the -swift.h files in Other targets
The issue was:
There were Unit test cases that were failing, disrupting further Compiling of the Project
Quick Fix:
The ObjectiveC Classes had Unit test cases associated with it.
Some of the Unit tests were failing due to changes to the main code base.
I had to uncheck the the following under Edit Schemes > Build so that they don't Build while running the WatchKit App.
I agree I will have to update the test cases to work with the Updated app, But the issue of Watch App not working is Fixed! :)

Compiling for device, swift header file not found

Recently added first swift file to large obj-c project. Compile and run in simulator is fine. Attempt to compile and run for a device and I get a file not found error on the obj-c compiler generated swift header file (aka Objective-C Generated Interface Header Name ending with -swift.h)
I have confirmed (at least to my knowledge) that project settings are correct and can see the file in the (derived data) file system for debug / simulator builds but nothing else.
Have looked at this and this but have not helped. Using xCode8 GM
The problem corrected itself when I
Did a clean (have done many times before)
Built for "Generic" iOS device (success)
Closed and restarted Xcode
Built for Device
go figure..
[Edit] and if this doesn't help .. try this post I just found for more ideas

Errors after removing Obj-C Bridging Header from Swift 2 Project

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!

Can't use Objective-C Pod Framework in Swift 2 project ("Use of undeclared type 'SMPageControl'")

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.