Annotation Processing

Hey there!

There’s another question of mine hanging around for a while now.
I wanted to get some dependency injection working in my current project.
Generating my CoreComponent and my AndroidComponent seems to work quite well, so I started to implement an IOSComponent the same way I did for Android.

But somehow it does not seem to generate any classes at all for the ios part now.

I tried using the gradle apt plugin for the compiler, but no matter which keyword I use (apt, compileOnly, annotationProcessor), I only end up getting the CoreComponent and AndroidComponent to work.

Did I miss something on annotation processing with Moe?

EDIT (here is some of the configuration I use for ios and the core module):


  1. Buildscript dependency:
    classpath 'net.ltgt.gradle:gradle-apt-plugin:0.15'
  2. Plugin usage:
    apply plugin: 'net.ltgt.apt'
  3. dependency:
    apt '' or
    compileOnly '' or
    annotationProcessor ''
    none of which works


  1. dependencies:
    compile ''
    compileOnly ''
    they work fine :slight_smile:

@Singleton @Component(modules = {CoreModule.class, IOSModule.class}) public interface IOSComponent { }

@Module public class IOSModule { public IOSModule() { } }

Btw, the AndroidComponent / Module is currently as simple and empty as the IOS part, but it is generated, so I guess there’s no problem with dagger stripping away unused stuff.


1 Like

Did you get this to work? I’m running into the same issue.

Hello, Adam!

Unfortunately, I haven’t been able to solve the problem yet either. Unfortunately, there also seem to be few people who are well versed in this subject.

Best regards!

Hi @TheWhiteLlama and @AdamN,

could you please share your project (or a simplified test project) that exhibits the problem? We are using Dagger2 in cross-platform MOE projects without any issue.

Best Regards,

Hi @kisg,

I have a test project that exhibits this problem. Here is a link to the project on my Google Drive

Any help would be greatly appreciated.


1 Like

Hi kisg,

I wanted to follow up regarding the test project I uploaded and see what I’m doing incorrectly regarding adding Dagger to all 3 modules?

Thanks again for taking time to look at this!

I have figured out how to get Dagger to work with MOE. Bellow is a link to Google Drive with a test project for anyone that would like to view how to implement Dagger 2 with MOE on the iOS side.

Also, if you would like the iOS dagger generated files to be viewable from code without having to deal with highlighting issues put this code into the iOS build.gradle to allow the IDE to see the generated files from Dagger

/ At the moment for non-Android projects you need to explicitly
// mark the code generated by kapt as ‘generated source code’
// for correct highlighting and resolve in IDE.
idea {
module {
sourceDirs += file(‘build/generated/source/kapt/main’)
generatedSourceDirs += file(‘build/generated/source/kapt/main’)