Skip to content

Instantly share code, notes, and snippets.

@laoyur
Created November 25, 2018 09:01
Show Gist options
  • Save laoyur/5b9f906ad16ab399c30e1ce5f14cfcb7 to your computer and use it in GitHub Desktop.
Save laoyur/5b9f906ad16ab399c30e1ce5f14cfcb7 to your computer and use it in GitHub Desktop.
code to fix Cydia network problem on iOS 11
//
// main.c
// NetworkFixer
//
// Created by mac on 2018/11/24.
// Copyright (c) 2018 ___ORGANIZATIONNAME___. All rights reserved.
//
#include <stdio.h>
#import <Foundation/Foundation.h>
// link to /System/Library/PrivateFrameworks/Preferences.framework/Preferences
// entitlements used:
/*
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.CommCenter.fine-grained</key>
<array>
<string>cellular-plan</string>
<string>data-usage</string>
<string>data-allowed-write</string>
<string>preferences-write</string>
</array>
<key>platform-application</key>
<true/>
</dict>
</plist>
*/
@interface AppWirelessDataUsageManager : NSObject
+ (void)setAppCellularDataEnabled:(NSNumber*)arg1 forBundleIdentifier:(NSString*)arg2 completionHandler:(id /* block */)arg3;
+ (void)setAppWirelessDataOption:(NSNumber*)arg1 forBundleIdentifier:(NSString*)arg2 completionHandler:(id /* block */)arg3;
@end
int main (int argc, const char * argv[])
{
NSString *cydiaBundleId = [NSString stringWithUTF8String:"com.saurik.Cydia"];
[AppWirelessDataUsageManager setAppWirelessDataOption:[NSNumber numberWithInt:3]
forBundleIdentifier:cydiaBundleId completionHandler:nil];
[AppWirelessDataUsageManager setAppCellularDataEnabled:[NSNumber numberWithInt:1]
forBundleIdentifier:cydiaBundleId completionHandler:nil];
return 0;
}
@laoyur
Copy link
Author

laoyur commented Nov 25, 2018

Note the entitlements needed:

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
     <dict>
         <key>com.apple.CommCenter.fine-grained</key>
         <array>
             <string>cellular-plan</string>
             <string>data-usage</string>
             <string>data-allowed-write</string>
             <string>preferences-write</string>
         </array>
         <key>platform-application</key>
         <true/>
     </dict>
 </plist>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment