Skip to content

Commit

Permalink
Fix build failures when importing WebKit, when `-DOS_OBJECT_USE_OBJC=…
Browse files Browse the repository at this point in the history
…0` is set

https://bugs.webkit.org/show_bug.cgi?id=263156
rdar://114438852

Reviewed by Richard Robinson.

Before iOS 17 / macOS Sonoma, it was possible to pull in WebKit headers (directly, or through Swift
modules) when compiling without ObjC-backed OS objects, by specifying `-DOS_OBJECT_USE_OBJC=0` as a
build setting. Some popular libraries and plugins such as the `flutter_inappwebview` plugin (see
also: <pichillilorenzo/flutter_inappwebview#1735>) use this.

However, after we introduced the following public API in iOS 17:

```
@Property (nullable, nonatomic, copy) NSArray<nw_proxy_config_t> *proxyConfigurations;
```

...this became impossible, since `nw_proxy_config_t` would be type-defined to an opaque struct
pointer in `Network.framework`, which is invalid as a type template argument in an `NSArray`. To fix
this, we adopt the same technique used in `Network/NSURLSession+Network.h` and simply expose a
generically-typed `NSArray` in the case where `OS_OBJECT_USE_OBJC` is off.

* Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.h:

Canonical link: https://commits.webkit.org/269371@main
  • Loading branch information
whsieh committed Oct 16, 2023
1 parent 4ed1844 commit 722fe4f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ WK_CLASS_AVAILABLE(macos(10.11), ios(9.0))
@discussion Changing the proxy configurations might interupt current networking operations in any WKWebView that use this WKWebsiteDataStore,
so it is encouraged to finish setting the proxy configurations before starting any page loads.
*/
#if defined(OS_OBJECT_USE_OBJC) && OS_OBJECT_USE_OBJC
@property (nullable, nonatomic, copy) NSArray<nw_proxy_config_t> *proxyConfigurations NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(14.0), ios(17.0));
#else
@property (nullable, nonatomic, copy) NSArray *proxyConfigurations NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(14.0), ios(17.0));
#endif
#endif

@end
Expand Down

0 comments on commit 722fe4f

Please sign in to comment.