Coder Social home page Coder Social logo

Comments (7)

tomball avatar tomball commented on June 11, 2024

That's surprising, as j2objc should be generating all declarations before use. The J2OBJC_CLASS_TYPE_LITERAL_SOURCE error is very strange, as it's included in every .m file, and should match a J2OBJC_TYPE_LITERAL_HEADER that is either in the same file (if the type is private) or in the associated .h file.

One possible problem is if you are using #import with j2objc-generated headers instead of #include. #include is necessary when a generated header has multiple types which refer to each other (an "include cycle"). We minimize the need for this by declaring @class and @protocol declarations where needed, but sometimes both types need to be fully declared, so j2objc generates segmented headers. Segmented headers in a way split a single header file into multiple ones that can be separately included, so #import can't be used since only one segment will be read.

Are you only seeing this in the Xcode UI, and not in a build log? If so, then Xcode may be confused by segmented headers.

from j2objc.

mungler avatar mungler commented on June 11, 2024

Hi Tom, thanks for the speedy response. I'll check out #include versus #import - looks like we may be doing this wrong, though a quick change to include doesn't seem to result in fewer warnings, so far.

We use j2objc to convert a java library to a static library project in xcode. The main header file for our library currently looks like this - is there some overarching import/include i should be doing?


#include <Foundation/Foundation.h>

#include "J2ObjC_header.h"

#include "java/lang/Integer.h"
#include "java/lang/Boolean.h"
#include "java/lang/Long.h"
#include "java/lang/Double.h"
#include "java/math/BigDecimal.h"
#include "java/util/Date.h"
#include "java/util/List.h"
#include "java/util/AbstractList.h"
#include "java/util/ArrayList.h"
#include "java/util/Collection.h"
#include "java/util/AbstractMap.h"
#include "java/util/Map.h"
#include "java/util/Set.h"
#include "java/io/File.h"
#include "IOSClass.h"
#include "IOSPrimitiveArray.h"

from j2objc.

mungler avatar mungler commented on June 11, 2024

Its very strange, actually, because taking another example:

ASWPresentersStep2AddYourIntroductionPresenter *new_ASWPresentersStep2AddYourIntroductionPresenter_init() {
...
}

Xcode highlights in yellow the () after 'init' with the usual warning, but I can see the header is declared with (void), which is, as far as I can gather, correct:

FOUNDATION_EXPORT ASWPresentersStep2AddYourIntroductionPresenter *new_ASWPresentersStep2AddYourIntroductionPresenter_init(void) NS_RETURNS_RETAINED;

For what its worth, I changed all imports to includes for generated code in our library project and the number of warnings did not drop.

from j2objc.

mungler avatar mungler commented on June 11, 2024
Screenshot 2023-07-18 at 19 15 55

Interesting.. in this case, its offering to 'fix' the issue by injecting (void) in the .m file.

from j2objc.

tomball avatar tomball commented on June 11, 2024

My guess is that Xcode is now getting confused by how j2objc's generates declarations. If you have the time, please try applying all the Xcode fixes and then diffing the generated sources to see what it changed. If we can tweak j2objc's output to make Xcode happy (without breaking anything), we should do that. Also, what version of Xcode are you using?

from j2objc.

mungler avatar mungler commented on June 11, 2024

Thanks Tom. The Xcode version is reported as Version 14.3.1 (14E300c)

We have more than 2000 warnings currently, so i'm not sure I can set about applying all of the fixes its suggesting. From what i've seen its mostly injecting (void) in places where the .m files have (). However, the relevant generated headers have the correct form with (void) so i'm not even sure why its suggesting these changes.

Some of the other changes its suggesting are... well, odd:

Screenshot 2023-07-18 at 21 20 45

from j2objc.

mungler avatar mungler commented on June 11, 2024

Closing this as I think this is due to the weird way i'm using the headers from the j2objc dist along with the JRE framework bundle.

from j2objc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.