Public frameworks are great for the large majority of cases but they don't cover everything.
Private Frameworks allow us to access every single feature on our iDevice, for example using
Pros
Cons
Importing Private Frameworks in
$(TWEAK_NAME)_PRIVATE_FRAMEWORKS = aRandomFramework
However, even if you are using patched SDK's you cant always guarantee that every PrivateFramework will work.
So we need to be picky in the headers we import as most likely we will have to download them from Limneos Headers
For example lets say we wanted to check to see if we are connected to a BluetoothDevice and if we are open an app, for example Spotify
So lets first go onto Limneos and search for the framework we want to use.
Tweak Development is largely about 'trial and improvement'. If one method doesn't work try another one and narrow down our search
Looking through the list of frameworks available to us lets find the ones related to Bluetooth
BluetoothAudio
BluetoothManager
Lets test our method of
In this framework it consists of 3
BluetoothAudio-Structs.h
BluetoothAudio.h
BluetoothBridge.h
We can use the
These both look promising, so let's implement them so we can use them in our tweak.
The key to this is only add what you need
In
After that is done we can create our smaller header for
Let's first remove what we don't need from the header, so it should look something like this.
@protocol OS_dispatch_semaphore, OS_dispatch_queue;
#import <BluetoothAudio-Structs.h>
@class NSObject, SFDeviceDiscovery;
@interface BluetoothBridge : NSObject {
NSObject*<OS_dispatch_semaphore> _connectedSemaphore;
NSObject*<OS_dispatch_semaphore> _disconnectedSemaphore;
BOOL _targetUserSession;
OpaqueFigEndpointManagerRef _manager;
SFDeviceDiscovery* _deviceDiscovery;
NSObject*<OS_dispatch_queue> _queue;
BTSessionImplRef _session;
}
@property (assign,nonatomic) OpaqueFigEndpointManagerRef manager; //@synthesize manager=_manager - In the implementation block
@property (retain) SFDeviceDiscovery * deviceDiscovery; //@synthesize deviceDiscovery=_deviceDiscovery - In the implementation block
@property (assign) BOOL targetUserSession; //@synthesize targetUserSession=_targetUserSession - In the implementation block
@property (retain) NSObject*<OS_dispatch_queue> queue; //@synthesize queue=_queue - In the implementation block
@property (assign) BTSessionImplRef session; //@synthesize session=_session - In the implementation block
-(void)deviceConnected:(BTDeviceImplRef)arg1 ;
-(BOOL)isConnected:(BTDeviceImplRef)arg1 ;
%end
Please Remember to change the imports line of your new header to reflect the name in the tweak files
There is still a few things we could remove, however for the sake of the guide we will keep it like this It is small enough to be managed easily.
Just like any other framework we need to import the
#import <BluetoothBridge.h>
And now using
%hook BluetoothBridge
-(void)deviceConnected:(BTDeviceImplRef)arg1 {
// returns original code
%orig;
// modified code here
}
-(BOOL)isConnected:(BTDeviceImplRef)arg1 {
return %orig;
}
%end
Please be aware if using anything other than a (void) method we have to return %orig; instead of %orig;
Also double check you have added the framework you are using in your
$(TWEAK_NAME)_PRIVATE_FRAMEWORKS = aRandomFramework
And ... we are done
It is a little complex, however not impossible