-
-
Notifications
You must be signed in to change notification settings - Fork 53
Broken Build #5
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
Comments
Hi @rhonyabdullah, It's working fine but might contains some imports issue on the iOS Side because To Use the iOS Imports section you must have a mac otherwise you'll get the imports issue. If you gave Mac then you'll not get any issue regarding these imports. But the build section works perfectly fine. Checkout what's the issue you are facing? If you need any help. Please comment it down. |
Helo @KhubaibKhan4 Here is the result when i'm running the Checking out from the last version, if i'm syncing the project this error occurs:
This is looks like caused by the napier version is not found, so i try to upgrade it to ![]() At this point, i'm trying to do some workaround: @file:OptIn(ExperimentalForeignApi::class)
package org.company.app
import YouTubeDatabase.db.YoutubeDatabase
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.interop.UIKitView
import app.cash.sqldelight.db.SqlDriver
import app.cash.sqldelight.driver.native.NativeSqliteDriver
import kotlinx.cinterop.BetaInteropApi
import kotlinx.cinterop.CValue
import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.ObjCObjectVar
import kotlinx.cinterop.allocPointerTo
import kotlinx.cinterop.memScoped
import kotlinx.cinterop.pointed
import kotlinx.cinterop.value
import platform.AVFoundation.AVPlayer
import platform.AVFoundation.AVPlayerLayer
import platform.AVFoundation.play
import platform.AVKit.AVPlayerViewController
import platform.CoreGraphics.CGRect
import platform.Foundation.NSError
import platform.Foundation.NSLocale
import platform.Foundation.NSURL
import platform.Foundation.NSURLConnection
import platform.Foundation.NSURLRequest
import platform.Foundation.NSURLResponse
import platform.Foundation.countryCode
import platform.Foundation.currentLocale
import platform.Foundation.sendSynchronousRequest
import platform.QuartzCore.CATransaction
import platform.QuartzCore.kCATransactionDisableActions
import platform.UIKit.UIActivityViewController
import platform.UIKit.UIAlertAction
import platform.UIKit.UIAlertActionStyle
import platform.UIKit.UIAlertController
import platform.UIKit.UIAlertControllerStyle
import platform.UIKit.UIApplication
import platform.UIKit.UIDevice
import platform.UIKit.UIView
internal actual fun openUrl(url: String?) {
val nsUrl = url?.let { NSURL.URLWithString(it) } ?: return
UIApplication.sharedApplication.openURL(nsUrl)
}
@Composable
internal actual fun VideoPlayer(modifier: Modifier, url: String?, thumbnail: String?) {
val player = remember { AVPlayer(uRL = NSURL.URLWithString(url.orEmpty())!!) }
val playerLayer = remember { AVPlayerLayer() }
val avPlayerViewController = remember { AVPlayerViewController() }
avPlayerViewController.player = player
avPlayerViewController.showsPlaybackControls = true
playerLayer.player = player
// Use a UIKitView to integrate with your existing UIKit views
UIKitView(
factory = {
// Create a UIView to hold the AVPlayerLayer
val playerContainer = UIView()
playerContainer.addSubview(avPlayerViewController.view)
// Return the playerContainer as the root UIView
playerContainer
},
onResize = { view: UIView, rect: CValue<CGRect> ->
CATransaction.begin()
CATransaction.setValue(true, kCATransactionDisableActions)
view.layer.setFrame(rect)
playerLayer.setFrame(rect)
avPlayerViewController.view.layer.frame = rect
CATransaction.commit()
},
update = { view ->
player.play()
avPlayerViewController.player!!.play()
},
modifier = modifier
)
}
@Composable
internal actual fun provideShortCuts(){
return
}
@Composable
internal actual fun Notify(message: String) {
val alertController = UIAlertController.alertControllerWithTitle(
title = UIDevice.currentDevice.systemName,
message = message,
preferredStyle = UIAlertControllerStyle.MAX_VALUE
)
alertController.addAction(
UIAlertAction.actionWithTitle(
"OK",
style = UIAlertActionStyle.MAX_VALUE,
handler = null
)
)
val viewController = UIApplication.sharedApplication.keyWindow?.rootViewController
viewController?.presentViewController(alertController, animated = true, completion = null)
}
@Composable
internal actual fun ShareManager(title: String, videoUrl: String) {
val viewController = UIApplication.sharedApplication.keyWindow?.rootViewController
val activityItems = listOf("$title: $videoUrl")
val activityViewController = UIActivityViewController(activityItems, null)
viewController?.presentViewController(activityViewController, true, null)
}
@Composable
internal actual fun ShortsVideoPlayer(url: String?) {
val player = remember { AVPlayer(uRL = NSURL.URLWithString(url.orEmpty())!!) }
val playerLayer = remember { AVPlayerLayer() }
val avPlayerViewController = remember { AVPlayerViewController() }
avPlayerViewController.player = player
avPlayerViewController.showsPlaybackControls = true
playerLayer.player = player
// Use a UIKitView to integrate with your existing UIKit views
UIKitView(
factory = {
// Create a UIView to hold the AVPlayerLayer
val playerContainer = UIView()
playerContainer.addSubview(avPlayerViewController.view)
// Return the playerContainer as the root UIView
playerContainer
},
onResize = { view: UIView, rect: CValue<CGRect> ->
CATransaction.begin()
CATransaction.setValue(true, kCATransactionDisableActions)
view.layer.setFrame(rect)
playerLayer.setFrame(rect)
avPlayerViewController.view.layer.frame = rect
CATransaction.commit()
},
update = { view ->
player.play()
avPlayerViewController.player!!.play()
},
modifier = Modifier
)
}
internal actual fun UserRegion(): String {
return NSLocale.currentLocale.countryCode ?: "us"
}
@OptIn(BetaInteropApi::class)
@Composable
internal actual fun isConnected(retry: () -> Unit): Boolean{
val url = NSURL.URLWithString("https://www.google.com")
val request = NSURLRequest.requestWithURL(url ?: return false)
val response = memScoped {
allocPointerTo<ObjCObjectVar<NSURLResponse?>>()
}
val error = memScoped {
allocPointerTo<ObjCObjectVar<NSError?>>()
}
val data = NSURLConnection.sendSynchronousRequest(request, response.value, error.value)
if (data != null) {
return true
} else {
val nsError = error.pointed?.value
if (nsError != null /*&& nsError.domain == NSErrorDomain*/) {
return nsError.code != -1009L
}
}
return false
}
actual class DriverFactory actual constructor(){
actual fun createDriver(): SqlDriver {
return NativeSqliteDriver(YoutubeDatabase.Schema,"YouTubeDatabase.db")
}
} Now there is all of the errors resolved then when i'm trying to rebuild the project its leading to another errors: After doing a lot of workaround the project still errors when i try to build PS: i'm also register a new gradle task for temporary workaround which related with |
@rhonyabdullah Thanks for providing the details. First of all, the Napier contains some issues but you can still run the apps. Further more, you need to imports the iOS Stuff by yourself. And you are getting some issues related to web app about the cashapp drivers, Basically you need to install npm and build this then it will work fine. |
This project is broken, i'm unable to build it. Some of the imports also error on the
iosMain.kt
file did you try to build this project on the Android Studio @KhubaibKhan4 ?The text was updated successfully, but these errors were encountered: