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>
This commit is contained in:
James BorthwickandCesar de la Vega authored and GitHub committed 2024-06-18 13:14:46 -07:00
1 parent 5331ce90fe
commit 1499538d33
10 files changed
+1673 -9

No files matched your search

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "RevenueCatUITests"
BuildableName = "RevenueCatUITests"
BlueprintName = "RevenueCatUITests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "887A5FB92C1D036200E1A461"
BuildableName = "RevenueCatUI.framework"
BlueprintName = "RevenueCatUI"
ReferencedContainer = "container:RevenueCat.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:RevenueCatUI/RevenueCatUIDev.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "887A5FB92C1D036200E1A461"
BuildableName = "RevenueCatUI.framework"
BlueprintName = "RevenueCatUI"
ReferencedContainer = "container:RevenueCat.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
+7
View File
@@ -235,6 +235,9 @@ private extension SubscriptionPeriod.Unit {
case .week: return .weekOfMonth
case .month: return .month
case .year: return .year
@unknown default:
Logger.warning("Unknown SubscriptionPeriod.Unit")
return .year
}
}
@@ -253,6 +256,7 @@ private extension SubscriptionPeriod {
case .year:
return DateComponents(year: self.value)
@unknown default:
Logger.warning("Unknown SubscriptionPeriod")
return .init()
}
}
@@ -273,6 +277,9 @@ private extension PackageType {
case .unknown, .custom:
return nil
@unknown default:
Logger.warning("Unknown localizationKey")
return nil
}
}
@@ -18,31 +18,39 @@ extension PaywallViewMode {
var displayAllPlansByDefault: Bool {
switch self {
case .fullScreen: return true
#if !os(watchOS)
case .footer: return true
case .condensedFooter: return false
#endif
}
}
var displayAllPlansButton: Bool {
switch self {
case .fullScreen: return false
#if !os(watchOS)
case .footer: return false
case .condensedFooter: return true
#endif
}
}
var shouldDisplayBackground: Bool {
switch self {
case .fullScreen: return true
#if !os(watchOS)
case .footer, .condensedFooter: return false
#endif
}
}
func shouldDisplayInlineOfferDetails(displayingAllPlans: Bool) -> Bool {
switch self {
case .fullScreen: return false
#if !os(watchOS)
case .footer: return false
case .condensedFooter: return !displayingAllPlans
#endif
}
}
+1 -1
View File
@@ -14,7 +14,7 @@
import Foundation
#if COCOAPODS
#if COCOAPODS || !SWIFT_PACKAGE
extension Bundle {
+24
View File
@@ -0,0 +1,24 @@
{
"configurations" : [
{
"id" : "F153BBC4-4E6D-4941-BBAF-962BE3A88B9C",
"name" : "Configuration 1",
"options" : {
}
}
],
"defaultOptions" : {
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:RevenueCat.xcodeproj",
"identifier" : "887A63202C1D174200E1A461",
"name" : "RevenueCatUITestsDev"
}
}
],
"version" : 1
}
+24
View File
@@ -0,0 +1,24 @@
//
// 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
//
// RevenueCatUIDev.h
//
// Created by James Borthwick on 2024-06-14.
#import <Foundation/Foundation.h>
//! Project version number for RevenueCatUIDev.
FOUNDATION_EXPORT double RevenueCatUIDevVersionNumber;
//! Project version string for RevenueCatUIDev.
FOUNDATION_EXPORT const unsigned char RevenueCatUIDevVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <RevenueCatUIDev/PublicHeader.h>
@@ -21,11 +21,11 @@ struct SamplePaywallsList: View {
self.list(with: Self.loader)
.navigationTitle("Example Paywalls")
}
.sheet(item: self.$display) { display in
self.view(for: display)
}
.navigationTitle("Paywalls")
.navigationViewStyle(StackNavigationViewStyle())
.sheet(item: self.$display) { display in
self.view(for: display)
}
.navigationTitle("Paywalls")
.navigationViewStyle(StackNavigationViewStyle())
}
@ViewBuilder