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

Problems with imports #10

Open
enoler opened this issue Aug 31, 2023 · 14 comments
Open

Problems with imports #10

enoler opened this issue Aug 31, 2023 · 14 comments

Comments

@enoler
Copy link

enoler commented Aug 31, 2023

Hello, I am trying to create a Kotlin class based on the swift library facebook-sdk-ios to be able to use one of the native functions of the Facebook SDK.

I installed the package on XCode using the SwiftPackageManager following this instructions.

I followed the steps on the Readme of your plugin and I create inside native/Facebook a file Facebook.swift that looks like:

import FacebookCore
import Foundation

@objc public class FacebookSdk : NSObject {
    @objc public class func getAccessToken() -> String {
        return AccessToken.current
    }
}

However, when I try to build, it appears an error in the console saying:

error: no such module 'FacebookCore'
import FacebookCore
       ^

Is there a way to make the libraries to be imported correctly? Is it even possible to get what I need using your plugin? I don't actually know if this is in the scope of the plugin or I need to find another solution.

Thank you in advance!

@hatteajay1212
Copy link

@enoler i have been coming across the same issue of imports.I am trying to use Alamofire library through cocoapods but getting the same issue of 'no such module Alamofire' for import 'Alamofire'.Have you found any solution for this problem ?

@enoler
Copy link
Author

enoler commented Sep 12, 2023

@enoler i have been coming across the same issue of imports.I am trying to use Alamofire library through cocoapods but getting the same issue of 'no such module Alamofire' for import 'Alamofire'.Have you found any solution for this problem ?

Sadly I did not manage to fix it. If you finally get it, please post it here.

@hatteajay1212
Copy link

hatteajay1212 commented Sep 13, 2023

@enoler have you got any other plugin or library to overcome this problem ?

@enoler
Copy link
Author

enoler commented Sep 13, 2023

@enoler have you got any other plugin or library to overcome this problem ?

No, I did not, actually I postponed the problem to wait for an answer using this plugin

@hatteajay1212
Copy link

hatteajay1212 commented Sep 13, 2023

@enoler thanks for the quick response, will post it here if i manage to fix it.

@enoler
Copy link
Author

enoler commented Sep 14, 2023

@hatteajay1212 I just saw in the comments of this link that is not supported yet but the creator of the plugin is thinking about adding it.

@ttypic Thanks for your work and looking forward for it, honestly if you get how to do it it will be a life changer in the KMM ecosystem.

@ttypic
Copy link
Owner

ttypic commented Sep 14, 2023

@enoler, @hatteajay1212 thank you very much for using the plugin! Right now I don't have enough time to improve this behavior. I hope to come back to this in a month or so. But any help will be very much appreciated.

@yumiki
Copy link

yumiki commented Sep 21, 2023

Hello @ttypic, I'd like to help, but I'm not familiar with how dependencies work for Swift . Could you recommend any resources or provide advice on where I can start learning about this topic?

@RaedGhazal
Copy link

Facing the same issue here, I was trying to use firebase analytics but apparently this is not possible 🙁

@jershell
Copy link

The plugin cant working with dependencies

@codesplode
Copy link

Hi @ttypic, thanks for your hard work on this plugin. I'm also looking to add some sort of support for using a swift dependency with some glue code in swift to make Kotlin multiplatform libraries that don't require separate steps for swift dependencies and copy/pasting files.

I'm not super familiar with the apple build processes for these things, but I'm considering a simply dependency file that does a git checkout of swift package into the native folder and seeing how heavy that is or how it behaves at least. If there is another strategy you recommend based on your knowledge such as a way to make the plugin aware of the dependency and able to enforce that swift package manager adds it in the project using the library, it would be appreciated and I'll happily share the code in the end if it succeeds. Just want to end up on the right path so it is usable for all of us.

@markst
Copy link
Contributor

markst commented Jan 19, 2024

@codesplode to me what would make most sense is to be able to setup a swift package with it's own dependencies.

i.e:

let package = Package(
    name: "YourPackageName",
    dependencies: [
        .package(url: "https://github.com/facebook/facebook-ios-sdk.git", from: "16.3.1")
    ],
    targets: [
        .target(
            name: "YourPackageName",
            dependencies: ["FacebookCore"]),

which can easily be built to a binary using:

swift build

@ttypic I had wondered about creating a new issue relating to this possible feature, but keen to hear your thoughts?

@markst
Copy link
Contributor

markst commented Jan 19, 2024

@ttypic actually taking a real superficial look at the way the plugin works, it seems that createPackageSwift actually creates and compiles the package in order to link? Seem it could be a really simple change in approach to expect the Package.swift to be defined as part of the plugin usage rather than CompileSwiftTask generating.

@menjoo
Copy link

menjoo commented Sep 3, 2024

If you want that, currently, I think an approach like this is needed https://github.com/KodeinKoders/playground-SwiftLib-in-KMMLib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants