3

I'm trying to change the wallpaper of Home Screen and Lock Screen programmatically. I've seen many blogs and posts so far like:

  1. Setting iOS background/lockscreen image programatically?
  2. https://www.reddit.com/r/jailbreakdevelopers/comments/24uyr6/which_private_framework_and_methods_set/
  3. Cropping/zooming not working while setting iOS Wallpaper using PhotoLibrary private framework
  4. Handling private frameworks in Xcode ≥ 7.3
  5. 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.

SandeepM
  • 2,601
  • 1
  • 22
  • 32

0 Answers0