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

Possible to add *junit* to *spec.libraries* in generated podspec? #600

Open
adil-hussain-84 opened this issue Feb 23, 2016 · 1 comment
Open

Comments

@adil-hussain-84
Copy link

I have a TestContracts Java module in my project that has classes which have JUnit / Hamcrest assertions. I'd like to translate these classes and use them in the tests target of my iOS module. The build.gradle file of my TestContracts module is as follows:

plugins {
    id 'java'
    id 'com.github.j2objccontrib.j2objcgradle' version '0.6.0-alpha'
}

dependencies {
    compile project(':SharedCode')
    compile 'junit:junit:4.12' // this is compile scope deliberately
    compile 'org.hamcrest:hamcrest-core:1.3' // this is compile scope deliberately
}

j2objcConfig {
    autoConfigureDeps true
    minVersionIos '8.4'
    supportedArchs += ['ios_i386']
    translateArgs '--no-package-directories'
    translateArgs '--prefixes', 'prefixes.properties'
    xcodeProjectDir '../iOS'
    xcodeTargetsIos 'RetailSDKTests'
    finalConfigure()
}

The Java to Objective-C translation step of the Gradle build completes but the :iOS:xcodebuild step fails with a linking error. It can't make sense of the JUnit assertions. The problem I've discovered is that the 'junit' library is missing from the podspec files created in the TestContracts/build/j2objcOutputs folder.

So question is: is it possible specify the JUnit and Hamcrest dependencies in a way that they're included in the generated podspec file? And, if so, how?

@adil-hussain-84 adil-hussain-84 changed the title Problem referencing JUnit in translated classes Problem referencing JUnit annotations and assertions in translated classes Feb 23, 2016
@adil-hussain-84
Copy link
Author

I've updated the description of the issue above as I've discovered the root of the problem... but still don't know how to solve the issue so I haven't closed it yet. The best I've come up with right now is to add the following in the "Other linker flags" in Xcode for my tests target:

$(inherited)
-l"junit"

Would be great if I could do this via the build.gradle file instead of hard-coding in my Xcode project.

@adil-hussain-84 adil-hussain-84 changed the title Problem referencing JUnit annotations and assertions in translated classes Possible to add *junit* to *spec.libraries* in generated podspec? Mar 3, 2016
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

1 participant