SpringBoard header errors when compiling tweaks with theos - ios

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.

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

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?

error in ACAccount.h in Simulator-iOS 7.1

I'm trying to build and test an app with the xcode simulator, but during the building I get errors in ACAccount.h, ACAccountType.h, etc.
The "strange thing" (at least for me as i'm completely new in using xcode) is that if I click on the .h files with errors they do not appear under the project code but under
Simulator - iOS 7.1-> Frameworks -> Accounts -> ACAccount.h
which is unmodifiable.
Examples of the errors are:
line:
#class ACAccountType,ACAccount Credential; --> Illegal interface qualifier
ACCOUNTS_CLASS_AVAILABLE(NA, 5_0)
#interface ACAccount : NSObject -->Objective-C declarations may only appear in global scope
If the .h are predefined files.. How can I solve these errors?
Many thanks in advance!
Generally when you encounter items like the 'illegal interface qualifier' in system provided headers it indicates that you've placed the #import statement within an #interface block, like:
#interface foo ()
#import <Accounts/ACAccount.h>
#end
This generates errors about the content in the file being imported (e.g. your illegal interface qualifier error), while the actual issue is that putting #import statements within an #interface block is invalid.
You should put #import statements together at the top of the file, outside of any #interface or #implementation blocks.
If you put it into the #implementation section, the error becomes:
error: Objective-C declarations may only appear in global scope

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

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.

Unit testing a static library with RestKit

I'm attempting to follow along with the RestKit unit test guide ( https://github.com/RestKit/RestKit/wiki/Unit-Testing-with-RestKit ) except that my project is a static library instead of an app.
Here is the test I've written:
- (void)testMappingOfDate
{
id parsedJSON = [RKTestFixture parsedObjectWithContentsOfFixture:#"plan.json"];
RKMappingTest *test = [RKMappingTest testForMapping:[self planMapping] object:parsedJSON];
[test expectMappingFromKeyPath:#"plan.date" toKeyPath:#"date"];
STAssertNoThrow([test verify], nil);
}
When I attempt to run the test I receive this error on the first line of the test:
error: testMappingOfDate (api_clientTests) failed: -[NSBundle parsedObjectWithContentsOfResource:withExtension:]: unrecognized selector sent to instance 0x1765c40
It seems like its not finding the NSBundle category defined by RestKit, but my test target header search path is set to "$(BUILT_PRODUCTS_DIR)/../../Headers" and I've verified this path includes NSBundle+RKAdditions.h which contains the supposed "unrecognized selector".
Is there something I'm missing here?
You are trying to include a category within your binary that comes from a library. To get that accomplished you will need to add the following to your (Unit-Test-Target's) build settings.
Other Linker Flags: -ObjC
From Apple's QA:
Objective-C does not define linker symbols for each function (or
method, in Objective-C) - instead, linker symbols are only generated
for each class. If you extend a pre-existing class with categories,
the linker does not know to associate the object code of the core
class implementation and the category implementation. This prevents
objects created in the resulting application from responding to a
selector that is defined in the category.
Solution:
To resolve this issue, the static library should pass the -ObjC option
to the linker. This flag causes the linker to load every object file
in the library that defines an Objective-C class or category. While
this option will typically result in a larger executable (due to
additional object code loaded into the application), it will allow the
successful creation of effective Objective-C static libraries that
contain categories on existing classes.
The error means that the "unrecognized selector" issue is at runtime. The compiler and NSBundle+RKAdditions.h do not give this error they would at compile timr.
The issue is that the code that has #implementation NSBundle(RKAdditions) is not linked into your app. So you need to add this to your build

Resources