Skip to content

Commit c5be992

Browse files
fix: Cache Functionality Fixes and Comprehensive Test Suite (#91)
Co-authored-by: Gareth Reese <[email protected]> Co-authored-by: Gareth Reese <[email protected]>
1 parent 88fdb10 commit c5be992

File tree

18 files changed

+2800
-263
lines changed

18 files changed

+2800
-263
lines changed

.github/workflows/pull-request.yml

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,39 @@ on:
77
branches: [main]
88

99
jobs:
10-
macos-build-14:
10+
macos-latest:
1111
# macOS-latest images are not the most recent
12-
# The macos-latest workflow label currently uses the macOS 12 runner image, which doesn't include the build-tools we need
1312
# The vast majority of macOS developers would be using the latest version of macOS
1413
# Current list here: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners
15-
runs-on: macOS-14
16-
17-
steps:
18-
- uses: actions/checkout@v4
19-
- name: Build (macOS)
20-
run: swift build -v
21-
- name: Run tests
22-
run: swift test -v
23-
24-
macos-build-13:
25-
# Let's also check that the code builds on macOS 13
26-
# At 23rd April 2023 the 'latest' macOS version is macOS 12
27-
runs-on: macOS-13
28-
14+
runs-on: macOS-latest
2915
steps:
3016
- uses: actions/checkout@v4
17+
- name: Check for FLAGSMITH_TEST_API_KEY
18+
run: |
19+
if [ -z "$FLAGSMITH_TEST_API_KEY" ]; then
20+
echo "Warning: FLAGSMITH_TEST_API_KEY environment variable is not set"
21+
exit 1
22+
fi
23+
env:
24+
FLAGSMITH_TEST_API_KEY: ${{ secrets.FLAGSMITH_TEST_API_KEY }}
3125
- name: Build (macOS)
32-
run: swift build -v
33-
- name: Run tests
34-
run: swift test -v
35-
36-
ubuntu-build:
37-
runs-on: ubuntu-latest
38-
39-
steps:
40-
- uses: actions/checkout@v4
41-
- name: Build (Ubuntu)
42-
run: swift build -v
26+
run: swift --version && swift build
4327
- name: Run tests
44-
run: swift test -v
45-
28+
run: swift test
29+
env:
30+
FLAGSMITH_TEST_API_KEY: ${{ secrets.FLAGSMITH_TEST_API_KEY }}
4631
swift-lint:
47-
4832
runs-on: ubuntu-latest
49-
5033
steps:
5134
- uses: actions/checkout@v4
35+
- name: Check for FLAGSMITH_TEST_API_KEY
36+
run: |
37+
if [ -z "$FLAGSMITH_TEST_API_KEY" ]; then
38+
echo "Warning: FLAGSMITH_TEST_API_KEY environment variable is not set"
39+
exit 1
40+
fi
41+
env:
42+
FLAGSMITH_TEST_API_KEY: ${{ secrets.FLAGSMITH_TEST_API_KEY }}
5243

5344
- name: Run SwiftLint
5445
uses: norio-nomura/[email protected]

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ Carthage/Build
5252
# This was causing confusion on PRs and is really just a record of the last time the example
5353
# pods were re-built from scratch. It's not useful to keep in the repo.
5454
Example/Podfile.lock
55+
56+
# Test configuration with real API keys (do not commit)
57+
FlagsmithClient/Tests/test-config.json

Example/FlagsmithClient.xcodeproj/project.pbxproj

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 46;
6+
objectVersion = 77;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -143,14 +143,14 @@
143143
};
144144
};
145145
buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "FlagsmithClient" */;
146-
compatibilityVersion = "Xcode 3.2";
147146
developmentRegion = en;
148147
hasScannedForEncodings = 0;
149148
knownRegions = (
150149
en,
151150
Base,
152151
);
153152
mainGroup = 607FACC71AFB9204008FA782;
153+
preferredProjectObjectVersion = 77;
154154
productRefGroup = 607FACD11AFB9204008FA782 /* Products */;
155155
projectDirPath = "";
156156
projectRoot = "";
@@ -201,13 +201,16 @@
201201
buildActionMask = 2147483647;
202202
files = (
203203
);
204+
inputFileListPaths = (
205+
"${PODS_ROOT}/Target Support Files/Pods-FlagsmithClient_Example/Pods-FlagsmithClient_Example-frameworks-${CONFIGURATION}-input-files.xcfilelist",
206+
);
204207
inputPaths = (
205-
"${PODS_ROOT}/Target Support Files/Pods-FlagsmithClient_Example/Pods-FlagsmithClient_Example-frameworks.sh",
206-
"${BUILT_PRODUCTS_DIR}/FlagsmithClient/FlagsmithClient.framework",
207208
);
208209
name = "[CP] Embed Pods Frameworks";
210+
outputFileListPaths = (
211+
"${PODS_ROOT}/Target Support Files/Pods-FlagsmithClient_Example/Pods-FlagsmithClient_Example-frameworks-${CONFIGURATION}-output-files.xcfilelist",
212+
);
209213
outputPaths = (
210-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FlagsmithClient.framework",
211214
);
212215
runOnlyForDeploymentPostprocessing = 0;
213216
shellPath = /bin/sh;
@@ -350,7 +353,8 @@
350353
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
351354
MTL_ENABLE_DEBUG_INFO = NO;
352355
SDKROOT = iphoneos;
353-
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
356+
SWIFT_COMPILATION_MODE = wholemodule;
357+
SWIFT_OPTIMIZATION_LEVEL = "-O";
354358
VALIDATE_PRODUCT = YES;
355359
};
356360
name = Release;
@@ -362,7 +366,11 @@
362366
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
363367
DEVELOPMENT_TEAM = RYCT86V4LM;
364368
INFOPLIST_FILE = FlagsmithClient/Info.plist;
365-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
369+
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
370+
LD_RUNPATH_SEARCH_PATHS = (
371+
"$(inherited)",
372+
"@executable_path/Frameworks",
373+
);
366374
MODULE_NAME = ExampleApp;
367375
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
368376
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -377,7 +385,11 @@
377385
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
378386
DEVELOPMENT_TEAM = RYCT86V4LM;
379387
INFOPLIST_FILE = FlagsmithClient/Info.plist;
380-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
388+
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
389+
LD_RUNPATH_SEARCH_PATHS = (
390+
"$(inherited)",
391+
"@executable_path/Frameworks",
392+
);
381393
MODULE_NAME = ExampleApp;
382394
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
383395
PRODUCT_NAME = "$(TARGET_NAME)";

Example/FlagsmithClient/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2525
func application(_ application: UIApplication,
2626
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2727
// Override point for customization after application launch.
28-
Flagsmith.shared.apiKey = "<add your API key from the Flagsmith settings page>"
28+
Flagsmith.shared.apiKey = "<add your API key from the Flagsmith dashboard project settings, account, API Key tab here>"
2929

3030
// set default flags
3131
Flagsmith.shared.defaultFlags = [Flag(featureName: "feature_a", enabled: false),

0 commit comments

Comments
 (0)