Skip to content

Commit 3f28584

Browse files
committed
Another 0.5 faq fix
1 parent 4ef448b commit 3f28584

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

FAQ.md

Lines changed: 21 additions & 25 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)
@@ -89,8 +89,9 @@ is opened in Xcode then CocoaPods will fail. This will appear as an Xcode build
8989
library not found for -lPods-IOS-APP-j2objc-shared
9090

9191
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.
92+
you'll have to [manually](#how-do-i-manually-configure-my-xcode-project-to-use-the-translated-libraries)
93+
add the static libraries and translated header directories to your Xcode project,
94+
and `j2objcXcode` will not do anything.
9495

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

@@ -283,7 +284,7 @@ sourceSets {
283284
To work with Swift in Xcode, you need to configure a
284285
[bridging header](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-XID_81).
285286
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.
287+
you'd like to access from Swift code.
287288

288289
```objective-c
289290
// File: ios/IOS-APP/IOS-APP-bridging-header.h
@@ -299,32 +300,27 @@ you'd like to access from Swift code. Also see the FAQ item on [file not found](
299300
```
300301

301302

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

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.
305+
If you do not want to use CocoaPods, you will need to modify your Xcode project's build settings.
306+
In each case, you need to make sure the specification of the path is relative to the location
307+
of the Xcode project. We'll assume your J2ObjC distribution is at `/J2OBJC_HOME`.
307308

308-
```groovy
309-
j2objcConfig {
310-
translateArgs '--no-package-directories'
311-
...
312-
}
313-
```
309+
1. Add `/J2OBJC_HOME/include` and `shared/build/j2objcOutputs/src/main/objc` to
310+
[`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).
314311

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.
312+
2. Add `-lshared-j2objc` and `-ljre_emul` to `OTHER_LD_FLAGS`. If you also use Guava, JSR 305,
313+
etc., you will need to add appropriate OTHER_LD_FLAGS for them as well.
318314

319-
Example error:
315+
2. For each build configuration and platform applicable to your project, add the following `LIBRARY_SEARCH_PATHS`:
316+
* iOS Debug: /J2OBJC_HOME/lib/, shared/build/j2objcOutputs/lib/iosDebug
317+
* iOS Release: /J2OBJC_HOME/lib/, shared/build/j2objcOutputs/lib/iosRelease
318+
* OS X Debug: /J2OBJC_HOME/lib/macosx, shared/build/j2objcOutputs/lib/x86_64Debug
319+
* OS X Release: /J2OBJC_HOME/lib/macosx, shared/build/j2objcOutputs/lib/x86_64Release
320320

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-
```
321+
3. Follow the instructions on "Build Phases" (only) [here](http://j2objc.org/docs/Xcode-Build-Rules.html#update-the-build-settings).
322+
323+
In each case, if the setting has existing values, append the ones above.
328324

329325
### How do I work with Package Prefixes?
330326

0 commit comments

Comments
 (0)