Skip to content

Commit 2b8eabb

Browse files
committed
Merge pull request #582 from brunobowden/update
xcodeTargetsManualConfig
2 parents 016d060 + 4a1f876 commit 2b8eabb

File tree

4 files changed

+806
-122
lines changed

4 files changed

+806
-122
lines changed

FAQ.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Paste the results below, replacing existing contents.
3232
- [Why is my clean build failing?](#why-is-my-clean-build-failing)
3333
- [How do I include Java files from additional source directories?](#how-do-i-include-java-files-from-additional-source-directories)
3434
- [How do I develop with Swift?](#how-do-i-develop-with-swift)
35+
- [How do I manually configure the Cocoapods Podfile?](#how-do-i-manually-configure-the-cocoapods-podfile)
3536
- [How do I manually configure my Xcode project to use the translated libraries?](#how-do-i-manually-configure-my-xcode-project-to-use-the-translated-libraries)
3637
- [How do I update my J2ObjC translated code from Xcode?](#how-do-i-update-my-j2objc-translated-code-from-xcode)
3738
- [How do I work with Package Prefixes?](#how-do-i-work-with-package-prefixes)
@@ -254,6 +255,7 @@ with `translateArgs`.
254255
Make sure your arguments are separate strings, not a single space-concatenated string.
255256

256257
```gradle
258+
// File: shared/build.gradle
257259
j2objcConfig {
258260
// CORRECT
259261
translateArgs '-use-arc'
@@ -302,6 +304,7 @@ For example, if you want to include files from `src-gen/base` both into your JAR
302304
your Objective C libraries, then add to your `shared/build.gradle`:
303305

304306
```gradle
307+
// File: shared/build.gradle
305308
sourceSets {
306309
main {
307310
java {
@@ -333,6 +336,57 @@ you'd like to access from Swift code.
333336
```
334337

335338

339+
### How do I manually configure the Cocoapods Podfile?
340+
341+
The plugin will try to automatically update the Cocoapods Podfile but that may fail if
342+
the Podfile is too complex. In that situation, you can manually configure the pod method.
343+
344+
```gradle
345+
// File: shared/build.gradle
346+
j2objcConfig {
347+
xcodeTargetsManualConfig true
348+
...
349+
}
350+
```
351+
352+
The "pod method" definition will still be added automatically (e.g.
353+
`def j2objc_shared...`). However, the "pod method" will not be added to any
354+
targets, so that needs to be done manually. See example of the Podfile below:
355+
356+
```
357+
// File: ios/Podfile
358+
...
359+
360+
# J2ObjC Gradle Plugin - PodMethods - DO NOT MODIFY START - can be moved as a block
361+
def j2objc_shared
362+
pod 'j2objc-shared-debug', :configuration => ['Debug'], :path => '../shared/build/j2objcOutputs'
363+
pod 'j2objc-shared-release', :configuration => ['Release'], :path => '../shared/build/j2objcOutputs'
364+
end
365+
# J2ObjC Gradle Plugin - PodMethods - DO NOT MODIFY END
366+
367+
<SOME COMPLEX RUBY>
368+
...
369+
# NOTE: this line must be added manually for the relevant targets:
370+
j2objc_shared
371+
...
372+
end
373+
```
374+
375+
To disable all modifications of the Podfile, disable the `j2objcXcode` task.
376+
This will also skip the `pod install` step. The podspec files will still
377+
be written (done by the `j2objcPodspec` task).
378+
379+
```gradle
380+
// File: shared/build.gradle
381+
j2objcConfig {
382+
...
383+
}
384+
j2objcXcode {
385+
enabled = false
386+
}
387+
```
388+
389+
336390
### How do I manually configure my Xcode project to use the translated libraries?
337391

338392
Using CocoaPods is the quickest way to use the plugin. To configure Xcode manually,

src/main/groovy/com/github/j2objccontrib/j2objcgradle/J2objcConfig.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,17 @@ class J2objcConfig {
714714
appendArgs(this.xcodeTargetsWatchos, 'xcodeTargetsWatchos', false, xcodeTargetsWatchos)
715715
}
716716

717+
/**
718+
* Allows manual config of Xcode targets in the Podfile (default is false).
719+
*
720+
* When set to true, this allows manual configuring of the Podfile targets.
721+
* This is necessary when your Podfile is too complex to be automatically
722+
* updated. It will still add the "Pod Method" (e.g. j2objc_shared) but it
723+
* will not update the targets within the Podfile. When used, you must also
724+
* set xcodeTargets{Ios|Osx|Watchos) to empty.
725+
*/
726+
boolean xcodeTargetsManualConfig = false
727+
717728

718729
protected boolean finalConfigured = false
719730
/**

0 commit comments

Comments
 (0)