AlecKazakova/kotlin-native-cocoapods

Cannot access classes inside generated pod framework

Closed this issue · 18 comments

Hi,

After renaming the dir of my project to remove the -, i was able to successufly generate the pod framework both by invoking ./gradlew createIosDebugArtifacts on the terminal or by building the project directly on xcode, but i cannot access any of the classes it contains.

I can import the module, but when i try to create an object of a type which is part of the multi-platform project it is no recognised.
None of the classes show in the autocomplete, and if i declare the type manual i cannot build the xcode project.

Browsing the pod frameworks on xcode i can see the correct header file is present.

Is this a problem with the pod generation step or am i missing some setting or flag on my xcode project ?
Thanks in advance

if you cmd+click the module from swift what do you see?

Only this:

import UIKit


public var companysdkVersionNumber: Double

does companysdkVersionNumber exist in your common code?

No, it does not

Thaaaaaaaaaats weird

is the code you're trying to reference the module from also inside a pod?

@AlecStrong sounds pretty similar to the issue we talked about in Slack. I didn't find a solution for this myself, yet.

oh right - @jrocharodrigues whats name of the .h file when you cmd+click the module name? Is it Dummy.h

also @jonasbark did that ever get resolved?

Unfortunately no. I ended up using a standard Build Phase that executes the createIosDebugArtifacts task and then copies the Framework to the iOS project where it ultimately is just directly embedded as framework.

is the code you're trying to reference the module from also inside a pod?

@AlecStrong No, it's directly on the main project

oh right - @jrocharodrigues whats name of the .h file when you cmd+click the module name? Is it Dummy.h

@AlecStrong I cannot confirm right now (just left work). Tomorrow i'll confirm that to you.

@AlecStrong I'm now looking at the code at your repository and just remembered something weird i noticed with the module.modulemap file of the generated framework.
In the dummy framwork you have this:
https://github.com/AlecStrong/kotlin-native-cocoapods/blob/595030c524b44ca1b5d09965640c48a75dc903cb/gradle-plugin/src/main/resources/Dummy.framework/Modules/module.modulemap#L2

On the generated framework instead of:
umbrella header "companysdk.h"

there is something like:

umbrella header "companysdk-umbrela.h"

And i'm almost sure that the file companysdk-umbrela.h only imports Foundation/Foundation.h and has no reference to companysdk.h

i'm writing this from the top of my head, so some names can be incorrect, but i think i wrote the gist of it right.
Tomorrow i can confirm all of this, and share the complete files if you think it might help.

Hi @AlecStrong ,
Back with the confirmations from yesterday:

  • When i cmd + click the module name i do not see any file name.
    screenshot 2019-01-31 at 01 33 43

As for the umbrella files, i confirm waht i said yesterday.
Here is the code from the files to see if helps:
companysdk.modulemap

framework module companysdk {
  umbrella header "companysdk-umbrella.h"

  export *
  module * { export * }
}

companysdk-umbrella.h

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif


FOUNDATION_EXPORT double companysdkVersionNumber;
FOUNDATION_EXPORT const unsigned char companysdkVersionString[];

Hi again,

I've been messing around in the project trying to solve the problem, and if a paste the code from companysdk.h into companysdk-umbrella.h i can acess the classes i have in my multi-platform project from swift. But when i try to build the project i get this error:
ld: symbol(s) not found for architecture x86_64

I tried running directly to a device but got similar error:
ld: symbol(s) not found for architecture arm64

sweet, I think we're getting closer.

so if I understand correctly, if you run ./gradlew clean createIosDebugArtifacts the the file build/companysdk.framework/Modules/module.modulemap has

framework module companysdk {
  umbrella header "companysdk-umbrella.h"

  export *
  module * { export * }
}

in it?

can you tell me whats in build/bin/ios/debugFramework/companysdk.framework/Modules/module.modulemap after that clean create?

Hi,
I finally managed to make it work :)
All i had to do was to comment the line
use_frameworks!

on my Podfile and everything works perfectly now.

I'm not really sure if commenting this will have any side effects, or if this should be commented from the beginning...

Is this anything related to your lib?

sweet, I think we're getting closer.

so if I understand correctly, if you run ./gradlew clean createIosDebugArtifacts the the file build/companysdk.framework/Modules/module.modulemap has

framework module companysdk {
  umbrella header "companysdk-umbrella.h"

  export *
  module * { export * }
}

in it?

Correct.

can you tell me whats in build/bin/ios/debugFramework/companysdk.framework/Modules/module.modulemap after that clean create?

framework module companysdk {
    umbrella header "companysdk.h"

    export *
    module * { export * }
}

I'll close the issue since it was an issue on my on my Podspec file

I also have this issue, as my project uses Swift, I can't comment use_frameworks!, any solution for this now?