"Use of undeclared identifier" even though Framework linked and header file imported - ios

I copy and pasted the following line of code into a .m file:
uiipc.mediaTypes = #[(NSString *)kuTTypeImage];
But even though I had linked MobileCoreServices.framework and did #import <MobileCoreServices/MobileCoreServices.h> I can't get rid of this error:
Use of undeclared identifier 'kuTTypeImage'
Background
I copied this piece of code from http://www.stanford.edu/class/cs193p/cgi-bin/drupal/system/files/lectures/Lecture%2017_0.pdf to add picture taking capabilities to my iPhone app.
From Symbol not found: kUTTypeImage I figured out I had to link MobileCoreServices.framework. I indepedently figured out I had to #import <MobileCoreServices/MobileCoreServices.h>. I think I've done everything by the book, but why am I still getting this error?

I think the problem stems from having copied and pasted the line of code before linking the framework and importing the correct header file.
I managed to fix the problem by re-writing the line of code. When I began typing kuTTypeImage Xcode's code completion found the variable. So I let code completion finish the variable name and the error suddenly dissapeared.

Related

Use of undeclared type 'PKCS7' (Receipt-Validation/OpenSSL)

To set up Receipt-Validation in my iOS app, I am now following this tutorial:
https://www.raywenderlich.com/9257-in-app-purchases-receipt-validation-tutorial
and reading at this point: Loading the Receipt.
While reading and attempting to understand what is going on I also try to integrate the code in my own app, by doing so getting a hands-on understanding of the process.
Here is one problem I am hitting at this moment:
On this line of code:
private func loadReceipt() -> UnsafeMutablePointer<PKCS7>? {
I get this error message:
Use of undeclared type 'PKCS7'
After searching the net and trying a few things, I guess it is related to the use of the use of the ReceiptVerifier-Bridging-Header.h file. But I am not sure how to set it in the project.
I will be glad if anyone has some tip allowing me to move forward.
Thanks in advance!
In case this can be useful, here is the meaningful contents of the bridging header file (ReceiptVerifier-Bridging-Header.h):
#import <openssl/pkcs7.h>
#import <openssl/objects.h>
#import <openssl/evp.h>
#import <openssl/ssl.h>
#import <openssl/asn1_locl.h>
The problem is that I had simply copied the bridge-header file, without doing the proper setting as explained here:
https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_objective-c_into_swift

Header file issue with xcode 7

I have a subclass of NSObject, but I have a problem with header file, when I run the project, it shows me this:
and it allows me to add this, but directly this logical error is returned: "#end must appear in Objective-C context"
I precise that with Xcode6 I didn't have that issue with this Does anyone knows how to fix this frustrating issue ?
EDIT:
that's a constants file, do not pay attention to the file's name, here is .m file:
#import "CUSBoxes.h"
const int defaultCount = 10;
const long int repeat = 25000;
const NSString *defaultDescription = #"If any layout issue is related, change default values of each box you want to display";
#implementation CUSBoxes
#end
Usually this error causes you missed #end or invalid character in one of the .h file you used in your project. I have came across with this error, this error not exist in same files it throws check for other header files to fix this issue.
1) You might missing #end in any of the Header file.Check one by one all .h file which has #interface section,should be ended with "#end".
2) If everything looks good then Try cleaning project or Restart Xcode.(In my case,It worked).

'PushmoteSDK/Headers/Pushmote.h' file not found when trying to use pushmote sdk

I am trying to follow the steps given here:
http://docs.pushmote.com/docs/import-pushmote-ios-sdk-swift
but I am getting this error: 'PushmoteSDK/Headers/Pushmote.h' file not found, when I try and build my app.
Its my Pushmote-Bridging-Header.h file that has this import statement and the file is clearly there, in project_dir/PushmoteSDK.framework/Headers/Pushmote.h
I have read about a few other header file not found error with xcode and the solutions seem to vary a lot, so I think it might have to do with the specific version of xcode. Perhaps someone has used pushmote with xcode7 before and can assist?
EDIT:
This is my Pushmote-Bridging-Header.h file found in /Users/alex/ios_projects/Monkey/Monkey/Pushmote-Bridging-Header.h
#ifndef Pushmote_Bridging_Header_h
#define Pushmote_Bridging_Header_h
#import "PushmoteSDK/Pushmote.h"
#endif /* Pushmote_Bridging_Header_h */
You should change import line like this;
#import "PushmoteSDK/Headers/Pushmote.h"
to
#import "PushmoteSDK/Pushmote.h"

Getting "Expected a type" error in XCode

I'm getting this error:
/Class/GData/OAuth/GDataOAuthViewControllerTouch.m:116:22: Expected a type
That line is:
authentication:(GDataOAuthAuthentication *)auth
Inside of this block of code:
- (id)initWithScope:(NSString *)scope
language:(NSString *)language
requestTokenURL:(NSURL *)requestURL
authorizeTokenURL:(NSURL *)authorizeURL
accessTokenURL:(NSURL *)accessURL
authentication:(GDataOAuthAuthentication *)auth
appServiceName:(NSString *)keychainAppServiceName
delegate:(id)delegate
finishedSelector:(SEL)finishedSelector {
NSString *nibName = [[self class] authNibName];
I'm a newb XCode developer. So far I've created and compiled a calculator app based from an online class but that's it.
Is this a library that is not being included?
Background: The previous developer abandoned the project and the owner sent the project code to me. I'm trying to replace the existing graphics with new graphics and recompile it with support for iOS 6, which I thought I should be able to do without any coding, but have run into this error and many others when I opened the project. I have the latest XCode.
The :22 (and the position of the caret within the editor) tell you exactly where on the line the error is. In this case it's telling you that where it sees GDataOAuthAuthentication it was expecting a type. So, implicitly, it doesn't recognise that GDataOAuthAuthentication is a type.
Objective-C still sits upon compilation units ala C — each .m file is compiled in isolation then the lot are linked together. You use #import (or #include if you want; #import just guarantees the same file won't be included twice) to give each individual file visible sight of any external definitions it needs.
So, that's a long-winded way of reaching the same conclusion as Rick did five minutes ago: you've probably omitted a necessary #import.
A few things to look for:
Did you #import the file where the GDataOAuthAuthentication type is defined? (e.g. #import "GDataOAuthAuthentication.h")
Is there a variable named GDataOAuthAuthentication which is causing the compiler to think GDataOAuthAuthentication is a variable not a type?

SpringBoard header errors when compiling tweaks with theos

I am new to jailbreak tweaks development and I am using theos to develop my tweaks but I ran into some issues when I was compiling my tweak with the make command.
Basically I dumped all the IOS 7 SpringBoard headers with class-dump-z and placed all of them in the theos/include folder. I realize that there's a class called XXUnknownSuperClass and when I was compiling the tweak I got some error from that class.
/theos/include/Spring/SBUIAnimationController.h:8:9: error:
'XXUnknownSuperclass.h' file not found with <angled> include; use "quotes"
instead
#import <XXUnknownSuperclass.h> // Unknown library
^~~~~~~~~~~~~~~~~~~~~~~
"XXUnknownSuperclass.h"
/theos/include/Spring/XXUnknownSuperclass.h:14:12: error:
cannot find interface declaration for 'XXUnknownSuperclass'
#interface XXUnknownSuperclass (SBApplicationAdditions)
fatal error: too many errors emitted, stopping now [-ferror-limit=]
And the next question that I have is can I hook the SBIconViewDelegate to run custom method when the app icons on the SpringBoard is tapped?
Thanks a lot for your helps!
Some of the header files from class dump can not be used directly. There are some common errors and could be changed as below.
#import "NSObject.h"
->
#import <Foundation/NSObject.h>
#class CTPhoneNumber, NSArray, NSDate, NSDictionary, NSMutableArray, NSMutableDictionary, NSObject<CTMessageAddress, NSCopying>, NSString;
->
#class CTPhoneNumber, NSArray, NSDate, NSDictionary, NSMutableArray, NSMutableDictionary, NSObject<CTMessageAddress, NSCopying>, NSString;
NSObject<CTMessageAddress><NSCopying>
->
NSObject<CTMessageAddress,NSCopying>
For your question, you can delete the declaration or implementation about "XXUnknownSuperclass" or just delete "XXUnknownSuperclass" sometimes.
I prefer only declare the interfaces about current project. You can also search "iOS header" on github.com and download headers dumped and modified by others.
Commonly SBIconViewDelegate is implemented by SBIconController, you can check SBIconController's header file and hook related methods.

Resources