diff --git a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/Resources/UICustomViewMenuElement-Image.png b/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/Resources/UICustomViewMenuElement-Image.png deleted file mode 100644 index 1157be3..0000000 Binary files a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/Resources/UICustomViewMenuElement-Image.png and /dev/null differ diff --git a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSApplicationProxy/LSApplicationProxy.md b/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSApplicationProxy/LSApplicationProxy.md deleted file mode 100644 index c3ef101..0000000 --- a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSApplicationProxy/LSApplicationProxy.md +++ /dev/null @@ -1,22 +0,0 @@ -# LSApplicationProxy - -@Metadata { - @TitleHeading("Class") - @PageColor(blue) -} - -## Overview - -Not much is known about `LSApplicationProxy`, but it seems to manage many components of application sandboxing and appearance. An instance of it can be generated by [`LSBundleProxy`]() with the function [`bundleProxyForCurrentProcess()`](). - -> Important: `LSApplicationProxy` is not available until runtime. Adding the following linker flag in the build settings will alleviate this issue: `-Wl,-U,_OBJC_CLASS_$_LSBundleProxy` - -## Topics - -- - -## See Also - -- -- -- diff --git a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSApplicationProxy/setAlternateIconName.md b/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSApplicationProxy/setAlternateIconName.md deleted file mode 100644 index 6bb8b18..0000000 --- a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSApplicationProxy/setAlternateIconName.md +++ /dev/null @@ -1,65 +0,0 @@ -# setAlternateIconName(\_:completionHandler:) - -@Metadata { - @TitleHeading("Instance Method") - @Available(iOS, introduced: "10.3") - @Available("iPadOS", introduced: "10.3") - @Available("Mac Catalyst", introduced: "13.1") - @Available(tvOS, introduced: "10.2") - @Available(visionOS, introduced: "1.0") - @PageColor(red) -} - -Set an alternate app icon without an alert - -## Overview - -`setAlternateIconName(_:completionHandler:)` is a completely private function in UIKit which is actually responsible for setting an app's alternate icon. According to [Bryce Bostwick](https://bryce.co), this is called down the chain by [`_setAlternateIconName(_:completionHandler:)`](). - -> Note: We think that it is important to note that Bostwick also discovered that `setAlternateIconName(_:completionHandler:)` ultimately calls the function `setAlternateIconName(_:completionHandler:)` in the completely private class called LSApplicationProxy. - -> Warning: It is unknown when `setAlternateIconName(_:completionHandler:)` became the backbone of `setAlternateIconName(_:completionHandler:)` and exactly which operating systems/versions support it. Testing is required before release into production and `setAlternateIconName(_:completionHandler:)` may be removed in the future. - -> Note: Given that `setAlternateAppIcon(_:completionHandler:)` in `UIApplication` was added in iOS 10.3, we can speculate that it supports iOS 10.3+ - -For more information, watch Bostwick's [video](https://www.youtube.com/watch?v=KDVibKGtSVI) on the subject. - -## Adding the Function to Swift - -To make swift recognize this function, just bridge it with Objective-C. To do so, create a `LSApplicationProxy.h` file with the following code: -```objc -#import - -@interface LSApplicationProxy: NSObject - -- (void)setAlternateIconName:(nullable NSString *)name - withResult:(void (^_Nonnull)(BOOL success, NSError *_Nullable))result; - -@end -``` -Then, add the following to a [bridging header file](https://developer.apple.com/documentation/swift/importing-objective-c-into-swift) (you may need to create one): -```objc -#import "LSApplicationProxy.h" -``` - -## Method - -We can use roughly the same code as if we were using the public version of this API in [`UIApplication`](): -```swift -let appProxy: LSApplicationProxy = LSBundleProxy.bundleProxyForCurrentProcess() -appProxy.setAlternateIconName(iconName) { success, error in - if !success || error != nil { - print("Error: \(error as Any)") - return - } -} -``` -As seen above, this function also requires the use of [`LSBundleProxy`]() and [`bundleProxyForCurrentProcess()`](). - -> Important: It is critical to note that unlike other variations of this function, `LSApplicationProxy` requires that the completion handler have a bool value first. This is assumed to be if the operation succeeded or not. - -## See Also - -- -- -- diff --git a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSBundleProxy/LSBundleProxy.md b/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSBundleProxy/LSBundleProxy.md deleted file mode 100644 index 0e523a1..0000000 --- a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSBundleProxy/LSBundleProxy.md +++ /dev/null @@ -1,22 +0,0 @@ -# LSBundleProxy - -@Metadata { - @TitleHeading("Class") - @PageColor(blue) -} - -## Overview - -Not much is known about `LSBundleProxy`, but it seems to manage components of application sandboxing and appearance. With the function [`bundleProxyForCurrentProcess`](), `LSBundleProxy` can generate instances of [`LSApplicationProxy`](). - -> Important: `LSBundleProxy` is not available until runtime. Adding the following linker flag in the build settings will alleviate this issue: `-Wl,-U,_OBJC_CLASS_$_LSBundleProxy` - -## Topics - -- - -## See Also - -- -- -- diff --git a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSBundleProxy/bundleProxyForCurrentProcess.md b/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSBundleProxy/bundleProxyForCurrentProcess.md deleted file mode 100644 index 2a7d20f..0000000 --- a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/LSBundleProxy/bundleProxyForCurrentProcess.md +++ /dev/null @@ -1,46 +0,0 @@ -# bundleProxyForCurrentProcess() - -@Metadata { - @TitleHeading("Instance Method") - @PageColor(red) -} - -Get the current `LSApplicationProxy`. - -## Overview - -According to [Bryce Bostwick](https://bryce.co), this function gets the current [`LSApplicationProxy`](). - -> Warning: It is unknown when `bundleProxyForCurrentProcess()` was added to Apple's platforms and exactly which operating systems/versions support it. Testing is required before release into production and `bundleProxyForCurrentProcess()` may be removed in the future. - -For more information, watch Bostwick's [video](https://www.youtube.com/watch?v=KDVibKGtSVI) on the subject. - -## Adding the Function to Swift - -To make swift recognize this function, just bridge it with Objective-C. To do so, create a `LSBundleProxy.h` file with the following code: -```objc -#import - -@interface LSBundleProxy: NSObject - -+ (nonnull LSApplicationProxy *)bundleProxyForCurrentProcess; - -@end -``` -Then, add the following to a [bridging header file](https://developer.apple.com/documentation/swift/importing-objective-c-into-swift) (you may need to create one): -```objc -#import "LSBundleProxy.h" -``` - -## Method - -We can create this constant to retrieve the [`LSApplicationProxy`](): -```swift -let appProxy: LSApplicationProxy = LSBundleProxy.bundleProxyForCurrentProcess() -``` - -## See Also - -- -- -- diff --git a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIApplication/UIApplication.md b/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIApplication/UIApplication.md deleted file mode 100644 index 478c0cb..0000000 --- a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIApplication/UIApplication.md +++ /dev/null @@ -1,39 +0,0 @@ -# UIApplication - -@Metadata { - @TitleHeading("Class") - @Available(iOS, introduced: "2.0") - @Available("iPadOS", introduced: "2.0") - @Available("Mac Catalyst", introduced: "13.1") - @Available(tvOS, introduced: "9.0") - @Available(visionOS, introduced: "1.0") - @PageColor(blue) -} -An object that displays an alert message. - -## Overview - -Every iOS app has exactly one instance of UIApplication (or, very rarely, a subclass of UIApplication). When an app launches, the system calls the [`UIApplicationMain(_:_:_:_:)`](https://developer.apple.com/documentation/uikit/1622933-uiapplicationmain) function. Among its other tasks, this function creates a singleton UIApplication object that you access using [`shared`](https://developer.apple.com/documentation/uikit/uiapplication/1622975-shared). - -Your app’s application object handles the initial routing of incoming user events. It dispatches action messages forwarded to it by control objects (instances of the [`UIControl`](https://developer.apple.com/documentation/uikit/uicontrol) class) to appropriate target objects. The application object maintains a list of open windows ([`UIWindow`](https://developer.apple.com/documentation/uikit/uiwindow) objects), which it can use to retrieve any of the app’s [`UIView`](https://developer.apple.com/documentation/uikit/uiview) objects. - -The [`UIApplication`](https://developer.apple.com/documentation/uikit/uiapplicationdelegate) class defines a delegate that conforms to the UIApplicationDelegate protocol and must implement some of the protocol’s methods. The application object informs the delegate of significant runtime events—for example, app launch, low-memory warnings, and app termination—giving it an opportunity to respond appropriately. - -Apps can cooperatively handle a resource, such as an email or an image file, through the [`open(_:options:completionHandler:)`](https://developer.apple.com/documentation/uikit/uiapplication/1648685-open) method. For example, an app that calls this method with an email URL causes the Mail app to launch and display the message. - -The APIs in this class allow you to manage device-specific behavior. Use your UIApplication object to do the following: - -- Temporarily suspend incoming touch events ([`beginIgnoringInteractionEvents()`](https://developer.apple.com/documentation/uikit/uiapplication/1623047-beginignoringinteractionevents)\) -- Register for remote notifications ([`registerForRemoteNotifications()`](https://developer.apple.com/documentation/uikit/uiapplication/1623078-registerforremotenotifications)\) -- Trigger the undo-redo UI ([`applicationSupportsShakeToEdit`](https://developer.apple.com/documentation/uikit/uiapplication/1623127-applicationsupportsshaketoedit)\) -- Determine whether there is an installed app registered to handle a URL scheme ([`canOpenURL(_:)`](https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl)\) -- Extend the execution of the app so that it can finish a task in the background ([`beginBackgroundTask(expirationHandler:)`](https://developer.apple.com/documentation/uikit/uiapplication/1623031-beginbackgroundtask) and [`beginBackgroundTask(withName:expirationHandler:)`](https://developer.apple.com/documentation/uikit/uiapplication/1623051-beginbackgroundtask)\) -- Schedule and cancel local notifications ([`scheduleLocalNotification(_:)`](https://developer.apple.com/documentation/uikit/uiapplication/1623005-schedulelocalnotification) and [`cancelLocalNotification(_:)`](https://developer.apple.com/documentation/uikit/uiapplication/1623082-cancellocalnotification)\) -- Coordinate the reception of remote-control events ([`beginReceivingRemoteControlEvents()`](https://developer.apple.com/documentation/uikit/uiapplication/1623126-beginreceivingremotecontrolevent) and [`endReceivingRemoteControlEvents()`](https://developer.apple.com/documentation/uikit/uiapplication/1623057-endreceivingremotecontrolevents)\) -- Perform app-level state restoration tasks (methods in the [Managing state restoration](https://developer.apple.com/documentation/uikit/uiapplication#1657552) task group) - -Full Documentation [Here](https://developer.apple.com/documentation/uikit/UIAlertController) - -## Topics - -- diff --git a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIApplication/_setAlternateIconName.md b/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIApplication/_setAlternateIconName.md deleted file mode 100644 index 4d0781e..0000000 --- a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIApplication/_setAlternateIconName.md +++ /dev/null @@ -1,64 +0,0 @@ -# \_setAlternateIconName(\_:completionHandler:) - -@Metadata { - @TitleHeading("Instance Method") - @Available(iOS, introduced: "10.3") - @Available("iPadOS", introduced: "10.3") - @Available("Mac Catalyst", introduced: "13.1") - @Available(tvOS, introduced: "10.2") - @Available(visionOS, introduced: "1.0") - @PageColor(red) -} - -Set an alternate app icon without an alert - -## Overview - -`_setAlternateAppIcon(_:completionHandler:)` is a completely private function in UIKit which is actually responsible for setting an app's alternate icon. According to [Bryce Bostwick](https://bryce.co), the typical `setAlternateAppIcon(_:completionHandler:)` just calls `_setAlternateAppIcon(_:completionHandler:)` and then adds the alert into the handling flow. - -> Note: We think that it is important to note that Bostwick also discovered that `_setAlternateAppIcon(_:)` ultimately calls the function `setAlternateIconName(_:completionHandler:)` in the completely private class called LSApplicationProxy. - -> Warning: It is unknown when `_setAlternateAppIcon(_:completionHandler:)` became the backbone of `setAlternateAppIcon(_:completionHandler:)` and exactly which operating systems/versions support it. Testing is required before release into production and `_setAlternateAppIcon(_:completionHandler:)` may be removed in the future. - -> Note: Given that `setAlternateAppIcon(_:completionHandler:)` was added in iOS 10.3, we can speculate that it supports iOS 10.3+ - -For more information, watch Bostwick's [video](https://www.youtube.com/watch?v=KDVibKGtSVI) on the subject. - -See the full documentation on [`setAlternateAppIcon(_:completionHandler:)`](https://developer.apple.com/documentation/uikit/uiapplication/2806818-setalternateiconname) - -## Adding the Function to Swift - -To make swift recognize this function, just bridge it with Objective-C. To do so, create a `UIApplication+Private.h` file with the following code: -```objc -#indef UIApplication_Private_h -#define UIApplication_Private_h - -@import UIKit; - -@interface UIApplication (Private) - -- (void)_setAlternateIconName:(NSString *)alternateIconName - completionHandler:(void (^)(NSError *error))completionHandler; -@end - -#endif -``` -Then, add the following to a [bridging header file](https://developer.apple.com/documentation/swift/importing-objective-c-into-swift) (you may need to create one): -```objc -#import "UIApplication+Private.h" -``` - -## Method - -We can use roughly the same code as if we were using the public version of this API: -```swift -UIApplication.shared._setAlternateIconName(“AppIcon-2”) { error in - print(“Error to set alternate icons:- \(error?.localizedDescription)”) -} -``` - -## See Also - -- -- -- diff --git a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIMenu/UICustomViewMenuElement.md b/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIMenu/UICustomViewMenuElement.md deleted file mode 100644 index f78fca9..0000000 --- a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIMenu/UICustomViewMenuElement.md +++ /dev/null @@ -1,128 +0,0 @@ -# UICustomViewMenuElement -Include a custom element in your `UIMenu` - -@Metadata { - @TitleHeading("Instance Property") - @PageColor(green) -} - -## Overview - -UICustomViewMenuElement is a class that inherits from UIMenuElement and lets you initialise a menu item with a custom content view. - -It's used in frameworks like ChatKit for the Messages app. - -> Warning: It is unknown when `UICustomViewMenuElement` was added to `UIMenu` and exactly which operating systems/versions support it. Testing is required before release into production and these properties may be removed in the future. - -![An example of this UI](UICustomViewMenuElement-Image) - -## Method - -We can use this code to build our `UICustomViewMenuElement`: -```swift -let UICustomViewMenuElement = NSClassFromString("UICustomViewMenuElement") as! NSObject.Type -let elementWithViewProviderSelector = NSSelectorFromString("elementWithViewProvider:") -let elementWithViewProviderBlock: @convention(block) (UIMenuElement) -> UIView = { _ in return CustomContentView() } -let customViewMenuElement = UICustomViewMenuElement - .perform(elementWithViewProviderSelector, with: elementWithViewProviderBlock) - .takeUnretainedValue() as! UIMenuElement - -let primaryActionHandlerSelector = NSSelectorFromString("setPrimaryActionHandler:") -let primaryActionHandlerBlock: @convention(block) (UIMenuElement) -> Void = { _ in print("Hello, World!") } -customViewMenuElement.perform(primaryActionHandlerSelector, with: primaryActionHandlerBlock) -``` - -## Example - -Here is a full example of this implementation: -```swift -import UIKit - -class ViewController: UIViewController { - override func viewDidLoad() { - super.viewDidLoad() - - let UICustomViewMenuElement = NSClassFromString("UICustomViewMenuElement") as! NSObject.Type - let elementWithViewProviderSelector = NSSelectorFromString("elementWithViewProvider:") - let elementWithViewProviderBlock: @convention(block) (UIMenuElement) -> UIView = { _ in return CustomContentView() } - let customViewMenuElement = UICustomViewMenuElement - .perform(elementWithViewProviderSelector, with: elementWithViewProviderBlock) - .takeUnretainedValue() as! UIMenuElement - - let primaryActionHandlerSelector = NSSelectorFromString("setPrimaryActionHandler:") - let primaryActionHandlerBlock: @convention(block) (UIMenuElement) -> Void = { _ in print("Hello, World!") } - customViewMenuElement.perform(primaryActionHandlerSelector, with: primaryActionHandlerBlock) - - let editBarButtonItem = UIBarButtonItem(systemItem: .edit) - editBarButtonItem.menu = buildMenu(with: customViewMenuElement) - - navigationItem.leftBarButtonItem = editBarButtonItem - } - - func buildMenu(with customViewMenuElement: UIMenuElement) -> UIMenu { - let selectMessagesElement = UIAction(title: "Select Messages", image: UIImage(systemName: "checkmark.circle")) { _ in } - let recentlyDeletedElement = UIAction(title: "Show Recently Deleted", image: UIImage(systemName: "trash")) { _ in } - let editPinsElement = UIAction(title: "Edit Pins", image: UIImage(systemName: "pin")) { _ in } - - let menu = UIMenu(children: [ - UIMenu(options: .displayInline, children: [customViewMenuElement]), - UIMenu(options: .displayInline, children: [selectMessagesElement, editPinsElement]), - UIMenu(options: .displayInline, children: [recentlyDeletedElement]) - ]) - - return menu - } -} - -class CustomContentView: UICollectionReusableView { - override init(frame: CGRect) { - super.init(frame: frame) - - let imageView = UIImageView() - imageView.image = .avatar - imageView.clipsToBounds = true - imageView.layer.cornerRadius = 25 - imageView.layer.cornerCurve = .circular - imageView.backgroundColor = .systemTeal - imageView.translatesAutoresizingMaskIntoConstraints = false - - addSubview(imageView) - - NSLayoutConstraint.activate([ - imageView.topAnchor.constraint(equalTo: topAnchor, constant: 12), - imageView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 12), - imageView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -12), - imageView.widthAnchor.constraint(equalToConstant: 50), - imageView.heightAnchor.constraint(equalToConstant: 50) - ]) - - let stackView = UIStackView() - stackView.axis = .vertical - stackView.translatesAutoresizingMaskIntoConstraints = false - - addSubview(stackView) - - NSLayoutConstraint.activate([ - stackView.leadingAnchor.constraint(equalTo: imageView.trailingAnchor, constant: 9), - stackView.centerYAnchor.constraint(equalTo: centerYAnchor) - ]) - - let titleLabel = UILabel() - titleLabel.text = "Seb Vidal" - titleLabel.font = .preferredFont(forTextStyle: .headline) - - stackView.addArrangedSubview(titleLabel) - - let detailLabel = UILabel() - detailLabel.text = "Name & Photo" - detailLabel.textColor = .secondaryLabel - detailLabel.font = .preferredFont(forTextStyle: .subheadline) - - stackView.addArrangedSubview(detailLabel) - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } -} -``` diff --git a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIMenu/UIMenu.md b/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIMenu/UIMenu.md deleted file mode 100644 index 5c007cc..0000000 --- a/Sources/NotPrivateAPIs/NotPrivateAPIs.docc/UIKit/UIMenu/UIMenu.md +++ /dev/null @@ -1,47 +0,0 @@ -# UIMenu -@Metadata { - @TitleHeading("Class") - @Available(iOS, introduced: "13.0") - @Available("iPadOS", introduced: "13.0") - @Available("Mac Catalyst", introduced: "13.1") - @Available(visionOS, introduced: "1.0") - @PageColor(blue) -} -A container for grouping related menu elements in an app menu or contextual menu. - -## Overview - -Create UIMenu objects and use them to construct the menus and submenus your app displays. You provide menus for your app when it runs on macOS, and key command elements in those menus also appear in the discoverability HUD on iPad when someone presses the Command key. You also use menus to display contextual actions in response to specific interactions with one of your views. Every menu has a title, an optional image, and an optional set of child elements. When someone selects an element from the menu, the system executes the code you provide. The code sample below illustrates adding a menu group that contains two menu elements — New and Open — to the File menu. - -```swift -// Ensure that the builder is modifying the menu bar system. -guard builder.system == UIMenuSystem.main else { return } - - -let newDocument = UIKeyCommand(title: "New", - action: #selector(newDocument(_:)), - input: "n", - modifierFlags: .command) - - -let openDocument = UIKeyCommand(title: "Open...", - action: #selector(openDocument(_:)), - input: "o", - modifierFlags: .command) - - -// Use the .displayInline option to avoid displaying the menu as a submenu, -// and to separate it from the other menu elements using a line separator. -let newMenu = UIMenu(title: "", options: .displayInline, children: [newDocument, openDocument]) - - -// Insert the menu item at the top of the File menu. -builder.insertChild(newMenu, atStartOfMenu: .file) -``` -For examples of how you use UIMenu, see [Adding Menus and Shortcuts to the Menu Bar and User Interface](https://developer.apple.com/documentation/uikit/uicommand/adding_menus_and_shortcuts_to_the_menu_bar_and_user_interface). - -Full Documentation [Here](https://developer.apple.com/documentation/uikit/uimenu) - -## Topics - --