0

I'm trying to add share button implementation to my Gluon Mobile application and I have followed the GoNative application on their website. Following it step by step, I get a file structure that is different than what is specified. In addition, the Share Service is not found so any of the code in the "ifPresent" lambda doesn't work:

What it looks like

enter image description here

What it is supposed to look like

enter image description here

You can see that the package itself is not getting created (com.gluonhq.charm.down.plugins.ios) when I run the Gluon Mobile Task -> Install -> installNativeLib gradle task.

The files I created to form the plugin are almost identical to those in the GoNative application here. In fact the only difference between them is the word log is changed to share wherever present.

I also even attempted to create the GoNative application identically from the link provided above and the same issue happens. Java folder gets created in the ios package with nothing in it. The plugin cannot be found as a Service (ifPresent returns false).

UPDATE

Given @jns recommendation in the comments, I have put the classes in the correct locations and I get the following error when trying to launch to the iPhone simulator:

Execution failed for task ':launchIPhoneSimulator'.

org.apache.commons.exec.ExecuteException: Command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/konfamdbranch -arch i386 -Wl,-filelist,/Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/objects0 -L /Users/ashishsharma/.gradle/caches/modules-2/files-2.1/com.mobidevelop.robovm/robovm-dist/2.3.0/5628ca14c9057976088ce11fe045c2e1beea9a0b/unpacked/robovm-2.3.0/lib/vm/ios/x86 -ObjC -exported_symbols_list /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/exported_symbols -Wl,-no_implicit_dylibs -Wl,-dead_strip -fPIC -mios-simulator-version-min=8.0 -Wl,-no_pie -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk -lrobovm-bc -force_load /Users/ashishsharma/.gradle/caches/modules-2/files-2.1/com.mobidevelop.robovm/robovm-dist/2.3.0/5628ca14c9057976088ce11fe045c2e1beea9a0b/unpacked/robovm-2.3.0/lib/vm/ios/x86/librobovm-rt.a -lrobovm-debug -lrobovm-core -lgc -lpthread -ldl -lm -lz -liconv -lsqlite3 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework CoreGraphics -framework CoreText -framework ImageIO -framework MobileCoreServices -framework CoreBluetooth -framework CoreLocation -framework CoreMedia -framework CoreMotion -framework AVFoundation -framework AudioToolbox -framework MediaPlayer -framework UserNotifications -framework AVKit -force_load /Users/ashishsharma/.gradle/caches/modules-2/files-2.1/org.javafxports/ios-sdk/8.60.9/e900bcbcc39096ff9a3a409c28efe35d32f57ef5/unpacked/ios-sdk/rt/lib/libglass.a -force_load /Users/ashishsharma/.gradle/caches/modules-2/files-2.1/org.javafxports/ios-sdk/8.60.9/e900bcbcc39096ff9a3a409c28efe35d32f57ef5/unpacked/ios-sdk/rt/lib/libjavafx_font.a -force_load /Users/ashishsharma/.gradle/caches/modules-2/files-2.1/org.javafxports/ios-sdk/8.60.9/e900bcbcc39096ff9a3a409c28efe35d32f57ef5/unpacked/ios-sdk/rt/lib/libjavafx_iio.a -force_load /Users/ashishsharma/.gradle/caches/modules-2/files-2.1/org.javafxports/ios-sdk/8.60.9/e900bcbcc39096ff9a3a409c28efe35d32f57ef5/unpacked/ios-sdk/rt/lib/libjavafx_ios_webnode.a -force_load /Users/ashishsharma/.gradle/caches/modules-2/files-2.1/org.javafxports/ios-sdk/8.60.9/e900bcbcc39096ff9a3a409c28efe35d32f57ef5/unpacked/ios-sdk/rt/lib/libprism_common.a -force_load /Users/ashishsharma/.gradle/caches/modules-2/files-2.1/org.javafxports/ios-sdk/8.60.9/e900bcbcc39096ff9a3a409c28efe35d32f57ef5/unpacked/ios-sdk/rt/lib/libprism_es2.a -l/Users/ashishsharma/NetBeansProjects/konfamdbranch/src/ios/jniLibs/.DS_Store -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/src/ios/jniLibs/libShare.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libBarcodeScan.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libCharm.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libConnectivity.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libDialer.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libDisplay.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libLifecycle.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libLocalNotifications.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libPosition.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libRuntimeArgs.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libStatusBar.a -force_load /Users/ashishsharma/NetBeansProjects/konfamdbranch/build/javafxports/tmp/ios/native/libStorage.a -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks' failed (Exit value: 1)

A.Sharma
  • 2,771
  • 1
  • 11
  • 24
  • 1
    `ShareService` is not found because it's in the wrong package. You need to place it in `com.gluonhq.charm.down.plugins` in your main package. The platform specific Service.class (IosShareService) must be placed in the corresponding package `com.gluonhq.charm.down.plugins.ios` in ios sources. See this [answer](http://stackoverflow.com/questions/41523778/how-to-make-the-softkeyboard-show-up-again/41526346#41526346) – jns May 15 '17 at 00:41
  • @jns I did that and when I tried to launch an iPhone simulator through the tasks, I get the following error: library not found for -l/Users/ashishsharma/NetBeansProjects/konfamdbranch/src/ios/jniLibs/.DS_Store. Did you experience this at all? – A.Sharma May 15 '17 at 03:38
  • Make sure you don't add hidden files to the `jniLibs` folder, just the `*.a` library. – José Pereda May 15 '17 at 06:49
  • And if you are adding native code that needs to be compiled, you have to run the `installNativeLib ` task before running `launchIOSDevice`. If the build is successful, the `*.a` lib will be added to `jniLibs`. – José Pereda May 15 '17 at 07:06
  • @JoséPereda it works with the GoNative Objective C code, but I can't seem to get it to share. I get this which is understandable as `self` is unknown in the context. How would I pop open a share dialog if I don't know the Present View controller? `/Users/ashishsharma/NetBeansProjects/konfamdbranch/src/ios/native/Share.m:25:6: error: use of undeclared identifier 'self' [self presentViewController:activityVC animated:YES completion:nil];` Please see this post for the full question: http://stackoverflow.com/questions/43838857/gluon-mobile-share-button-implementation – A.Sharma May 15 '17 at 13:54
  • @jns Type that as an answer so you can get some credit! Your solution works and I was actually able to solve the sharing implementation I mentioned before as well! – A.Sharma May 16 '17 at 05:12

1 Answers1

2

ShareService is not found because it's in the wrong package.

Services.get(ShareService.class) expects ShareService to be in the package com.gluonhq.charm.down.plugins in your main sources. The platform specific implementations (AndroidShareService / IosShareService) need to be placed in the corresponding platform sources, e.g. src/ios/java/com.gluonhq.charm.down.plugins.ios.

See this answer for more information

Community
  • 1
  • 1
jns
  • 6,017
  • 2
  • 23
  • 28