Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iOS KMP resources #685

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app-ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
830BFA7C2C74EBF40017A600 /* compose-resources in Resources */ = {isa = PBXBuildFile; fileRef = 830BFA7B2C74EBF40017A600 /* compose-resources */; };
8C31F46B2BF6909A003F1BBA /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 8C31F46A2BF6909A003F1BBA /* GoogleService-Info.plist */; };
8C7DACB72BCBCCB0002C298A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8C7DACB02BCBCCB0002C298A /* Preview Assets.xcassets */; };
8C7DACB82BCBCCB0002C298A /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C7DACB22BCBCCB0002C298A /* App.swift */; };
Expand All @@ -15,6 +16,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
830BFA7B2C74EBF40017A600 /* compose-resources */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "compose-resources"; path = "../../app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosSimulatorArm64/compose-resources"; sourceTree = "<group>"; };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

8C31F46A2BF6909A003F1BBA /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
8C772B152BCBCBCA00F2BADC /* DroidKaigi2024App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DroidKaigi2024App.app; sourceTree = BUILT_PRODUCTS_DIR; };
8C7DACB02BCBCCB0002C298A /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -42,6 +44,7 @@
8C772B0C2BCBCBCA00F2BADC = {
isa = PBXGroup;
children = (
830BFA7B2C74EBF40017A600 /* compose-resources */,
C412816C2C149FB500B458D1 /* DroidKaigi2024App-Info.plist */,
8C7DACC22BCBD111002C298A /* App */,
8C7DACC12BCBD0F1002C298A /* app-ios */,
Expand Down Expand Up @@ -152,6 +155,7 @@
8C7DACB92BCBCCB0002C298A /* Assets.xcassets in Resources */,
8C7DACB72BCBCCB0002C298A /* Preview Assets.xcassets in Resources */,
8C31F46B2BF6909A003F1BBA /* GoogleService-Info.plist in Resources */,
830BFA7C2C74EBF40017A600 /* compose-resources in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -173,7 +177,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/zsh;
shellScript = "cd ${SRCROOT}/../..\n./gradlew assembleSharedXCFramework --no-configuration-cache\n";
shellScript = "cd ${SRCROOT}/../..\n./gradlew assembleSharedXCFramework --no-configuration-cache\n./gradlew iosSimulatorArm64AggregateResources --no-configuration-cache\n\nRESOURCE_DIR=\"./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosSimulatorArm64\"\n\nmkdir ${RESOURCE_DIR}/compose-resources\ncp -R ${RESOURCE_DIR}/composeResources ${RESOURCE_DIR}/compose-resources\n";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script is this

cd ${SRCROOT}/../..
./gradlew assembleSharedXCFramework --no-configuration-cache
./gradlew iosSimulatorArm64AggregateResources --no-configuration-cache

RESOURCE_DIR="./app-ios-shared/build/kotlin-multiplatform-resources/aggregated-resources/iosSimulatorArm64"

mkdir ${RESOURCE_DIR}/compose-resources
cp -R ${RESOURCE_DIR}/composeResources ${RESOURCE_DIR}/compose-resources

};
/* End PBXShellScriptBuildPhase section */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package io.github.droidkaigi.confsched.ui

import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density
import io.github.droidkaigi.confsched.compose.ComposeEffectErrorHandler
import io.github.droidkaigi.confsched.compose.LocalComposeEffectErrorHandler
import io.github.droidkaigi.confsched.compose.compositionLocalProviderWithReturnValue
Expand All @@ -11,7 +14,11 @@ fun <T> providePresenterDefaults(
userMessageStateHolder: UserMessageStateHolder = rememberUserMessageStateHolder(),
block: @Composable (UserMessageStateHolder) -> T,
): T {
val composeResourceErrorMessages = composeResourceErrorMessages()
var composeResourceErrorMessages: List<ComposeResourceErrorMessage> = listOf()
// For iOS
CompositionLocalProvider(LocalDensity provides Density(1F)) {
composeResourceErrorMessages = composeResourceErrorMessages()
}
val handler = remember(userMessageStateHolder) {
object : ComposeEffectErrorHandler {
override suspend fun emit(throwable: Throwable) {
Expand Down
Loading