-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RevenueCatUI
: fix CocoaPods build (#3594)
Fixes https://circleci.com/gh/RevenueCat/purchases-ios/163464 Unfortunately CocoaPods does not support symlinks, and neither `pod spec lint` nor our installation tests (because they use a local reference) can catch that. This replaces it with a copy of the file.
- Loading branch information
Showing
1 changed file
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Copyright RevenueCat Inc. All Rights Reserved. | ||
// | ||
// Licensed under the MIT License (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://opensource.org/licenses/MIT | ||
// | ||
// Optional+Extensions.swift | ||
// | ||
// Created by Nacho Soto on 3/30/22. | ||
|
||
import Foundation | ||
|
||
/// Protocol definition to be able to use `Optional` as a type. | ||
internal protocol OptionalType { | ||
|
||
associatedtype Wrapped | ||
|
||
init(optional: Wrapped?) | ||
var asOptional: Wrapped? { get } | ||
|
||
} | ||
|
||
extension Optional: OptionalType { | ||
|
||
init(optional: Wrapped?) { self = optional } | ||
|
||
var asOptional: Wrapped? { return self } | ||
|
||
} | ||
|
||
extension OptionalType { | ||
|
||
/// - Returns: unwrapped value if present. | ||
/// - Throws: `error` if the value is not present. | ||
func orThrow(_ error: @autoclosure () -> Error) throws -> Wrapped { | ||
if let value = self.asOptional { | ||
return value | ||
} else { | ||
throw error() | ||
} | ||
} | ||
|
||
} |