lukhnos / objclucene

An Objective-C port of Lucene 5.x
MIT License
12 stars 6 forks source link

Problem to build with Xcode 7.3 #1

Closed kevindelord closed 8 years ago

kevindelord commented 8 years ago

Hi,

OSX: 10.11.3 Xcode: 7.3 iOS: 9.3

I have tried for the last 2 days to build on Xcode 7.3 a mobile version of Lucene and make it work within an iOS project.

First, I have tried the solution form the LuceneSearchDemo-iOS repository but the code contains many build errors such as:

- Interface type 'OrgApacheLuceneAnalysisTokenStream' cannot be passed by value; did you forget * in 'OrgApacheLuceneAnalysisTokenStream'?`

- Conflicting types for 'J2OBJC_STATIC_FIELD_GETTER'

I understood that this project is just a small wrapper project around j2objc and the converted objc files from the objclucene. Those objc files have been generated from the repo mobilelucene repository by using j2objc 0.9.8.2-xcode6.

This version of j2objc is now outdated and a new one has been released by Google: j2objc 1.0.2.

So what I did is to:

The java code has been taken from the master branch under mobilelucene/lucene/core/src/java.

I configured the custom j2objc Build Rule within Xcode as follow:

"${J2OBJC_HOME}/j2objc" -d "${PROJECT_DIR}/objclucene" -sourcepath "${PROJECT_DIR}/core_mobilelucene" --no-package-directories -use-arc --no-segmented-headers --swift-friendly --nullability --doc-comments --no-extract-unsequenced -g ${INPUT_FILE_PATH};

And in the Output Files:

${PROJECT_DIR}/objclucene/${INPUT_FILE_BASE}.h
${PROJECT_DIR}/objclucene/${INPUT_FILE_BASE}.m

with -ljre_emul as Compiler Flags.

screenshot 2016-05-12 11 12 02

I followed the official j2objc documentation here and there.

This generates correctly the objective-c files without any error.

But once I try to build them I got errors of the same kind than before:

- TermCollectingRewrite.h:23:57: Cannot find interface declaration for 'OrgApacheLuceneSearchMultiTermQuery_RewriteMethod', superclass of 'OrgApacheLuceneSearchTermCollectingRewrite'

- AutomatonQuery.h:58:1: No known class method for selector 'class'

I have prepared a public repo (based on yours) containing all of this. The setup-j2objc.sh has been updated to fetch the latest j2objc and match the xcode project expectation:

Do you see any reason why this is failing ? Do you know a better solution or if this is simply not possible to achieve?

Maybe I am missing something and my knowledge of mobile Lucene is not good enough, could you maybe release a new version ?

Best regards,

Kevin

lukhnos commented 8 years ago

Take a look at the translation script in Mobile Lucene and use that to derive the Objective-C code. Unfortunately not all of Mobile Lucene is translatable, and that script takes care of that.

Another thing is the translation flags you used. --no-package-directories and --no-segmented-headers guarantee that it will not produce a buildable translation, and it has to do with the fact that (1) Java allows you to use the same class name in different packages (so you need the package subdirectories), and (2) Java allows circular dependency between two Java source files (for example, nested class A.B can extend class C which subclasses A), and that's why you need the segmented headers.

See if you can get the translation script to work. Unfortunately the repos need a lot of updating (Xcode 7 for example). I don't have time to work on those at the moment, but contributions are always welcome. Thanks!

kevindelord commented 8 years ago

Thanks for your help. I have been able to update the transform.py and translate.py scripts.

The problem now is that many java classes can't get translated due to many import and unresolved type errors. Though, the classes generated do builds within an xcode project. It also seems that the generated files are not enough to satisfy the lucenestudy project, at least I have not been able to make it run.

Please see the other PR for more information: https://github.com/lukhnos/mobilelucene/pull/2

Best;

kevindelord commented 8 years ago

As the wrong approach has been used here, I guess this issue can now be closed. Some other PR are making this repo working again ;)