Skip to content

Commit

Permalink
RevenueCatUI: fix CocoaPods build (#3594)
Browse files Browse the repository at this point in the history
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
NachoSoto authored Jan 23, 2024
1 parent 45d4f67 commit 381f926
Showing 1 changed file with 46 additions and 1 deletion.
1 change: 0 additions & 1 deletion RevenueCatUI/Helpers/Optional+Extensions.swift

This file was deleted.

46 changes: 46 additions & 0 deletions RevenueCatUI/Helpers/Optional+Extensions.swift
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()
}
}

}

0 comments on commit 381f926

Please sign in to comment.