messapix / jfxmobile-maven-plugin

Maven version of jfxmobile plugin
Apache License 2.0
5 stars 3 forks source link

Target ios-launcher not working #4

Open joerg-wille opened 6 years ago

joerg-wille commented 6 years ago

I guess the correct way to launch app on a Device is: 'mvn clean package ios ios-launcher -X'. But this does not work. It gives the same result as: 'mvn clean package ios -X' which generates a „unix executable“ file, a file without extension. Have not found any way to bring this binary on a device or to generate ipa.

agloria commented 6 years ago

try with: mvn clean package ios ios-device

joerg-wille commented 6 years ago

mvn clean package ios ios-device -X

works better. I see an app is being generated. Also uploading works, but do get an error on VerifyingApplication.

[INFO] [ 0%] Beginning upload... [INFO] [ 0%] Uploading /Users/joerg/NetBeansProjects/customcontrols/custombuttontest/target/javafxports/ios/tmp/robovm/custombuttontest.app...

[INFO] [100%] Upload complete [INFO] [ 0%] Beginning installation... [INFO] [ 5%] CreatingStagingDirectory [INFO] [ 15%] ExtractingPackage [INFO] [ 20%] InspectingPackage [INFO] [ 20%] TakingInstallLock [INFO] [ 30%] PreflightingApplication [INFO] [ 30%] InstallingEmbeddedProfile [INFO] [ 40%] VerifyingApplication [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:22 min [INFO] Finished at: 2017-12-18T16:48:30+01:00 [INFO] Final Memory: 786M/2211M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.messapix.ftatr.jfxmobile:jfxmobile-maven-plugin:1.0.0-b3:ios-device (default-ios-device) on project custombuttontest: Error: APIInternalError -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.messapix.ftatr.jfxmobile:jfxmobile-maven-plugin:1.0.0-b3:ios-device (default-ios-device) on project custombuttontest: Error at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290) at org.apache.maven.cli.MavenCli.main (MavenCli.java:194) at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Error at com.messapix.ftatr.jfxmobile.maven.plugin.ios.lifecycle.DeviceMojo.execute (DeviceMojo.java:70) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290) at org.apache.maven.cli.MavenCli.main (MavenCli.java:194) at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356) Caused by: org.robovm.libimobiledevice.LibIMobileDeviceException: APIInternalError at org.robovm.libimobiledevice.util.AppLauncher$1.error (AppLauncher.java:1001) at org.robovm.libimobiledevice.Callbacks.callInstproxyCallback (Callbacks.java:64)

agloria commented 6 years ago

I'm investigating.

In the meanwhile try with: mvn clean package ios ios-device -Djfxmobile.ios.ipaArchs=amd64

joerg-wille commented 6 years ago

Did you mean arm64? I tried: mvn clean package ios ios-device -Djfxmobile.ios.ipaArchs=arm64

harmony and javafxports get compiled to "ios arm64 debug". But in line 31 and following this is shown (see attached file ipaArchs-arm64.txt):

[INFO] No arch defined [INFO] arch=thumbv7 is used [INFO] No iOS SDK defined. 10.3 used

And then the main app still gets build with:

[INFO] Compiling net.joergwille.controls.custombuttontest.MainApp (ios thumbv7 debug)

agloria commented 6 years ago

device mojo wasn't tested at all. I made some change. Recompile the plugin, the new version is 1.0.0-b4-SNAPSHOT

then compile and run with: mvn clean package ios ios-device -Djfxmobile.ios.ipaArchs=arm64 -Djfxmobile.ios.simulator.arch=arm64

don't worry about "simulator" in the property.

joerg-wille commented 6 years ago

Thanks! I build and installed 1.0.0-b4-SNAPSHOT of jfxmobile-maven-plugin locally (I verified that no old versions were pulled afterwards.) The result looks very similar as yesterday (see attached file). (Can I somehow help? Should I try to debug the maven plugin?)

agloria commented 6 years ago

Here had the same problem a couple of month ago. It seems they resolved with arm64.

robovm resolves "iPhone 5" as device name and doesn't give the correct device type.

Add the following parameter: -Djfxmobile.ios.simulator.deviceName=

joerg-wille commented 6 years ago

Yes, if no name is specified "iPhone 5" is being used, but the build installs and runs to: [INFO] [ 40%] VerifyingApplication

If I specify a name the build breaks earlier - in RobovmBuilder.build() with: Unable to find a matching device [arch=arm64, family=iPad, name=iPad Pro, sdk=10.3]

I have tried a couple of different names and renamed iPad. I will now update iPad to iOS 11.2.1 and XCode to 9.2 - maybe this helps.

joerg-wille commented 6 years ago

No difference with iOS 11.2.1 and XCode to 9.2. When I set a name the build breaks, without a name it defaults to iPhone 5 and verifying fails.

agloria commented 6 years ago

Maybe is it a problem of signing and/or provisioning profile? Can you deploy a simple ios app from xcode with the same signing/profile?

agloria commented 6 years ago

I was wondering if the plugin targets the right device. I updated the code in order to show the list of connected devices. Run simply in debug mode

joerg-wille commented 6 years ago

Looks like the device is being detected correctly. I have following settings in pom.xml

<simulator>
    <deviceName>iPad Pro</deviceName>
    <arch>arm64</arch>                           
    <sdk>11.2</sdk>                            
</simulator>
<debug>TRUE</debug>
<ipaArchs>arm64</ipaArchs>

Your last changes print following info when running: mvn clean package ios ios-device -X

[DEBUG] Connected devices: [DEBUG] Device: d6bda137cf53ef35d53eb3cb4a174955bf3b37d7

And XCode shows following device information..

agloria commented 6 years ago

from log seems you have two signing identities with the same name. robovm picks the first one. I'm not sure if it makes sense but you should find the way to exclude one of the two.

agloria commented 6 years ago

Try to modify and debug the method com.messapix.ftatr.jfxmobile.maven.plugin.ios.RobovmBuilder#signing()

agloria commented 6 years ago

I updated the code in order to log all provisioning profiles

joerg-wille commented 6 years ago

I knew about the 2 signing identities but it looked to me, that this was not the issue. So now I have deleted signing identities and provisioning profiles and started from scratch. I have pulled your latest changes and running mvn clean package ios ios-device -X gives following logging:

[DEBUG] -- end configuration -- [DEBUG] Connected devices: [DEBUG] Device: d6bda137cf53ef35d53eb3cb4a174955bf3b37d7 [INFO] ios device os ios [INFO] ios device arch arm64 [INFO] ios device target org.robovm.compiler.target.ios.IOSTarget@17856f0

which is the correct Device ID of my 'iPad Pro' and:

[INFO] Using robovm from location /Users/joerg/.m2/repository/com/mobidevelop/robovm/robovm-dist/2.3.3/unpacked/robovm-2.3.3 [DEBUG] Robovm: signing config [DEBUG] List of signing identities [DEBUG] SigningIdentity [name=iPhone Developer: joerg.wille[AT]me.com (W****R), fingerprint=977B1B1A92E092694BA998AE5B505758CD40EA76] [DEBUG] List of provisioning profiles [DEBUG] ProvisioningProfile [type=Development, file=/Users/joerg/Library/MobileDevice/Provisioning Profiles/8ff18537-79f9-4e87-a553-4b42352c91ed.mobileprovision, uuid=8ff18537-79f9-4e87-a553-4b42352c91ed, name=iOS Team Provisioning Profile: net.joergwille.controls.custombuttontest.MainApp, appIdName=XC net joergwille controls custombuttontest MainApp, appIdPrefix=EFDKYA5E4Z, appId=EFDKYA5E4Z.net.joergwille.controls.custombuttontest.MainApp, creationDate=Wed Dec 20 17:59:17 CET 2017, expirationDate=Wed Dec 27 17:59:17 CET 2017, certFingerprints=[6396FFD625D1F3E60432140B816349CBE770887C, 977B1B1A92E092694BA998AE5B505758CD40EA76]] [DEBUG] Using explicit iOS Signing identity: joerg.wille[AT]me.com (W****R) [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE

Btw. I am using the 'Free/Automatic provisioning': provisioning

Following settings in pom.xml:

<signIdentity>iPhone Developer: joerg.wille@me.com (W********R)</signIdentity>
<provisioningProfile>8ff18537-79f9-4e87-a553-4b42352c91ed</provisioningProfile>
<simulator>
    <deviceName>iPad Pro</deviceName>
    <arch>arm64</arch>                           
    <sdk>11.2</sdk>                            
</simulator>
<debug>TRUE</debug>
<ipaArchs>arm64</ipaArchs>

The Console Logging Console Logging for the iPad is giving following:

'<private>' has value not permitted by provisioning profile '<private>'

0x16f89f000 +[MICodeSigningVerifier _validateSignatureAndCopyInfoForURL:withOptions:error:]: 147: Failed to verify code signature of /private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.EEcj51/extracted/custombuttontest.app : 0xe8008016 (The executable was signed with invalid entitlements.)

0x16f89f000 -[MIInstaller performInstallationWithError:]: Verification stage failed

I have found a potential solution for this error here.

Therefore I checked the Entitlements.plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>get-task-allow</key>
    <true/>
    <key>keychain-access-groups</key>
    <array>
        <string>EFDKYA5E4Z.*</string>
    </array>
    <key>application-identifier</key>
    <string>EFDKYA5E4Z.org.javafxports.jfxmobile.ios.BasicLauncher</string>
    <key>com.apple.developer.team-identifier</key>
    <string>EFDKYA5E4Z</string>
</dict>
</plist>

Seems that either I have a problem with my provisioning profile, although I am using the same for running apps on iPad build with gluon gradle plugin. Or I am having the issue because Free Profile do not work in general with your plugin. Or the plugin or robovm is somehow generating a wrong entitlement. Sorry, I have no clue at the moment.

agloria commented 6 years ago

I see. I'll try to provide Entitlements.plist

joerg-wille commented 6 years ago

I think the Entitlements for key application-identifier might be wrong.

EFDKYA5E4Z.org.javafxports.jfxmobile.ios.BasicLauncher

In a different application build with gluo gradle plugin the key

application-identifier EFDKYA5E4Z.net.joerg-wille.ensemble.WidgetsEnsemble

which is the main class of the app and not the BasicLauncher.

What do you think?

joerg-wille commented 6 years ago

In the robovm channel Kees van Dieren mentioned: In our Robovm project it is empty, but in the ipa build some things are added.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>application-identifier</key>
        <string>TEAMID.BUNDLEID</string>
    </dict>
</plist>

BUNDLEID: can be found in iTunes connect, option 'App Information' TEAMID: is (at least for our apps) the same as the 'prefix' in Apple Developer Center app details here: https://developer.apple.com/account/ios/identifier/bundle BUNDLEID is also the same as 'id' in Apple Developer Center.

I think BUNDLEID (at least for free provisioning profile) should be: [some-hash + java-package-name + main-class-name] At least this it what gradle plugin put is:

<dict>
    <key>get-task-allow</key>
    <true/>
    <key>keychain-access-groups</key>
    <array>
        <string>EFDKYA5E4Z.*</string>
    </array>
    <key>application-identifier</key>
    <string>EFDKYA5E4Z.net.joerg-wille.ensemble.WidgetsEnsemble</string>
    <key>com.apple.developer.team-identifier</key>
    <string>EFDKYA5E4Z</string>
</dict>
agloria commented 6 years ago

I took a quick look at the gradle plugin. It uses a modified version of robovm compiler for ios11 and has an Entitlements.plist creation task but includes only aps enviromnents. After Christmas holiday I'll try to use that compiler.

joerg-wille commented 6 years ago

I have seen this gluon fork: https://github.com/gluonhq/robovm/commits/robovm-2.3.1-ios11 But it does not look as it has any important gluon fixes and because it is older, I choose to go with the current MobiVM.

For the problem with the potential wrong application-identifier in Entitlements.plist I did a (ugly) fix. With this change the installation process works now up to 100%... ...but it crashes when the app gets started. Here is a console log from iPad starting the installed app. I see some error messages, like:

assertiond[65] : [DemoApp:486] Port death watcher fired.

But no clear root cause.

Anyway, I wish you a Merry Christmas and nice holidays!

joerg-wille commented 6 years ago

Looks like the Entitlements.plist creation task only fixes the aps-environment key to allow push-notifications. Where as CreateDefaultLauncher seems to be the task where they modify the BasicLauncher.java. So am I right, that these are 2 different changes, gluon has done to the gradle script. Will you have time to look into that?

agloria commented 6 years ago

During this week-end I'll try to sync the maven plugin with the gradle plugin.

joerg-wille commented 6 years ago

There is a new home and a new version (2.1.0-SNAPSHOT) for the javafxmobile-plugin because of the new Gluon VM. I see more java file on first sight and the readme mentions usbmuxd is needed to deploy on an iOS device (not knowing if this lib was needed so far).

agloria commented 6 years ago

I think we should have the plugin to work with robovm before move to gluon vm. I made some change in 1.0.0-b5-SNAPSHOT but not related to Entitlements.plist

joerg-wille commented 6 years ago

Completely agree with you. Only the current toolchain supports Android apps from API 21 (Android 5), the new toolchain depends on OpenJDK which only will work on API 26 (Android 5). Also, the current toolchain is quite stable and probably will be around for a longer time. I will have a look at your "half commit" and try it out. Also I made a small change to get it running with current Android SDK - multidex is in a different location on my machine: extras/android/m2repository/com/android/support/multidex/1.0.1/exploded/multidex-1.0.1.jar instead of extras/android/support/multidex/library/libs/android-support-multidex.jar

agloria commented 6 years ago

PS: use gpg.skip property to skip signing instead of comment the maven gpg plugin in the pom.xml

joerg-wille commented 6 years ago

Hi I have finally tried version 1.0.0-b5-SNAPSHOT with "mvn clean package ios ios-device -X". First problem was that it failed with java.io.FileNotFoundException: demoapp/target/javafxports/ios/tmp/Entitlements.plist (No such file or directory)

The default Entitlements.plist gets copied to "ios/tmp/robovm". Therefore I changed IosTaget.java line 35 to "ENTITLEMENTSPLIST("ios/tmp/robovm/Entitlements.plist",Type.FILE);".

Now the build runs a little further, but since it is still the unmodified Entitlements.plist it fails at: [INFO] [ 40%] VerifyingApplication

The default Entitlements.plist uses "org.javafxports.jfxmobile.ios.BasicLauncher" as application-identifier, but the main class - for which a valid entitlements exists - is called "com.indsp.playground.javafxmobiledemo.demoapp.DemoApp".

The ios-console-log prints: 147: Failed to verify code signature of /private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.ov0LJ4/extracted/DemoApp.app : 0xe8008016 (The executable was signed with invalid entitlements.) standard 22:34:18.464868 +0100 installd 0x16f26b000 -[MIInstaller performInstallationWithError:]: Verification stage failed

I think in the gradle robovm build the Entitlements.plist gets modified.

joerg-wille commented 6 years ago

I have found 2 workarounds to finally load the app on iOS device. But App shows only black screen. I do not see any useful debug messages or hints what crashes. I have also successfully tested some of the new settings you have added. And in simulator everything works. Any chance that we can have a debug session together?

joerg-wille commented 6 years ago

Hi Alfio, can we have a chat on skype? I can't get any further with running on iOS device.