Skip to content

Commit

Permalink
xcodeTargetsManualConfig
Browse files Browse the repository at this point in the history
- Manual config mode for Xcode targets in Podfile
- FAQ to explain how to use this
- Better "DO NOT MODIFY" lines for "pod method" + upgrade logic
- Fixes #561
- Fixes #562
  • Loading branch information
brunobowden committed Jan 12, 2016
1 parent b2effff commit 0d7a5c4
Show file tree
Hide file tree
Showing 4 changed files with 806 additions and 122 deletions.
54 changes: 54 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Paste the results below, replacing existing contents.
- [Why is my clean build failing?](#why-is-my-clean-build-failing)
- [How do I include Java files from additional source directories?](#how-do-i-include-java-files-from-additional-source-directories)
- [How do I develop with Swift?](#how-do-i-develop-with-swift)
- [How do I manually configure the Cocoapods Podfile?](#how-do-i-manually-configure-the-cocoapods-podfile)
- [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)
- [How do I update my J2ObjC translated code from Xcode?](#how-do-i-update-my-j2objc-translated-code-from-xcode)
- [How do I work with Package Prefixes?](#how-do-i-work-with-package-prefixes)
Expand Down Expand Up @@ -254,6 +255,7 @@ with `translateArgs`.
Make sure your arguments are separate strings, not a single space-concatenated string.

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

```gradle
// File: shared/build.gradle
sourceSets {
main {
java {
Expand Down Expand Up @@ -333,6 +336,57 @@ you'd like to access from Swift code.
```


### How do I manually configure the Cocoapods Podfile?

The plugin will try to automatically update the Cocoapods Podfile but that may fail if
the Podfile is too complex. In that situation, you can manually configure the pod method.

```gradle
// File: shared/build.gradle
j2objcConfig {
xcodeTargetsManualConfig true
...
}
```

The "pod method" definition will still be added automatically (e.g.
`def j2objc_shared...`). However, the "pod method" will not be added to any
targets, so that needs to be done manually. See example of the Podfile below:

```
// File: ios/Podfile
...
# J2ObjC Gradle Plugin - PodMethods - DO NOT MODIFY START - can be moved as a block
def j2objc_shared
pod 'j2objc-shared-debug', :configuration => ['Debug'], :path => '../shared/build/j2objcOutputs'
pod 'j2objc-shared-release', :configuration => ['Release'], :path => '../shared/build/j2objcOutputs'
end
# J2ObjC Gradle Plugin - PodMethods - DO NOT MODIFY END
<SOME COMPLEX RUBY>
...
# NOTE: this line must be added manually for the relevant targets:
j2objc_shared
...
end
```

To disable all modifications of the Podfile, disable the `j2objcXcode` task.
This will also skip the `pod install` step. The podspec files will still
be written (done by the `j2objcPodspec` task).

```gradle
// File: shared/build.gradle
j2objcConfig {
...
}
j2objcXcode {
enabled = false
}
```


### How do I manually configure my Xcode project to use the translated libraries?

Using CocoaPods is the quickest way to use the plugin. To configure Xcode manually,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,17 @@ class J2objcConfig {
appendArgs(this.xcodeTargetsWatchos, 'xcodeTargetsWatchos', false, xcodeTargetsWatchos)
}

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


protected boolean finalConfigured = false
/**
Expand Down
Loading

0 comments on commit 0d7a5c4

Please sign in to comment.