Skip to content

Commit 718a965

Browse files
committed
Merge pull request #546 from madvay/faq0.5
Faq 0.5 update
2 parents 5692f15 + b8f45cb commit 718a965

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

FAQ.md

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Paste the results below, replacing existing contents.
3131
- [Why is my clean build failing?](#why-is-my-clean-build-failing)
3232
- [How do I include Java files from additional source directories?](#how-do-i-include-java-files-from-additional-source-directories)
3333
- [How do I develop with Swift?](#how-do-i-develop-with-swift)
34-
- [How do I solve 'File not found' import error in Xcode?](#how-do-i-solve-file-not-found-import-error-in-xcode)
34+
- [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)
3535
- [How do I work with Package Prefixes?](#how-do-i-work-with-package-prefixes)
3636
- [How do I enable ARC for my translated Objective-C classes?](#how-do-i-enable-arc-for-my-translated-objective-c-classes)
3737
- [How do I call finalConfigure()?](#how-do-i-call-finalconfigure)
@@ -79,18 +79,22 @@ Now try building again.
7979

8080
### How do I develop with Xcode?
8181

82-
The J2ObjC Gradle Plugin configures your Xcode project with [CocoaPods](https://cocoapods.org/).
82+
The J2ObjC Gradle Plugin can configure your Xcode project with [CocoaPods](https://cocoapods.org/).
8383
To take advantage of this, specify the directory that contains `PROJECT.xcodeproj` as
84-
the `xcodeProjectDir` in your `j2objcConfig` per the [Quick Start Guide](README.md#quick-start-guide).
84+
the `xcodeProjectDir` in your shared `j2objcConfig` per the [Quick Start Guide](README.md#quick-start-guide).
85+
Gradle projects that `shared` depends on must not specify `xcodeProjectDir` so that only one project
86+
controls the Xcode updates.
8587

8688
After running `j2objcXcode`, open the `.xcworkspace` file in Xcode. If the `.xcodeproj` file
8789
is opened in Xcode then CocoaPods will fail. This will appear as an Xcode build time error:
8890

8991
library not found for -lPods-IOS-APP-j2objc-shared
9092

91-
If you don't use CocoaPods, do not specify the `xcodeProjectDir` option;
92-
you'll have to manually add the static libraries and translated header directories
93-
to your Xcode project, and `j2objcXcode` will not do anything.
93+
The above system uses CocoaPods and is the quickest way to build in Xcode with this plugin.
94+
If you wish to avoid using CocoaPods, do not specify the `xcodeProjectDir` option and instead
95+
[manually](#how-do-i-manually-configure-my-xcode-project-to-use-the-translated-libraries)
96+
add the static libraries and translated header directories to your Xcode project. The
97+
`j2objcXcode` task will not do anything.
9498

9599
Also see the FAQ note on [developing with Swift](#how-do-i-develop-with-swift).
96100

@@ -283,7 +287,7 @@ sourceSets {
283287
To work with Swift in Xcode, you need to configure a
284288
[bridging header](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-XID_81).
285289
Within that bridging header, include the files needed for using the JRE and any classes that
286-
you'd like to access from Swift code. Also see the FAQ item on [file not found](#how-do-i-solve-file-not-found-import-error-in-xcode) errors.
290+
you'd like to access from Swift code.
287291

288292
```objective-c
289293
// File: ios/IOS-APP/IOS-APP-bridging-header.h
@@ -299,32 +303,31 @@ you'd like to access from Swift code. Also see the FAQ item on [file not found](
299303
```
300304

301305

302-
### How do I solve 'File not found' import error in Xcode?
306+
### How do I manually configure my Xcode project to use the translated libraries?
303307

304-
This is typically caused by a limitation of Xcode that expects all the source to be in a
305-
top-level directory. You need to use the `--no-package-directories` argument to flatten
306-
the hierarchy. The plugin will warn if two files are mapped to a conflicting name.
308+
Using CocoaPods is the quickest way to use the plugin. To configure Xcode manually,
309+
you will need to modify your Xcode project's build settings.
307310

308-
```groovy
309-
j2objcConfig {
310-
translateArgs '--no-package-directories'
311-
...
312-
}
313-
```
311+
In each case, you need to make sure the specification of the path is relative to the location
312+
of the Xcode project. We'll assume your J2ObjC distribution is at `/J2OBJC_HOME`.
314313

315-
If you'd like to preserve your folder hierarchy, you can instead change your
316-
[USER_HEADER_SEARCH_PATHS](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW21)
317-
setting in your Xcode projects to include the `shared/build/j2objcOutputs/src/main/objc` folder.
314+
1. Add `/J2OBJC_HOME/include` and `shared/build/j2objcOutputs/src/main/objc` to
315+
[`USER_HEADER_SEARCH_PATHS`](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW21).
318316

319-
Example error:
317+
2. Add `-lshared-j2objc` and `-ljre_emul` to `OTHER_LD_FLAGS`. If you also use Guava, JSR 305,
318+
etc., you will need to add appropriate OTHER_LD_FLAGS for them as well.
320319

321-
```
322-
Bridging-Header.h:6:9: note: in file included from Bridging-Header.h:6:
323-
#import "MyClass.h"
324-
^
325-
Template.h:10:10: error: 'com/test/AnotherClass.h' file not found
326-
#include "com/test/AnotherClass.h"
327-
```
320+
2. For each build configuration and platform applicable to your project, add the following `LIBRARY_SEARCH_PATHS`:
321+
* iOS Debug: /J2OBJC_HOME/lib, shared/build/j2objcOutputs/lib/iosDebug
322+
* iOS Release: /J2OBJC_HOME/lib, shared/build/j2objcOutputs/lib/iosRelease
323+
* OS X Debug: /J2OBJC_HOME/lib/macosx, shared/build/j2objcOutputs/lib/x86_64Debug
324+
* OS X Release: /J2OBJC_HOME/lib/macosx, shared/build/j2objcOutputs/lib/x86_64Release
325+
326+
3. Follow the instructions on "Build Phases" (only) [here](http://j2objc.org/docs/Xcode-Build-Rules.html#update-the-build-settings).
327+
328+
In each case, if the setting has existing values, append the ones above.
329+
Wherever `shared` appears above, duplicate that value for every J2ObjC project used,
330+
including all transitive dependencies.
328331

329332
### How do I work with Package Prefixes?
330333

0 commit comments

Comments
 (0)