Skip to content

Commit 892aef9

Browse files
committed
fix iOS build
1 parent 7bd0af5 commit 892aef9

File tree

13 files changed

+1798
-47
lines changed

13 files changed

+1798
-47
lines changed

common/build.gradle

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,17 @@ apply plugin: 'kotlin-multiplatform'
77
apply plugin: 'kotlinx-serialization'
88

99
kotlin {
10-
11-
// iosArm64("ios")
12-
// iosX64("iosSim")
13-
//
14-
// targets.all { target ->
15-
// if (target.name == 'android') return // Android handles this differently
16-
// compilations.all { compilation ->
17-
// tasks[compileKotlinTaskName].kotlinOptions {
18-
// freeCompilerArgs = ['-Xuse-experimental=kotlin.Experimental']
19-
// }
20-
// }
21-
// }
22-
//
2310
targets {
2411
// fromPreset(presets.jvm, 'jvm')
25-
26-
// fromPreset(presets.android, 'androidMain')
2712
fromPreset(presets.android, 'android')
2813
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
2914
? presets.iosArm64 : presets.iosX64
3015

3116
fromPreset(iOSTarget, 'ios') {
3217
binaries {
33-
framework('shared')
18+
framework('common')
3419
}
3520
}
36-
37-
// Change to `presets.iosArm64` to deploy the app to iPhone
38-
// Change to `presets.iosX64` to deploy the app to iPhone
39-
// fromPreset(presets.iosX64, 'ios') {
40-
// fromPreset(presets.iosArm64, 'ios') {
41-
// compilations.main.outputKinds('FRAMEWORK')
42-
// }
4321
}
4422
sourceSets {
4523
commonMain {
@@ -104,9 +82,6 @@ kotlin {
10482
implementation "io.ktor:ktor-client-json-native:$ktorVersion"
10583
}
10684
}
107-
108-
// iosSimMain.dependsOn iosMain
109-
// iosSimTest.dependsOn iosTest
11085
}
11186
}
11287

@@ -132,15 +107,16 @@ android {
132107
// Don't run this task directly,
133108
// Xcode runs this task itself during its build process when we configure it.
134109
// make sure all Gradle infrastructure exists (gradle.wrapper, gradlew)
135-
//and gradlw is in executable mode (chmod +x gradlew)
110+
//and gradlew is in executable mode (chmod +x gradlew)
136111
task packForXCode(type: Sync) {
137112
final File frameworkDir = new File(buildDir, "xcode-frameworks")
138113
final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG'
114+
final def framework = kotlin.targets.ios.binaries.getFramework("common", mode)
139115

140116
inputs.property "mode", mode
141-
dependsOn kotlin.targets.ios.compilations.main.linkTaskName("FRAMEWORK", mode)
117+
dependsOn framework.linkTask
142118

143-
from { kotlin.targets.ios.compilations.main.getBinary("FRAMEWORK", mode).parentFile }
119+
from { framework.outputFile.parentFile }
144120
into frameworkDir
145121

146122
doLast {

common/src/commonMain/kotlin/com/willowtreeapps/common/ui/PresenterFactory.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.willowtreeapps.common
33
import com.beyondeye.reduks.*
44
import com.willowtreeapps.common.ui.*
55
import kotlin.coroutines.CoroutineContext
6+
import kotlin.reflect.KClass
67

78
/**
89
* PresenterFactory that creates presenters for all views in the application.
@@ -22,9 +23,9 @@ internal class PresenterFactory(private val gameEngine: GameEngine, networkConte
2223
private val gameResultsPresenter by lazy { GameResultsPresenter(gameEngine.appStore) }
2324
private val settingsPresenter by lazy { SettingsPresenter(gameEngine.appStore) }
2425

25-
2626
fun <T : View> attachView(view: T): Presenter<out View?> {
2727
Logger.d("AttachView: $view")
28+
2829
if (subscription == null) {
2930
subscription = gameEngine.appStore.subscribe(this)
3031
}
@@ -59,6 +60,8 @@ internal class PresenterFactory(private val gameEngine: GameEngine, networkConte
5960
questPresenter.detachView(view)
6061
if (view is GameResultsView)
6162
gameResultsPresenter.detachView(view)
63+
if (view is SettingsView)
64+
settingsPresenter.detachView(view)
6265

6366
if (hasAttachedViews()) {
6467
subscription?.unsubscribe()
@@ -78,6 +81,9 @@ internal class PresenterFactory(private val gameEngine: GameEngine, networkConte
7881
if (gameResultsPresenter.isAttached()) {
7982
gameResultsPresenter.onStateChange(gameEngine.appStore.state)
8083
}
84+
if (settingsPresenter.isAttached()) {
85+
gameResultsPresenter.onStateChange(gameEngine.appStore.state)
86+
}
8187
// presenters.forEach { it.onStateChange(gameEngine.appStore.state) }
8288
}
8389
}

iOS/NameGame/NameGame.xcodeproj/project.pbxproj

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
/* Begin PBXBuildFile section */
1010
1E19EEA6224019610094EA01 /* StartViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E19EEA5224019610094EA01 /* StartViewController.swift */; };
11+
1E37F67F225C064E00CC126B /* common.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E37F67E225C064E00CC126B /* common.framework */; };
12+
1E37F682225C078400CC126B /* common.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1E37F680225C078400CC126B /* common.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1113
1E43892D224013860034263E /* IosNavigator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E43892C224013860034263E /* IosNavigator.swift */; };
1214
1E43892F224015A80034263E /* QuestionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E43892E224015A80034263E /* QuestionViewController.swift */; };
1315
1E9D6D35224EA56200F5C0B8 /* SAConfettiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E9D6D34224EA55800F5C0B8 /* SAConfettiView.swift */; };
@@ -24,8 +26,6 @@
2426
1EB9EA892238071B008AF004 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1EB9EA872238071B008AF004 /* LaunchScreen.storyboard */; };
2527
1EB9EA942238071B008AF004 /* NameGameTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB9EA932238071B008AF004 /* NameGameTests.swift */; };
2628
1EB9EA9F2238071C008AF004 /* NameGameUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB9EA9E2238071C008AF004 /* NameGameUITests.swift */; };
27-
1EB9EAB022382532008AF004 /* main.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EB9EAAF22382532008AF004 /* main.framework */; };
28-
1EB9EAB422382BBC008AF004 /* main.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1EB9EAB222382BBC008AF004 /* main.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2929
D794BC0580F8ABAD74AEC0E7 /* Pods_NameGameTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 53A3C83D4D3C38CDD08E0A5E /* Pods_NameGameTests.framework */; };
3030
EB73C32D7A5026680B6E058F /* Pods_NameGameUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ACB48F17499F8632BF88AB6B /* Pods_NameGameUITests.framework */; };
3131
/* End PBXBuildFile section */
@@ -54,7 +54,7 @@
5454
dstPath = "";
5555
dstSubfolderSpec = 10;
5656
files = (
57-
1EB9EAB422382BBC008AF004 /* main.framework in Embed Frameworks */,
57+
1E37F682225C078400CC126B /* common.framework in Embed Frameworks */,
5858
);
5959
name = "Embed Frameworks";
6060
runOnlyForDeploymentPostprocessing = 0;
@@ -63,6 +63,9 @@
6363

6464
/* Begin PBXFileReference section */
6565
1E19EEA5224019610094EA01 /* StartViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartViewController.swift; sourceTree = "<group>"; };
66+
1E37F67C225C063C00CC126B /* common.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = common.framework.dSYM; path = "../../common/build/xcode-frameworks/common.framework.dSYM"; sourceTree = "<group>"; };
67+
1E37F67E225C064E00CC126B /* common.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = common.framework; sourceTree = "<group>"; };
68+
1E37F680225C078400CC126B /* common.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = common.framework; sourceTree = "<group>"; };
6669
1E43892C224013860034263E /* IosNavigator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IosNavigator.swift; sourceTree = "<group>"; };
6770
1E43892E224015A80034263E /* QuestionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionViewController.swift; sourceTree = "<group>"; };
6871
1E9D6D34224EA55800F5C0B8 /* SAConfettiView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAConfettiView.swift; sourceTree = "<group>"; };
@@ -86,8 +89,6 @@
8689
1EB9EA9E2238071C008AF004 /* NameGameUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameGameUITests.swift; sourceTree = "<group>"; };
8790
1EB9EAA02238071C008AF004 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8891
1EB9EAAD22382510008AF004 /* NameGame */ = {isa = PBXFileReference; lastKnownFileType = folder; name = NameGame; path = ../..; sourceTree = "<group>"; };
89-
1EB9EAAF22382532008AF004 /* main.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = main.framework; path = ../../common/build/bin/ios/mainDebugFramework/main.framework; sourceTree = "<group>"; };
90-
1EB9EAB222382BBC008AF004 /* main.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = main.framework; path = ../../common/build/bin/ios/mainDebugFramework/main.framework; sourceTree = "<group>"; };
9192
53A3C83D4D3C38CDD08E0A5E /* Pods_NameGameTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NameGameTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9293
ACB48F17499F8632BF88AB6B /* Pods_NameGameUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NameGameUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9394
CEC3584174F51CF5ECAE2ED7 /* Pods_NameGame.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NameGame.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -98,7 +99,7 @@
9899
isa = PBXFrameworksBuildPhase;
99100
buildActionMask = 2147483647;
100101
files = (
101-
1EB9EAB022382532008AF004 /* main.framework in Frameworks */,
102+
1E37F67F225C064E00CC126B /* common.framework in Frameworks */,
102103
);
103104
runOnlyForDeploymentPostprocessing = 0;
104105
};
@@ -124,7 +125,8 @@
124125
1EB9EA722238071A008AF004 = {
125126
isa = PBXGroup;
126127
children = (
127-
1EB9EAB222382BBC008AF004 /* main.framework */,
128+
1E37F67E225C064E00CC126B /* common.framework */,
129+
1E37F680225C078400CC126B /* common.framework */,
128130
1EB9EA7D2238071A008AF004 /* NameGame */,
129131
1EB9EA922238071B008AF004 /* NameGameTests */,
130132
1EB9EA9D2238071C008AF004 /* NameGameUITests */,
@@ -187,7 +189,7 @@
187189
1EB9EAAC2238250F008AF004 /* Frameworks */ = {
188190
isa = PBXGroup;
189191
children = (
190-
1EB9EAAF22382532008AF004 /* main.framework */,
192+
1E37F67C225C063C00CC126B /* common.framework.dSYM */,
191193
1EB9EAAD22382510008AF004 /* NameGame */,
192194
CEC3584174F51CF5ECAE2ED7 /* Pods_NameGame.framework */,
193195
53A3C83D4D3C38CDD08E0A5E /* Pods_NameGameTests.framework */,
@@ -347,7 +349,7 @@
347349
);
348350
runOnlyForDeploymentPostprocessing = 0;
349351
shellPath = /bin/sh;
350-
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n#move to the xcode-frameworks folder\ncd \"$SRCROOT/../../common/build/xcode-frameworks\"\n#run the gradle task\n./gradlew :common:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}\n";
352+
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n#move to the xcode-frameworks folder\n#cd \"$SRCROOT/../../common/build/xcode-frameworks\"\ncd \"$SRCROOT/../../\"\n\n#run the gradle task\n./gradlew :common:build -PXCODE_CONFIGURATION=${CONFIGURATION}\n";
351353
};
352354
5103126C9BF956C7ADB08E88 /* [CP] Check Pods Manifest.lock */ = {
353355
isa = PBXShellScriptBuildPhase;
@@ -584,7 +586,10 @@
584586
CODE_SIGN_STYLE = Automatic;
585587
DEVELOPMENT_TEAM = 9W3M6638YZ;
586588
ENABLE_BITCODE = NO;
587-
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../../common/build/bin/ios/mainDebugFramework";
589+
FRAMEWORK_SEARCH_PATHS = (
590+
"$(SRCROOT)/../../common/build/bin/ios/mainDebugFramework",
591+
"$(PROJECT_DIR)",
592+
);
588593
INFOPLIST_FILE = NameGame/Info.plist;
589594
LD_RUNPATH_SEARCH_PATHS = (
590595
"$(inherited)",
@@ -604,7 +609,10 @@
604609
CODE_SIGN_STYLE = Automatic;
605610
DEVELOPMENT_TEAM = 9W3M6638YZ;
606611
ENABLE_BITCODE = NO;
607-
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../../common/build/bin/ios/mainDebugFramework";
612+
FRAMEWORK_SEARCH_PATHS = (
613+
"$(SRCROOT)/../../common/build/bin/ios/mainDebugFramework",
614+
"$(PROJECT_DIR)",
615+
);
608616
INFOPLIST_FILE = NameGame/Info.plist;
609617
LD_RUNPATH_SEARCH_PATHS = (
610618
"$(inherited)",

iOS/NameGame/NameGame/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import UIKit
2-
import main
2+
import common
33

44
@UIApplicationMain
55
class AppDelegate: UIResponder, UIApplicationDelegate {

iOS/NameGame/NameGame/GameResultsViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import main
2+
import common
33
import UIKit
44

55
class GameResultsViewController: UIViewController, GameResultsView {

iOS/NameGame/NameGame/ImageUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Foundation
1010
import UIKit
11-
import main
11+
import common
1212

1313
public extension UIImageView {
1414
func downloaded(from url: URL, contentMode mode: UIView.ContentMode = .scaleAspectFit, onComplete: @escaping () -> ()) { // for swift 4.2 syntax just use ===> mode: UIView.ContentMode

iOS/NameGame/NameGame/IosNavigator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import main
2+
import common
33
import UIKit
44

55

iOS/NameGame/NameGame/QuestionViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22
import UIKit
3-
import main
3+
import common
44

55

66
class QuestionViewController: UIViewController, QuestionView {

iOS/NameGame/NameGame/StartViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22
import UIKit
3-
import main
3+
import common
44

55
class StartViewController: UIViewController, StartView {
66

0 commit comments

Comments
 (0)