1

I want to import files which are translated by j2objc in Cocoa Touch Framework in Xcode, and get some error.

My implementing steps as the following:

In PeopleProject -> Pepole.java:

   class Pepole{
          .....
    }
  1. Create a framework(named:objCFrameWork) and language is Objective-C in xcode(not static library). enter image description here

  2. Config for j2objc(Build Rules,Settings.xcconfig)

    Build Rules enter image description here

Settings.xcconfig

enter image description here

  1. New a file(Campony) in framework project and import People.h

     @interface Company : NSObject
     @property(nonatomic) People *CEO;
     @end
    
  2. Add a demon(objCFrameWorkDemo) using the objCFrameWork

     Company *c = [[Company alloc] init];
     [c.CEO sayWithNSString:@"Hello"];
    

6.Build objCFrameWork successfully.

7.Build objCFrameWorkDemo failed.

enter image description here

The source:https://github.com/leogeng/J2ObjC_Framework.git

2
  • Can you use any other (custom) Objective-C classes in your framework? If not, this may be unrelated to j2objc. Commented Jun 7, 2016 at 6:29
  • I new an objc file and it works ok. Commented Jun 7, 2016 at 6:33

1 Answer 1

1

If the Java source (A.java) declares that it is part of a package, then the default translation requires that you include the package as a subdirectory. For example, if class A is in the foo.bar package, then the header needs to referenced as #include "foo/bar/A.h".

If that won't work (Xcode doesn't support subdirectories well, so many projects avoid them), then run j2objc with the --no-package-directories flag to generate files that don't use subdirectories. This requires that all Java source files in the app have unique class/interface names, since there's no longer a package to differentiate them (the exception are JRE classes, which always need package subdirectories).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.