Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Cannot access classes inside generated pod framework #14

Closed
jrocharodrigues opened this issue Jan 30, 2019 · 18 comments
Closed

Cannot access classes inside generated pod framework #14

jrocharodrigues opened this issue Jan 30, 2019 · 18 comments

Comments

@jrocharodrigues
Copy link

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

@AlecKazakova
Copy link
Owner

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

@jrocharodrigues
Copy link
Author

jrocharodrigues commented Jan 30, 2019

Only this:

import UIKit


public var companysdkVersionNumber: Double

@AlecKazakova
Copy link
Owner

does companysdkVersionNumber exist in your common code?

@jrocharodrigues
Copy link
Author

No, it does not

@AlecKazakova
Copy link
Owner

Thaaaaaaaaaats weird

@AlecKazakova
Copy link
Owner

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

@jonasbark
Copy link
Contributor

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

@AlecKazakova
Copy link
Owner

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?

@jonasbark
Copy link
Contributor

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.

@jrocharodrigues
Copy link
Author

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.

@jrocharodrigues
Copy link
Author

@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.

@jrocharodrigues
Copy link
Author

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[];

@jrocharodrigues
Copy link
Author

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

@AlecKazakova
Copy link
Owner

AlecKazakova commented Jan 31, 2019

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?

@jrocharodrigues
Copy link
Author

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?

@jrocharodrigues
Copy link
Author

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 * }
}

@jrocharodrigues
Copy link
Author

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

@pkliang
Copy link

pkliang commented Feb 14, 2019

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

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

No branches or pull requests

4 participants