Use of unresolved identifier 'PFQuery' - swift

So I am following this tutorial https://www.youtube.com/watch?v=Q6qcrO8uNzU&feature=youtu.be for Parse and when defining a PFQuery variable I get this error: "Use of unresolved identifier 'PFQuery'".
Code Below:
var getMessages = PFQuery(className:"DevelopmentMessages")
How would this be fixed? Thanks in Advance! ;)

You haven't included the Parse framework in your project correctly. This is done about 7 minutes in during Part 1 of that tutorial: http://www.youtube.com/watch?v=Q6kTw_cK3zY
It is also covered in Parse's QuickStart instructions:
https://parse.com/apps/quickstart#parse_data/mobile/ios/native/existing
All you need to do is the "Install the SDK" portion but you also need to include the Parse framework's header in your Objective-C bridging header:
#import <Parse/Parse.h>

The problem might be because you might not have imported the libraries properly. Drag drop the library files into the project properly. Make sure you have added the library inside your project folder and not outside it. Sometimes it may also be the cause of the problem.
Note - Please don't forget to check the option "Copy files if needed" while dragging and dropping the library files.
Update - If you have named your project as "parse" then it will not work. So rename your project to any other name and try it.

Related

Using static C library in swift, cannot find module

I need to create a swift wrapper for a C library for use on both iOS and macOS.
I have added the .a to the frameworks list and include it in library search path. I have added the header file to project and added it to User header search paths and I have added a module.modulemap to the project as well. Looking like this:
module codinglibc [system][extern_c] {
header “codinglibc.h”
export *
}
But when I import the module in Swift:
import Foundation
import codinglibc
I get this error message: No such module 'codinglibc'.
The project is a Cocoa Framework and I have been following this guide: https://medium.com/swift-and-ios-writing/using-a-c-library-inside-a-swift-framework-d041d7b701d9
I have looked at a lot of stackoverflow answers but most have been solved by adding import paths, which I already have done and Xcode can find both the header file and the static library so that is not the issue.
So:
1. Have I done something obviously wrong which I have missed?
2. Should I use briding headers instead?
Edit: I tried enabling Allow Non-modular Includes In Framework Modules
still no success
The answer is pretty trivial, yet annoying.
If you add the module.modulemap in an Xcode project, Xcode will not register it as "to be imported", so what you need to do is to add the path to you module.modulemap file in the header includes.

Import third party C library into swift causes error "Include of non-modular header inside framework module"

This question is a continuation of a previous one I'm currently migrating this (https://github.com/emilwojtaszek/leveldb-swift) library from swift 2 to swift 3/4. Here is the link to my fork https://github.com/lu4/leveldb-swift/tree/MigrationFromSwift2ToSwift3 (please note that the target branch is MigrationFromSwift2ToSwift3)
I was able to resolve (with many thanks to #Ruslan Serebriakov) all of the issues with initial code base and check that the code is running.
However after trying to update LevelDB C code to latest master I got new type of error which I don't understand how to resolve:
Include of non-modular header inside framework module 'LevelDB.c': '/Path/to/Project/leveldb-swift-migration/vendor/leveldb/include/leveldb/export.h'
I've did some research on the internet but the issues described there seem non-related with one I've stumbled on. Here is an image of the issue
Any help is appreciated, thank you in advance!
I'm never 100% certain with mixed language frameworks. But an error like this happens in Swift projects when:
since you cannot use a Bridging Header in frameworks,
you #import a C header in the Foo-Framework.h to expose it so the Swift code, and
the header is not itself marked "Public" to the target.
"Non-modular" seems to indicate "not part of the published module interface". At least with Swift--C mixes, you can only combine both through making the C headers public; no way to import private header files there, which is weird.
Give it a shot: Since you are obviously importing the file in non-Swift code, try to locate the export.h header file in your Xcode project, open the File inspector (⌘⌥1), and ensure public visibility in the framework target:
This issue is because the SDK u are importing is not modular or u can say modulemap file is missing. So make sure modulemap file should be available inside the framework folder. Also make sure that all public headers are listed explicitly in the modulemap. This issue will be resolve 100% if module map file will be include in the third party framework.

unresolved identifier in swift when I use bridging Header

I want to get devices ip , so I use ifaddrs.h example like:
http://footruck.blogspot.com/2016/01/how-to-get-ip-address-for-ios-devices.html
but not working....
compile error is use of unresolved identifier "IPChecker"
In build setting, bridge header already set {PROJECT}/{PROJECT}-Bridging-Header.h
and other files just like above link.. please tell me why?
You need to include the header in your bridging header. In {PROJECT}-Bridging-Header.h add:
#import "IPChecker.h"
Some other things to check:
Did you add IPChecker.h and IPChecker.m to the Xcode project?
Do your header search paths in build settings include the location of IPChecker.h?
Try reducing the problem. Does bridging work for other headers? If so, what's the difference?
I already solved it. But it is still confused me:
In this project, I have main app-container called main and other app-extensions called tunnel.
when I use IPChecker in main. the tunnel in build parse compile error.
So I need to do the same thing in tunnel like main. But I only use IPChecker in main, why should I copy same code in tunnel ?
it is another way make it simple, not code duplicates

Weird including problems with AFNetwork?

I've just downloaded AFNetworking to try and mess with it, but i'm having weird errors on including it in my project.
I've just created an empty test project and dropped both AFNetworking and JSONKit in, and immediately i got the error "Lexical or Preprocessor Issue: 'AFNetworking/AFURLConnectionOperation.h' file not found" .
It happens in this row, but changing it to a regular import works for some reason. I could change all of them but I'm trying to understand why this is happening to begin with. I'm sure its some stupid configuration i didn't notice.
#import <AFNetworking/AFURLConnectionOperation.h> // Throws error
#import "AFURLConnectionOperation.h" // Works
Thanks ! :)
Shai
<AFNetworking/AFURLConnectionOperation.h> works if you add AFNetworking as a framework. If you added the files you have to replace the imports with just "AFURLConnectionOperation.h".
The '#import ' syntax is for framework import.
If you just drag&drop the source in your project you've to use '#import "AFURLConnectionOperation.h"'
If you want use a .framework this tutorial can help you: http://db-in.com/blog/2011/07/universal-framework-iphone-ios-2-0/

No such Directory Error >

i am using in my code this protocol:
#import "AdMobDelegateProtocol.h"
but i am facing no such file or directory found ??
help needed.
This error shows AdMobDelegateProtocol.h not present in your app bundle. either it need any kind of reference if you use this from any code present at net or you missing to include any framework or it also may possible you create any kind of typo. not more than this
Pls check if the file is present in the project folder or tree in the correct destination. This indicates that there is no such file or is missing in the specified folder/destination
From your comments I see you use AdWhirl.
If you want to use AdMob with AdWhirl you have to add the AdMob framework to your project.
There are no Ad frameworks included in AdWhirl. You have to add them to your project. AdWhirl just uses them, but you have to add them.
You can find the AdMob SDK and install instructions on the admob website.