IntrepidPursuits / swift-wisdom

A collection of additions to the Swift Standard Library created by Intrepid Pursuits developers
MIT License
39 stars 14 forks source link

Make the pod iPhone extension-compliant #170

Closed bobgilmore closed 4 years ago

bobgilmore commented 4 years ago

The pod contains a reference to UIApplication.open(_:), which is not permitted for Extensions (such as "Today Widgets"). For reasons I don't understand, Xcode 10 allowed my app and its extension, both of which rely heavily on this pod, to compile. But now, Xcode 11 is correctly preventing the extension from compiling do to the presence of this call.

I see three potential solutions:

  1. The one in this PR. Requires major version bump. Simply remove the offending function call, and mark the one function that uses it as unavailable at compile-time (and provide a good error message). Since the function that is being made unavailable is small (3 or 4 lines of code), well-known, easily searchable, and available in the pod source (#ifdef'd out), this should be a minimal burden on pod clients.
  2. Requires major version bump. Move the offending call to a separate directory, and out of the "core" spec. Create a separate subspec to contain the "app-only functionality." Since this would, at present, contain ONE three-line function, this seems like overkill. Further, while option (1) can be self-documenting with its errors, option (2) can't be. We can't have an unavailable version in the core spec and an available version in the subspec.
  3. Requires minor version bump, but then requires downstream pods to change. Move the offending call to a separate directory, but leave it in the "core" spec, leaving the core spec as app-only. Create a separate subspec to expose the "extension-only" subset (everything except this one function). As I said above, this would require only a minor update to this pod, but any downstream podspecs that rely on this pod would need to change to include only the "extension-only" subset. IMO that's more trouble than it's worth for this single function.
ipbuildserver commented 4 years ago
5 Warnings
:warning: ResultTests.swift#L15 - SwiftWisdomTests/CommonTypes/ResultTests.swift#L15: ‘IPResult’ is deprecated: use Swift.Result instead
private final let successfulResult = IPResult<Int>.success(1)
:warning: ResultTests.swift#L16 - SwiftWisdomTests/CommonTypes/ResultTests.swift#L16: ‘IPResult’ is deprecated: use Swift.Result instead
private final let failureResult = IPResult<Any>.failure(ResultError.error)
:warning: UnsignedInteger+ExtensionsTests.swift#L16 - SwiftWisdomTests/StandardLibrary/Numbers/UnsignedInteger+ExtensionsTests.swift#L16: ‘random(inRange:)’ is deprecated: Use Int.random(in:) instead
XCTAssert(positives.contains(random(inRange: positives)))
:warning: UnsignedInteger+ExtensionsTests.swift#L18 - SwiftWisdomTests/StandardLibrary/Numbers/UnsignedInteger+ExtensionsTests.swift#L18: ‘random(inRange:)’ is deprecated: Use Int.random(in:) instead
XCTAssert(negatives.contains(random(inRange: negatives)))
:warning: UnsignedInteger+ExtensionsTests.swift#L20 - SwiftWisdomTests/StandardLibrary/Numbers/UnsignedInteger+ExtensionsTests.swift#L20: ‘random(inRange:)’ is deprecated: Use Int.random(in:) instead
XCTAssert(mixed.contains(random(inRange: mixed)))
1 Message
:book: Executed 174 tests, with 0 failures (0 unexpected) in 0.335 (0.398) seconds

Generated by :no_entry_sign: Danger

wolfe719 commented 4 years ago

I like Paul's suggestion more than making the function call @available -- which would cause anyone depending upon the call to have a silent failure, and have no idea why - suddenly - their ip_openSettingsApp() suddenly does not do anything?

bobgilmore commented 4 years ago

I like Paul's suggestion more than making the function call @available -- which would cause anyone depending upon the call to have a silent failure, and have no idea why - suddenly - their ip_openSettingsApp() suddenly does not do anything?

@wolfe719 That was my initial reaction to @jpmendel 's comment as well, but I think what he means is to do what I'm doing, except that I should replace the iOS with a *. Because, even though this pod is basically unusable on Mac, might as well be precise and say that this function is not available anywhere at all.

bobgilmore commented 4 years ago
Screen Shot 2019-10-04 at 10 21 48 AM Screen Shot 2019-10-04 at 10 21 58 AM