With 1.3, I’m having trouble understanding how to generate Java bindings for native libraries, such as Google’s Firebase. I’m not sure where to put the native library in the project such that it can be found in the project tree where I can right-click it to begin the process and/or, if using the new GUI, how to fill in the information so that the bindings can be created. (In the dialog that comes up after hitting +, what should go in the Name field).
Is there any new documentation for this process for 1.3 beta?
It is also somewhat related to cocoapods support… I tried cocoapods but simple “pod install” on a MOE 1.3 project made bunch of changes in xcode files that broke project build. Also cocoapods is giving warnings about using xcode workspace instead of xcode project (the latter is used by MOE).
So, eagerly awaiting for new/updated tutorials for linking cocoapods and generating bindings.
Kristóf, I tried to follow your instructions, got bindings generated for AFNetworking sample, but then build is failing with the “framework not found AFNetworking” error. Any idea what’s missing?
Ld /Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/obj/CocoapodsTest.build/Debug-iphonesimulator/CocoapodsTest.build/Objects-normal/i386/CocoapodsTest normal i386
cd /Users/eu/Documents/workspace2/CocoapodsTest/xcode
export IPHONEOS_DEPLOYMENT_TARGET=9.3
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk -L/Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/Debug-iphonesimulator -F/Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/Debug-iphonesimulator -F/Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/sym/Debug-iphonesimulator/AFNetworking -F/Users/eu/Documents/workspace2/CocoapodsTest/xcode/../build/moe/sdk/sdk/iphonesimulator -filelist /Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/obj/CocoapodsTest.build/Debug-iphonesimulator/CocoapodsTest.build/Objects-normal/i386/CocoapodsTest.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=9.3 -Xlinker -object_path_lto -Xlinker /Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/obj/CocoapodsTest.build/Debug-iphonesimulator/CocoapodsTest.build/Objects-normal/i386/CocoapodsTest_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -framework AFNetworking -sectcreate __OATDATA __oatdata /Users/eu/Documents/workspace2/CocoapodsTest/xcode/..//build/moe/main/xcode/Debug-iphonesimulator/i386.oat -sectcreate __ARTDATA __artdata /Users/eu/Documents/workspace2/CocoapodsTest/xcode/..//build/moe/main/xcode/Debug-iphonesimulator/i386.art -segprot __OATDATA rwx rx -segprot __ARTDATA rwx rw -pagezero_size 4096 -lstdc++ -framework MOE -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/obj/CocoapodsTest.build/Debug-iphonesimulator/CocoapodsTest.build/CocoapodsTest.app.xcent -framework AFNetworking -Xlinker -dependency_info -Xlinker /Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/obj/CocoapodsTest.build/Debug-iphonesimulator/CocoapodsTest.build/Objects-normal/i386/CocoapodsTest_dependency_info.dat -o /Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/obj/CocoapodsTest.build/Debug-iphonesimulator/CocoapodsTest.build/Objects-normal/i386/CocoapodsTest
ld: warning: directory not found for option '-F/Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/sym/Debug-iphonesimulator/AFNetworking'
ld: warning: -pagezero_size not page aligned, rounding down
ld: framework not found AFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
The following build commands failed:
Ld /Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/obj/CocoapodsTest.build/Debug-iphonesimulator/CocoapodsTest.build/Objects-normal/i386/CocoapodsTest normal i386
(1 failure)
:moeMainDebugIphonesimulatorXcodeBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':moeMainDebugIphonesimulatorXcodeBuild'.
> Task failed, you can find the log file here: /Users/eu/Documents/workspace2/CocoapodsTest/build/moe/xcodebuild/XcodeBuild-main-debug-iphonesimulator.log
I created a new project with my guide above, but it worked fine and the only way I could reproduce this exact message was to remove the moe.xcode.workspace setting.
Could you please open the xcode/CocoapodsTest.xcworkspace file and try running from Xcode?
When I try to run from XCode it gives me similar error. Am I missing some step in XCode project/workspace setup? How do I add framework in there?
ld: warning: directory not found for option '-F/Users/eu/Library/Developer/Xcode/DerivedData/CocoapodsTest-gclnyaukpsaqckcqqzysjytnqxtu/Build/Products/Debug-iphonesimulator/AFNetworking'
ld: warning: -pagezero_size not page aligned, rounding down
ld: framework not found AFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)
this is something pod install should take care of. Pleased close Xcode and run pod install again. If you still have the same issue after this, could you please share your project with us?
That did it. Closing xcode and re-runing pod install couple more times fixed it. It runs from gradle now. My next step would be to get Charts pod bindings working…
Kristóf I’ve tried to generate bindings for the Charts pod. This one is written in Swift 2.x, so Xcode insisted on converting it to Swift 3 or else said it can’t build it.
Then after I switched to MOE and tried to generate bindings. But the binding generator gave me bunch of syntax errors in a non-scrollable popup with size larger than my screen that I can’t copy any text from and those errors wasn’t shown in Console view in Eclipse.
But even with the errors, it generated some Java classes, but these classes have Java compilation errors (e.g. incompatible return types on overwritten methods).
I attached my test project. So, after unzipping it, and running pod install you can open xcode workspace to build or convert installed pods and then open Java IDE to see issue with the binding generator. I put my binding file into the project root. I’ve used “Charts-Swift.h” as an include, that was a blind guess…
Please let me know if you could discover anything. Thank you.
you were quite close to a good solution. The errors you saw were due to some types not being resolved. That is usually because of missing imports. After I modified the Import headers section to the following, binding generation completed successfully:
Thank you Kristóf. It generates bindings successfully now, but there are compilation issues in generated Java code. See below.
It seem like bindings generator didn’t generate some of the parameter and return types correctly. Also some of initialize() methods in subclasses of UIView wasn’t generated as static. I am going to try to fix those errors manually and see if I can use Charts UI views in my app.
Also, should I open an issue regarding error reporting? It would be much more convenient to show generator errors in MOE Console view in Eclipse instead of modal popup dialog.
The return type is incompatible with ChartBaseDataSet.valueFormatter() BarLineScatterCandleBubbleChartDataSet.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 413 Java Problem
The return type is incompatible with ChartBaseDataSet.valueFormatter() PieChartDataSet.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 448 Java Problem
The type ChartBaseDataSet must implement the inherited abstract method IChartDataSet.setValueFormatter(Object) ChartBaseDataSet.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 37 Java Problem
The type ChartDefaultFillFormatter must implement the inherited abstract method IChartFillFormatter.getFillLinePositionWithDataSetDataProvider(Object, Object) ChartDefaultFillFormatter.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 36 Java Problem
The type ChevronDownShapeRenderer must implement the inherited abstract method IShapeRenderer.renderShapeWithContextDataSetViewPortHandlerPointColor(CGContextRef, Object, ChartViewPortHandler, CGPoint, UIColor) ChevronDownShapeRenderer.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 37 Java Problem
The type ChevronUpShapeRenderer must implement the inherited abstract method IShapeRenderer.renderShapeWithContextDataSetViewPortHandlerPointColor(CGContextRef, Object, ChartViewPortHandler, CGPoint, UIColor) ChevronUpShapeRenderer.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 37 Java Problem
The type CircleShapeRenderer must implement the inherited abstract method IShapeRenderer.renderShapeWithContextDataSetViewPortHandlerPointColor(CGContextRef, Object, ChartViewPortHandler, CGPoint, UIColor) CircleShapeRenderer.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 37 Java Problem
The type CrossShapeRenderer must implement the inherited abstract method IShapeRenderer.renderShapeWithContextDataSetViewPortHandlerPointColor(CGContextRef, Object, ChartViewPortHandler, CGPoint, UIColor) CrossShapeRenderer.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 37 Java Problem
The type LineChartDataSet must implement the inherited abstract method ILineChartDataSet.setFillFormatter(Object) LineChartDataSet.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 37 Java Problem
The type SquareShapeRenderer must implement the inherited abstract method IShapeRenderer.renderShapeWithContextDataSetViewPortHandlerPointColor(CGContextRef, Object, ChartViewPortHandler, CGPoint, UIColor) SquareShapeRenderer.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 37 Java Problem
The type TriangleShapeRenderer must implement the inherited abstract method IShapeRenderer.renderShapeWithContextDataSetViewPortHandlerPointColor(CGContextRef, Object, ChartViewPortHandler, CGPoint, UIColor) TriangleShapeRenderer.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 37 Java Problem
The type XShapeRenderer must implement the inherited abstract method IShapeRenderer.renderShapeWithContextDataSetViewPortHandlerPointColor(CGContextRef, Object, ChartViewPortHandler, CGPoint, UIColor) XShapeRenderer.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 37 Java Problem
This instance method cannot override the static method from UIView BubbleChartView.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 324 Java Problem
This instance method cannot override the static method from UIView CombinedChartView.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 374 Java Problem
This instance method cannot override the static method from UIView ScatterChartView.java /CocoapodsTest/src/main/java/com/euxx/charts/charts line 320 Java Problem
After fixing compilation errors in generated bindings I’ve tried to add chart component into ui controller, but getting “unrecognized selector” error.
Is it related to binding issues or I missed something? I noticed that none of generated bindings have @RegisterOnStartup annotation. Do I need to somehow register them manually, given the warnings below?
art I 22472 2387661 /Volumes/SSD/gh-moe-master-1.3.0-beta-1/aosp/art/runtime/parsed_options.cc:449] setting boot class path to /Users/eu/Library/Developer/CoreSimulator/Devices/2892A0BC-9C40-4FCD-B575-8607CE08D90D/data/Containers/Bundle/Application/84A1991A-0565-4EB0-A442-D44FDE46CF5A/CocoapodsTest.app/application.jar:/Users/eu/Library/Developer/CoreSimulator/Devices/2892A0BC-9C40-4FCD-B575-8607CE08D90D/data/Containers/Bundle/Application/84A1991A-0565-4EB0-A442-D44FDE46CF5A/CocoapodsTest.app
/Volumes/SSD/gh-moe-master-1.3.0-beta-1/moe/natj/natj/src/main/native/natj/NatJ.cpp:353 DEBUG: Method 'boolean java.lang.reflect.Method.isDefault()' is not accessible.
/Volumes/SSD/gh-moe-master-1.3.0-beta-1/moe/natj/natj/src/main/native/natj/ObjCRuntime.mm:1481 WARNING: Binding class refers to class NSUIView, but it can not be found. Fallback to indirect super class.
/Volumes/SSD/gh-moe-master-1.3.0-beta-1/moe/natj/natj/src/main/native/natj/ObjCRuntime.mm:1481 WARNING: Binding class refers to class ChartViewBase, but it can not be found. Fallback to indirect super class.
/Volumes/SSD/gh-moe-master-1.3.0-beta-1/moe/natj/natj/src/main/native/natj/ObjCRuntime.mm:1481 WARNING: Binding class refers to class BarLineChartViewBase, but it can not be found. Fallback to indirect super class.
/Volumes/SSD/gh-moe-master-1.3.0-beta-1/moe/natj/natj/src/main/native/natj/ObjCRuntime.mm:1481 WARNING: Binding class refers to class BarChartView, but it can not be found. Fallback to indirect super class.
2017-01-12 16:28:55.900 CocoapodsTest[22472:2387661] -[UIView setNoDataText:]: unrecognized selector sent to instance 0x7be444a0
org.moe.natj.objc.ObjCException: -[UIView setNoDataText:]: unrecognized selector sent to instance 0x7be444a0
at apple.uikit.c.UIKit.UIApplicationMain(Native Method)
at com.euxx.cocopods.Main.main(Main.java:18)
art I 22473 2387703 /Volumes/SSD/gh-moe-master-1.3.0-beta-1/aosp/art/runtime/parsed_options.cc:449] setting boot class path to /Users/eu/Library/Developer/CoreSimulator/Devices/2892A0BC-9C40-4FCD-B575-8607CE08D90D/data/Containers/Bundle/Application/84A1991A-0565-4EB0-A442-D44FDE46CF5A/CocoapodsTest.app/application.jar:/Users/eu/Library/Developer/CoreSimulator/Devices/2892A0BC-9C40-4FCD-B575-8607CE08D90D/data/Containers/Bundle/Application/84A1991A-0565-4EB0-A442-D44FDE46CF5A/CocoapodsTest.app
/Volumes/SSD/gh-moe-master-1.3.0-beta-1/moe/natj/natj/src/main/native/natj/NatJ.cpp:353 DEBUG: Method 'boolean java.lang.reflect.Method.isDefault()' is not accessible.
/Volumes/SSD/gh-moe-master-1.3.0-beta-1/moe/natj/natj/src/main/native/natj/ObjCRuntime.mm:1481 WARNING: Binding class refers to class NSUIView, but it can not be found. Fallback to indirect super class.
/Volumes/SSD/gh-moe-master-1.3.0-beta-1/moe/natj/natj/src/main/native/natj/ObjCRuntime.mm:1481 WARNING: Binding class refers to class ChartViewBase, but it can not be found. Fallback to indirect super class.
/Volumes/SSD/gh-moe-master-1.3.0-beta-1/moe/natj/natj/src/main/native/natj/ObjCRuntime.mm:1481 WARNING: Binding class refers to class BarLineChartViewBase, but it can not be found. Fallback to indirect super class.
/Volumes/SSD/gh-moe-master-1.3.0-beta-1/moe/natj/natj/src/main/native/natj/ObjCRuntime.mm:1481 WARNING: Binding class refers to class BarChartView, but it can not be found. Fallback to indirect super class.
2017-01-12 16:28:56.514 CocoapodsTest[22473:2387703] -[UIView setNoDataText:]: unrecognized selector sent to instance 0x7b14a6c0
org.moe.natj.objc.ObjCException: -[UIView setNoDataText:]: unrecognized selector sent to instance 0x7b14a6c0
at apple.uikit.c.UIKit.UIApplicationMain(Native Method)
at com.euxx.cocopods.Main.main(Main.java:18)
I managed to manually tweak generated bindings to get the Charts pod work. It looks like binding generator is choking on the IValueFormatter.swift file. Very likely because of the following code in Charts pod. Note that protocol name and objc name aren’t not the same, so MOE generates IChartValueFormatter.java class, but all references in swift to IValueFormatter are generated as Object.
@objc(IChartValueFormatter)
public protocol IValueFormatter : NSObjectProtocol
After I manually edited them all I was able to hook up a basic Charts widget and get it to draw the chart in iOS app.