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

Module 'Realm' not found in v2.2.1 #735

Closed
Gladkov-Art opened this issue Feb 3, 2016 · 31 comments
Closed

Module 'Realm' not found in v2.2.1 #735

Gladkov-Art opened this issue Feb 3, 2016 · 31 comments

Comments

@Gladkov-Art
Copy link

Updated ios-charts to 2.2.1 using Carthage.
Can't build the project any more.
It complains about @import Realm; in Charts-Swift.h file.

@Gladkov-Art
Copy link
Author

Find Realm mentioned in https://github.com/danielgindi/ios-charts#troubleshooting.
How can I fix the issue in my case (attached binaries downloaded using Carthage)?

@danielgindi
Copy link
Collaborator

Hmm... Seems like although Realm is optional, it appears in the header.
@petester42 do you have an idea how to overcome this?
Or will we have to separate the Realm data model to a different repository?

@pmairoldi
Copy link
Collaborator

You don't need a separate repo. You just need to create a workspace and add a second project. Create an "iOS-charts-realm" that depends on "iOS-charts".

@pmairoldi
Copy link
Collaborator

Does linking it weakly do anything?

@danielgindi
Copy link
Collaborator

It prevents the binaries from containing symbols from the realm framework.
The thing is with Swift it includes that nasty @import in the public
header...

Guys I'll separate the Realm stuff to another framework so it will allow
you to compile. I'll try to do it this evening.

@danielgindi
Copy link
Collaborator

@petester42 After I separate the Realm stuff to ChartsRealm.framework - do you know how to configure Podspec and Carthage properly to reference both Charts and ChartsRealm?
I'll need your help there as I'm not a user of those ecosystems.

@pmairoldi
Copy link
Collaborator

As long as you keep the same folder structure podspec will work fine. If you add a workspace with a second project Carthage will also just work.

@pmairoldi
Copy link
Collaborator

Out of curiosity, how do you manage 3rd party dependencies then?

@danielgindi
Copy link
Collaborator

In Objc the optional frameworks do just fine; But in swift it's problematic.
So if we have another framework called ChartsRealm.framework and it references Charts and Realm - then it should be fine.

The only problem now is that seems like Xcode refuses to get to know the new framework. It's embedded - but its classes are hidden. I'll push when I'm done struggling with Xcode...

@pmairoldi
Copy link
Collaborator

If you need any help just ask. I know my way around xcode projects pretty well.

@danielgindi
Copy link
Collaborator

@petester42 I'm attaching two patch files:

separate-project.patch is for separating the Realm stuff to another project, referencing Charts, and ChartsDemo referencing both. This is the way I'd really like it to be, easier to understand for beginners with the library, and less code to "get rid of" for people compiling the sources without Realm.

separate-target.patch is just separating the targets, having additional two targets containing only the Realm stuff, excluded from the Charts target.

In the "separate project" patch, Carthage does not find the ChartsRealm targets, although the schemes are shared, and according to their docs it should recognize.

In both cases - the ChartsDemo refuses to see the classes from ChartsRealm. It compiles and links ChartsRealm so you can see that the dependencies are good - but something went wrong there and a fresh pair of eyes on it wouldn't hurt.

If (when) you manage to solve it - I'd like to include updated instructions in README, to avoid all those issues of "dragged ChartsRealm.xcodeproj to my project, but it says undeclared identifier"

Thanks!

separate-project.patch.txt
separate-target.patch.txt

@pmairoldi
Copy link
Collaborator

Sounds good. I'll check this out in the morning.

@pmairoldi
Copy link
Collaborator

The patch files do not work since they give errors but I just did it myself.

For the carthage issues there will need to be a workspace to hold both projects since carthage cannot build multiple projects that aren't in a workplace. In addition, the realm project will need to have a different product name because if they are both called Charts.framework when it is built they will overwrite each other. The charts demo issues might also be related to the two projects having the same product name.

I know you don't like workspaces but they will be needed for separate projects otherwise we have to go with separate targets. So if you're ok with workspaces ill create a branch with the changes.

@danielgindi
Copy link
Collaborator

Oh I did change the product name, that's not the issie.
Note that when having separate targets the Carthage finds them all and builds fine... The problem is with the demo not seeing symbols from ChartsRealm. A workspace won't solve that.

The end result that I want is that people will be able to easily compile. I'll apply my patches and push to branches so you can see

@danielgindi
Copy link
Collaborator

@petester42 Please see realm-project and realm-target branches.

The first one is the one I prefer - and it contains a workspace just for Carthage compilation, which is the only one containing shared schemes - but it compiles the FBSnapshotTestCase stuff instead.

The second one works fine with Carthage, as it's just different targets inside the same project.

Both still don't compile the ChartsDemo project - it can't see the ChartsRealm symbols...

@pmairoldi
Copy link
Collaborator

Alright cool. I'll look into it tonight.

@raphschwander
Copy link

Hey, I am having a similar problem.
I am using Carthage and get the following errors:

  • module 'Realm' not found
  • Could not build Objective-C module 'Charts'

I don't use Realm.
Any idea @petester42 ?

@pmairoldi
Copy link
Collaborator

Right now if you are using Carthage you will have to also link realm even if you don't use it. If you really don't want to have to link it I suggest using cocoapods for now. As you can tell we are working on separating out realm from the main project.

@pmairoldi
Copy link
Collaborator

I just got to look at this and I fixed it. There were 3 problems:

  1. The schemes were not shared when I opened the carthage.workspace
  2. For the demo instead of importing #import <Charts/Charts.h> it needs to be #import <ChartsRealm/ChartsRealm.h> since you need the realm part and it also contains everything fromCharts`
  3. The podspec was broken with the changes that were made

All this should be fixed in the realm-project branch. You were oh so close ;)

@danielgindi
Copy link
Collaborator

Oh dammit. I knew it was something stupid.
The schemes were shared - but something must have happened.
I was so into the Swift thing, that I forgot about C imports.

Now you see why you need a fresh pair of eyes from time to time :-)

Thanks!

@danielgindi
Copy link
Collaborator

Oh right now the schemes are shared in both the ChartsDemo project, and the Carthage.workspace. I guess the workspace is redundant?

@pmairoldi
Copy link
Collaborator

Ya I think it can be removed. With the latest carthage it works just fine without one. I thought you needed an entry point that contained all the projects but the latest version of carthage doesn't seem to need that anymore.

@danielgindi
Copy link
Collaborator

Oh they say "Carthage will now build all frameworks from all the projects in the repository"

@raphschwander
Copy link

Many thanks ! :)

@danielgindi
Copy link
Collaborator

I will mark this as resolved - a release is coming soon!

@danielgindi
Copy link
Collaborator

@petester42 One thing that bothers me is that Carthage is trying to build FBSnaphostTestCase... Do you know of any way to avoid that? Carthage docs does not offer a solution. It's a new feature that finds all schemes, but that's one too many.

@pmairoldi
Copy link
Collaborator

It finds one too many because there is not cartfile in the root directory. I believe that if cartfile.private is moved to the root then that won't happen since it will know that is not a public thing. Right now it just seem a folder with a project so it builds it.

I was gonna move it but ou wanted to be able to copy the folder which would not work anymore if I did that.

@danielgindi
Copy link
Collaborator

@petester42 Could you take a look at carthage build --no-skip-current --platform tvos?
It randomly fails at building ChartsRealm-TV specifically, with different errors every time.
It could be no such module 'Charts', or module file's minimum deployment target is tvos9.1 v9.1 or various others. This is the only thing keeping me from making a release right now.

@pmairoldi
Copy link
Collaborator

Probably relam has set their minimum target to 9.1 for whatever reason. I'll look at it tonight if this still isn't fixed.

@danielgindi
Copy link
Collaborator

Nope. It sometimes compiles and sometimes not. When using Xcode to bulid it builds fine. When Using xcodebuild - it builds fine the second time. This is really weird.
I ended up packaging it by myself, but that could be an Xcode 7.2 bug as there are some complaints in other git repos...

@pmairoldi
Copy link
Collaborator

I just got this error and I don't really know. Might have to do with how the project is structured. Carthage does not seem to really like the project that depends on another project. I really don't know.

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

4 participants