感谢@ advayDev1指引我在正确的方向。
该溶液是声明build.gradle
文件SharedCode
模块的如下:
plugins {
id 'java'
id 'com.github.j2objccontrib.j2objcgradle' version '0.6.0-alpha'
}
dependencies {
compile 'com.google.guava:guava:18.0'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.3'
}
j2objcConfig {
autoConfigureDeps true
minVersionIos '8.4'
xcodeProjectDir '../iOS'
xcodeTargetsIos 'MySDK', 'MySDKTests'
finalConfigure()
}
而且如下申报build.gradle
文件TestContracts
模块:基于上述
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'
xcodeProjectDir '../iOS'
xcodeTargetsIos 'MySDKTests'
finalConfigure()
}
,在构建您的项目时,您应该期望您的Podfile
的内容如下:
target 'MySDK' do
platform :ios, '8.4'
j2objc_SharedCode
import_other_pods
end
target 'MySDKTests' do
platform :ios, '8.4'
j2objc_TestContracts
j2objc_SharedCode
import_other_pods
end
J2ObjC Gradle插件中存在一个错误,它不会产生预期的Podfile
输出,但请参阅here了解更多。
感谢您对此回复@ advayDev1。如果我遇到任何麻烦,我会在本周尝试一下,我会告诉你。 –
嘿@ advayDev1,我尝试了你的建议,但我没有看到我期望的'Podfile'中的输出。在这里写下评论太长了,所以我把它作为一个问题添加在这里:[将输出混淆到具有两个Java模块的项目的Podfile](https://github.com/j2objc-contrib/j2objc -gradle/issues/599)当你有时间的时候请看一看,如果你能发现我做错的事情,请告诉我。非常感谢。 –