I'm trying to change the wallpaper of Home Screen and Lock Screen programmatically. I've seen many blogs and posts so far like:
- Setting iOS background/lockscreen image programatically?
- https://www.reddit.com/r/jailbreakdevelopers/comments/24uyr6/which_private_framework_and_methods_set/
- Cropping/zooming not working while setting iOS Wallpaper using PhotoLibrary private framework
- Handling private frameworks in Xcode ≥ 7.3
- How to set lock screen , wallpaper and Ringtone programmatically in iPhone?
Nothing is working from all of the above. Here is what I tried so far:
NSString *path;
#if TARGET_OS_SIMULATOR
path = @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PhotoLibrary.framework";
#else
path = @"/System/Library/PrivateFrameworks/PhotoLibrary.framework";
#endif
NSBundle *bundle = [NSBundle bundleWithPath:path];
[bundle load];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
// Instantiate the controller.
id class = NSClassFromString(@"PLStaticWallpaperImageViewController");
id controller = [[class alloc] performSelector:@selector(initWithUIImage:) withObject:image];
// Select what wallpaper mode.
// 0 - Both lock screen and home screen.
// 1 - Home screen only.
// 2 - Lock screen only.
int wallpaperMode = 0;
[controller setValue:@(wallpaperMode) forKey:@"wallpaperMode"];
// Tell the controller to save the data.
[controller setValue:@YES forKey:@"isWallpaperEdit"];
[controller setValue:@YES forKey:@"saveWallpaperData"];
// Save the photo.
[controller performSelector:@selector(_savePhoto) withObject:nil];
[controller performSelector:@selector(setWallpaperForLocations:) withObject:@(wallpaperMode)];
#pragma clang diagnostic pop
I know that Apple will not approve it but I don't care.
Any help is appreciated.