Files
purchases-ios/RevenueCatUI/Helpers/Bundle+Extensions.swift
T
James BorthwickandCesar de la Vega 1499538d33 Xcode project with RevenueCatUI + Tests (#3960)
### RevenueCatUI and its tests are now accessible in the files
navigator:

<img width="555" alt="image"
src="https://github.com/RevenueCat/purchases-ios/assets/109382862/a4067d0a-62e5-43b2-bf77-a8a7ee1dd16e">

### It add two new schemes:

<img width="384" alt="image"
src="https://github.com/RevenueCat/purchases-ios/assets/109382862/94b80848-5cc3-4abc-b132-345d79a6f143">

Use RevenueCatUIDev to build RevenueCatUI, and RevenueCatUITests to run
its tests.

### Linting works:

<img width="716" alt="image"
src="https://github.com/RevenueCat/purchases-ios/assets/109382862/aacfa0bf-84af-494e-a4b1-9434de69b4f8">

### Individual tests can be run from the UI:

<img width="999" alt="image"
src="https://github.com/RevenueCat/purchases-ios/assets/109382862/902c5167-d352-4e6d-a848-c5d6c0e988de">

## N.B.

- Tests must be run via the RevenueCatUITest scheme.
- Xcode sometimes has difficulties switching schemes. If you see the
errors below, **clean the build folder** and try again and it will work
<img width="822" alt="image"
src="https://github.com/RevenueCat/purchases-ios/assets/109382862/0ac8dd77-676c-46e4-bc76-f8edf86f5a79">
- Building with the RevenueCatUIDev scheme creates some warnings related
to switches. Adding in an `@unknown default:` resolves the warning but
causes an error in other configurations ("Default will never be
executed").
<img width="801" alt="image"
src="https://github.com/RevenueCat/purchases-ios/assets/109382862/dcba6e0c-5755-4e5a-b940-ca270242b6bb">
- Because the root Package file was not altered, this PR won't have any
affect on how our package works when integrated via SPM.

---------

Co-authored-by: Cesar de la Vega <cesarvegaro@gmail.com>
2024-06-18 13:14:46 -07:00

45 lines
1.0 KiB
Swift

//
// 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
//
// Bundle+Extensions.swift
//
// Created by Nacho Soto on 10/31/23.
//
import Foundation
#if COCOAPODS || !SWIFT_PACKAGE
extension Bundle {
static let module: Bundle = {
let candidates = [
Bundle.main.resourceURL,
Bundle(for: BundleToken.self).resourceURL
]
// Generated by CocoaPods
let bundleName = "RevenueCat_RevenueCatUI"
for candidate in candidates {
let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
return bundle
}
}
return Bundle(for: BundleToken.self)
}()
}
private final class BundleToken {}
#endif