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

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.

Related

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.

Integrate Stripe SDK in iOS (Swift)

I added Stripe SDK to my iOS app (added PassKit.framework alongside the StripePublishableKey in AppDelegate) via manual installation, but I came across one of two issues when the import statement (tried both #import <Stripe/Stripe.h> and #import "Stripe.h") was added to the bridging header file:
1) With #import <Stripe/Stripe.h>, the bridging header no longer imports, despite having worked before. (I checked Swift Compiler under Build Settings and the file is correct. Plus once I removed elements of Stripe, the problems went away).
2) With #import "Stripe.h", I get errors that indicate that the SDK isn't picked up at all.
(I've checked the SO archive for relevant threads, which pointed to the aforementioned import statements as possible solutions. And, as a Swift learner, I'm not as familiar with implementing Obj-C solutions. I cobbled what I could from Stripe's documentation.)
Is this a Stripe problem? What am I missing in implementation?
This worked for me and hopefully this will be helpful for anyone who finds himself/herself in the same predicament. First, it's #import <Stripe/Stripe.h>. Next, adding turning on Passbook under Capabilities allowed Passkit.framework to be linked to the app (or recognized in the library).

Generic implementation of 3rd party Libraries and Frameworks in Swift

I see there’s many libraries, open source, like Cocos2d, ShareKit, FormatterKit, etc. that seems up to date. (Check GitHub).
But still, implementation, snippets, samples and manual are intended to be written in Objective-C.
But, a method is a method… I think… If I get an instance of any framework/library of these and I call the method in a full Swift enviroment, would I be affected behind the scenes?
After June WWDC Swift gonna get serious, Apple is pushing hard, I’m just getting ready for the move and I don’t want my Apps to implement a soon-to-be deprecated library implementation in Objective-C.
I do not understand your question so much that I will regard your question as "Is it possible to use the Objective-C&Swiftin the same project?"
Yes, Apple claimed that developers can use Bridging-Header to implement double languages development, whatever your main developing language is ObjC or Swift. The specific details and theories about it you shall check from there.
Next I want to tell you some errors occurred in my project when I used Bridging-Header.
I always meet this kind of problem like import 'file not found'. I think you can try to check your file&folder hierarchy. Such as you have a root folder named Project, as is often the case, there is another Project in your previous Project, the root folder.
And Checking the Objective-C Bridging Header in the Build Setting. Sometime error can occurred for Project/Project/Bridging-Header.h. And the error can be corrected by changing the definition as Project/Bridging-Header.h.
If the location of Bridging-Header.h is not matching with the definition in the Build Setting, the error like import file not found will occur.
I just tell your my solution for Bridging issue I already met, I hope it can help you.

Objective C - Swift Bridging issue Xcode 6.3 -Screenshot provided-

So, I found myself craving a framework to replicate iOS 6 folders animation. Luckily I found one called JWFolders, which is pretty neat and useful, but my problem is the following:
I am doing my program in Swift, in Xcode 6.3, I imported the header file to the bridging thingy in the swift compiler settings, and as long as I don't try to use anything from that framework, it doesn't complain, but as soon as I try to use it and compile I get the errors shown in the image below.
(even with a simple declaration like this)
var folder = JWFolders()
So, If anyone was wondering, I got it working. I contacted the developer and asked for help, and he nicely told me I was forgetting to add the source code files ".m" to the source compiling files.
After that it worked.

Theos preference loader + tweak error

I am making a cydia tweak with a preference bundle using theos in my iPhone
But I'm getting this error!
This is the code I have in:
PSListController
(I have no idea where is the error in my code. The code is too long to paste here. I made a link to my codes)
http://pastebin.com/gQvYvB89
How do I solve this problem?
This isn't an answer but it won't allow me to comment.
A good alternative to IOSOpenDev is Theos, this is more like you are used to as it works the same as on your iphone. You use the make command and have templates.
Installation is fairly involved but here is a good guide.
http://brandontreb.com/beginning-jailbroken-ios-development-getting-the-tools
You should add #import <UIKit/UIKit.h> at the beginning of the header file (this is a common thing: if you encounter a system defined class or protocol - basically every class that starts with NS or UI and some others - you should remove the header generated by class-dump and import the system header, this will save you a lot of headaches).
By the way, you should really NOT compile stuff on device because the GCC that there's on Cydia is very outdated (I think it's from the iOS 3.x days) and using Theos is a pain in the ass anyway: there is another framework that'll help you building preference bundles (and tweaks, siri extensions, toggles for SBSettings, ...), it's called iOSOpenDev and it lets you use Xcode for these projects, which is a MAJOR improvement over compiling on device from the command line (so without code completion, syntax highlighting and all those great improvements Xcode can give you).
PS: if you choose to move to iOSOpenDev feel free to ask for explanations, I have some experience with it ;)

Resources