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

Leo
  • 835
  • 1
  • 12
  • 31

1 Answers1

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).

tball
  • 1,984
  • 11
  • 21