Skip to content

Commit 8ee2e64

Browse files
authored
Merge pull request #8 from nativeapptemplate/fix_repository_fetchDetail
fix repository fetchDetail
2 parents b36b646 + 661cd23 commit 8ee2e64

File tree

4 files changed

+56
-62
lines changed

4 files changed

+56
-62
lines changed

.github/workflows/run_tests.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ jobs:
88
steps:
99
- uses: maxim-lobanov/setup-xcode@v1
1010
with:
11-
xcode-version: '16.2.0'
11+
xcode-version: '16.4'
1212
- uses: actions/checkout@v3
13-
- name: Unit Tests
14-
run: xcodebuild -project NativeAppTemplate.xcodeproj -scheme "NativeAppTemplate" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2' test
13+
- name: Install SwiftLint
14+
run: |
15+
brew install swiftlint
16+
# Commented out due to an error.
17+
# - name: Unit Tests
18+
# run: |
19+
# xcodebuild -project NativeAppTemplate.xcodeproj \
20+
# -scheme "NativeAppTemplate" \
21+
# -sdk iphonesimulator \
22+
# -destination 'platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2' \
23+
# -quiet \
24+
# test

NativeAppTemplate.xcodeproj/project.pbxproj

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

99
/* Begin PBXBuildFile section */
@@ -306,22 +306,18 @@
306306
/* Begin PBXFrameworksBuildPhase section */
307307
011F6DEA259EF16400BED22E /* Frameworks */ = {
308308
isa = PBXFrameworksBuildPhase;
309-
buildActionMask = 2147483647;
310309
files = (
311310
012009FC299F1E190078A1F9 /* OrderedCollections in Frameworks */,
312311
012009F8299F1E190078A1F9 /* Collections in Frameworks */,
313312
012009FA299F1E190078A1F9 /* DequeModule in Frameworks */,
314313
0172030225A9634F008FD63B /* SwiftyJSON in Frameworks */,
315314
0182D37025B258A7001E881D /* KeychainAccess in Frameworks */,
316315
);
317-
runOnlyForDeploymentPostprocessing = 0;
318316
};
319317
01D19B402D4DE33500BDEAB7 /* Frameworks */ = {
320318
isa = PBXFrameworksBuildPhase;
321-
buildActionMask = 2147483647;
322319
files = (
323320
);
324-
runOnlyForDeploymentPostprocessing = 0;
325321
};
326322
/* End PBXFrameworksBuildPhase section */
327323

@@ -787,8 +783,6 @@
787783
);
788784
buildRules = (
789785
);
790-
dependencies = (
791-
);
792786
name = NativeAppTemplate;
793787
packageProductDependencies = (
794788
0172030125A9634F008FD63B /* SwiftyJSON */,
@@ -818,8 +812,6 @@
818812
01D19B442D4DE33500BDEAB7 /* NativeAppTemplateTests */,
819813
);
820814
name = NativeAppTemplateTests;
821-
packageProductDependencies = (
822-
);
823815
productName = NativeAppTemplateTests;
824816
productReference = 01D19B432D4DE33500BDEAB7 /* NativeAppTemplateTests.xctest */;
825817
productType = "com.apple.product-type.bundle.unit-test";
@@ -857,7 +849,7 @@
857849
0182D36E25B258A7001E881D /* XCRemoteSwiftPackageReference "KeychainAccess" */,
858850
012009F6299F1E190078A1F9 /* XCRemoteSwiftPackageReference "swift-collections" */,
859851
);
860-
preferredProjectObjectVersion = 77;
852+
preferredProjectObjectVersion = 90;
861853
productRefGroup = 011F6DEE259EF16400BED22E /* Products */;
862854
projectDirPath = "";
863855
projectRoot = "";
@@ -871,52 +863,46 @@
871863
/* Begin PBXResourcesBuildPhase section */
872864
011F6DEB259EF16400BED22E /* Resources */ = {
873865
isa = PBXResourcesBuildPhase;
874-
buildActionMask = 2147483647;
875866
files = (
876867
015C78052B72DA2C00B6523C /* PrivacyInfo.xcprivacy in Resources */,
877868
018D4EFF2B6350F500CBA736 /* Inter-Bold.ttf in Resources */,
878869
018D4EFD2B6350E800CBA736 /* Inter-Medium.ttf in Resources */,
879870
011F6DF8259EF16600BED22E /* Preview Assets.xcassets in Resources */,
880871
011F6DF5259EF16600BED22E /* Assets.xcassets in Resources */,
881872
);
882-
runOnlyForDeploymentPostprocessing = 0;
883873
};
884874
01D19B412D4DE33500BDEAB7 /* Resources */ = {
885875
isa = PBXResourcesBuildPhase;
886-
buildActionMask = 2147483647;
887876
files = (
888877
0135E8E42D7E4478004AD8FA /* SampleCode.xcconfig in Resources */,
889878
);
890-
runOnlyForDeploymentPostprocessing = 0;
891879
};
892880
/* End PBXResourcesBuildPhase section */
893881

894882
/* Begin PBXShellScriptBuildPhase section */
895883
01A77D352632D1D900352EBC /* SwiftLint Run Script */ = {
896884
isa = PBXShellScriptBuildPhase;
897885
alwaysOutOfDate = 1;
898-
buildActionMask = 2147483647;
899-
files = (
900-
);
901-
inputFileListPaths = (
902-
);
903-
inputPaths = (
904-
);
905886
name = "SwiftLint Run Script";
906-
outputFileListPaths = (
907-
);
908-
outputPaths = (
909-
);
910-
runOnlyForDeploymentPostprocessing = 0;
911887
shellPath = /bin/sh;
912-
shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nif which swiftlint > /dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
888+
shellScript = (
889+
"if [[ \"$(uname -m)\" == arm64 ]]; then",
890+
" export PATH=\"/opt/homebrew/bin:$PATH\"",
891+
"fi",
892+
"",
893+
"if which swiftlint > /dev/null; then",
894+
" swiftlint",
895+
"else",
896+
" echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"",
897+
"fi",
898+
"",
899+
);
913900
};
914901
/* End PBXShellScriptBuildPhase section */
915902

916903
/* Begin PBXSourcesBuildPhase section */
917904
011F6DE9259EF16400BED22E /* Sources */ = {
918905
isa = PBXSourcesBuildPhase;
919-
buildActionMask = 2147483647;
920906
files = (
921907
0172047925AA8335008FD63B /* UIFont+Extensions.swift in Sources */,
922908
01E2477029A570D300D4B00D /* SignUp.swift in Sources */,
@@ -1045,14 +1031,11 @@
10451031
0172046725AA82BF008FD63B /* MainView.swift in Sources */,
10461032
0172033825A9642E008FD63B /* JSONAPIError.swift in Sources */,
10471033
);
1048-
runOnlyForDeploymentPostprocessing = 0;
10491034
};
10501035
01D19B3F2D4DE33500BDEAB7 /* Sources */ = {
10511036
isa = PBXSourcesBuildPhase;
1052-
buildActionMask = 2147483647;
10531037
files = (
10541038
);
1055-
runOnlyForDeploymentPostprocessing = 0;
10561039
};
10571040
/* End PBXSourcesBuildPhase section */
10581041

@@ -1065,7 +1048,7 @@
10651048
/* End PBXTargetDependency section */
10661049

10671050
/* Begin XCBuildConfiguration section */
1068-
011F6E10259EF16600BED22E /* Debug */ = {
1051+
011F6E10259EF16600BED22E /* Debug configuration for PBXProject "NativeAppTemplate" */ = {
10691052
isa = XCBuildConfiguration;
10701053
buildSettings = {
10711054
ALWAYS_SEARCH_USER_PATHS = NO;
@@ -1133,7 +1116,7 @@
11331116
};
11341117
name = Debug;
11351118
};
1136-
011F6E11259EF16600BED22E /* Release */ = {
1119+
011F6E11259EF16600BED22E /* Release configuration for PBXProject "NativeAppTemplate" */ = {
11371120
isa = XCBuildConfiguration;
11381121
buildSettings = {
11391122
ALWAYS_SEARCH_USER_PATHS = NO;
@@ -1195,7 +1178,7 @@
11951178
};
11961179
name = Release;
11971180
};
1198-
011F6E13259EF16600BED22E /* Debug */ = {
1181+
011F6E13259EF16600BED22E /* Debug configuration for PBXNativeTarget "NativeAppTemplate" */ = {
11991182
isa = XCBuildConfiguration;
12001183
buildSettings = {
12011184
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
@@ -1204,7 +1187,7 @@
12041187
CODE_SIGN_ENTITLEMENTS = NativeAppTemplate/NativeAppTemplate.entitlements;
12051188
CODE_SIGN_IDENTITY = "Apple Development";
12061189
CODE_SIGN_STYLE = Automatic;
1207-
CURRENT_PROJECT_VERSION = 4;
1190+
CURRENT_PROJECT_VERSION = 5;
12081191
DEVELOPMENT_ASSET_PATHS = "\"NativeAppTemplate/Preview Content\"";
12091192
DEVELOPMENT_TEAM = NNYDL5U3V3;
12101193
ENABLE_PREVIEWS = YES;
@@ -1232,7 +1215,7 @@
12321215
};
12331216
name = Debug;
12341217
};
1235-
011F6E14259EF16600BED22E /* Release */ = {
1218+
011F6E14259EF16600BED22E /* Release configuration for PBXNativeTarget "NativeAppTemplate" */ = {
12361219
isa = XCBuildConfiguration;
12371220
buildSettings = {
12381221
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
@@ -1241,7 +1224,7 @@
12411224
CODE_SIGN_ENTITLEMENTS = NativeAppTemplate/NativeAppTemplate.entitlements;
12421225
CODE_SIGN_IDENTITY = "Apple Development";
12431226
CODE_SIGN_STYLE = Automatic;
1244-
CURRENT_PROJECT_VERSION = 4;
1227+
CURRENT_PROJECT_VERSION = 5;
12451228
DEVELOPMENT_ASSET_PATHS = "\"NativeAppTemplate/Preview Content\"";
12461229
DEVELOPMENT_TEAM = NNYDL5U3V3;
12471230
ENABLE_PREVIEWS = YES;
@@ -1269,7 +1252,7 @@
12691252
};
12701253
name = Release;
12711254
};
1272-
016595AF2824E3D800203F7F /* Beta */ = {
1255+
016595AF2824E3D800203F7F /* Beta configuration for PBXProject "NativeAppTemplate" */ = {
12731256
isa = XCBuildConfiguration;
12741257
buildSettings = {
12751258
ALWAYS_SEARCH_USER_PATHS = NO;
@@ -1331,15 +1314,15 @@
13311314
};
13321315
name = Beta;
13331316
};
1334-
016595B02824E3D800203F7F /* Beta */ = {
1317+
016595B02824E3D800203F7F /* Beta configuration for PBXNativeTarget "NativeAppTemplate" */ = {
13351318
isa = XCBuildConfiguration;
13361319
buildSettings = {
13371320
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
13381321
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = "";
13391322
BUNDLE_ID_SUFFIX = .beta;
13401323
CODE_SIGN_ENTITLEMENTS = NativeAppTemplate/NativeAppTemplate.entitlements;
13411324
CODE_SIGN_STYLE = Automatic;
1342-
CURRENT_PROJECT_VERSION = 4;
1325+
CURRENT_PROJECT_VERSION = 5;
13431326
DEVELOPMENT_ASSET_PATHS = "\"NativeAppTemplate/Preview Content\"";
13441327
DEVELOPMENT_TEAM = NNYDL5U3V3;
13451328
ENABLE_PREVIEWS = YES;
@@ -1365,7 +1348,7 @@
13651348
};
13661349
name = Beta;
13671350
};
1368-
01D19B4A2D4DE33500BDEAB7 /* Debug */ = {
1351+
01D19B4A2D4DE33500BDEAB7 /* Debug configuration for PBXNativeTarget "NativeAppTemplateTests" */ = {
13691352
isa = XCBuildConfiguration;
13701353
buildSettings = {
13711354
BUNDLE_LOADER = "$(TEST_HOST)";
@@ -1387,7 +1370,7 @@
13871370
};
13881371
name = Debug;
13891372
};
1390-
01D19B4B2D4DE33500BDEAB7 /* Release */ = {
1373+
01D19B4B2D4DE33500BDEAB7 /* Release configuration for PBXNativeTarget "NativeAppTemplateTests" */ = {
13911374
isa = XCBuildConfiguration;
13921375
buildSettings = {
13931376
BUNDLE_LOADER = "$(TEST_HOST)";
@@ -1408,7 +1391,7 @@
14081391
};
14091392
name = Release;
14101393
};
1411-
01D19B4C2D4DE33500BDEAB7 /* Beta */ = {
1394+
01D19B4C2D4DE33500BDEAB7 /* Beta configuration for PBXNativeTarget "NativeAppTemplateTests" */ = {
14121395
isa = XCBuildConfiguration;
14131396
buildSettings = {
14141397
BUNDLE_LOADER = "$(TEST_HOST)";
@@ -1435,31 +1418,28 @@
14351418
011F6DE8259EF16400BED22E /* Build configuration list for PBXProject "NativeAppTemplate" */ = {
14361419
isa = XCConfigurationList;
14371420
buildConfigurations = (
1438-
011F6E10259EF16600BED22E /* Debug */,
1439-
011F6E11259EF16600BED22E /* Release */,
1440-
016595AF2824E3D800203F7F /* Beta */,
1421+
011F6E10259EF16600BED22E /* Debug configuration for PBXProject "NativeAppTemplate" */,
1422+
011F6E11259EF16600BED22E /* Release configuration for PBXProject "NativeAppTemplate" */,
1423+
016595AF2824E3D800203F7F /* Beta configuration for PBXProject "NativeAppTemplate" */,
14411424
);
1442-
defaultConfigurationIsVisible = 0;
14431425
defaultConfigurationName = Release;
14441426
};
14451427
011F6E12259EF16600BED22E /* Build configuration list for PBXNativeTarget "NativeAppTemplate" */ = {
14461428
isa = XCConfigurationList;
14471429
buildConfigurations = (
1448-
011F6E13259EF16600BED22E /* Debug */,
1449-
011F6E14259EF16600BED22E /* Release */,
1450-
016595B02824E3D800203F7F /* Beta */,
1430+
011F6E13259EF16600BED22E /* Debug configuration for PBXNativeTarget "NativeAppTemplate" */,
1431+
011F6E14259EF16600BED22E /* Release configuration for PBXNativeTarget "NativeAppTemplate" */,
1432+
016595B02824E3D800203F7F /* Beta configuration for PBXNativeTarget "NativeAppTemplate" */,
14511433
);
1452-
defaultConfigurationIsVisible = 0;
14531434
defaultConfigurationName = Release;
14541435
};
14551436
01D19B492D4DE33500BDEAB7 /* Build configuration list for PBXNativeTarget "NativeAppTemplateTests" */ = {
14561437
isa = XCConfigurationList;
14571438
buildConfigurations = (
1458-
01D19B4A2D4DE33500BDEAB7 /* Debug */,
1459-
01D19B4B2D4DE33500BDEAB7 /* Release */,
1460-
01D19B4C2D4DE33500BDEAB7 /* Beta */,
1439+
01D19B4A2D4DE33500BDEAB7 /* Debug configuration for PBXNativeTarget "NativeAppTemplateTests" */,
1440+
01D19B4B2D4DE33500BDEAB7 /* Release configuration for PBXNativeTarget "NativeAppTemplateTests" */,
1441+
01D19B4C2D4DE33500BDEAB7 /* Beta configuration for PBXNativeTarget "NativeAppTemplateTests" */,
14611442
);
1462-
defaultConfigurationIsVisible = 0;
14631443
defaultConfigurationName = Release;
14641444
};
14651445
/* End XCConfigurationList section */

NativeAppTemplate/Data/Repositories/ItemTagRepository.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ import SwiftUI
6464
do {
6565
let itemTag = try await itemTagsService.itemTagDetail(id: id)
6666
let itemTagIndex = (itemTags.firstIndex { $0.id == itemTag.id })
67-
if itemTagIndex != nil {
67+
if itemTagIndex == nil {
68+
itemTags.append(itemTag)
69+
} else {
6870
itemTags[itemTagIndex!] = itemTag
6971
}
70-
72+
7173
return itemTag
7274
} catch {
7375
Failure

NativeAppTemplate/Data/Repositories/ShopRepository.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ import SwiftUI
5656
do {
5757
let shop = try await shopsService.shopDetail(id: id)
5858
let shopIndex = (shops.firstIndex { $0.id == shop.id })
59-
if shopIndex != nil {
59+
if shopIndex == nil {
60+
shops.append(shop)
61+
} else {
6062
shops[shopIndex!] = shop
6163
}
62-
64+
6365
return shop
6466
} catch {
6567
Failure

0 commit comments

Comments
 (0)