如何在 iOS 模拟器或真实设备上测试 Gluon 应用程序?

How to testing Gluon app on iOS Simulator or Real Device?

当我尝试在 iOS Device/simulator 上执行 gluon 应用程序时,问题与我的 有关。它似乎根本不起作用。它向我显示以下错误:

已编辑

我也在检查 this question,但它对我没有帮助。 所以问题是如何让它发挥作用?

已记录 我使用的是 macOS Mojave 10.14.3 和 Xcode 10.2.1

Build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.3.16'
    }
}
// Apply the plugin
apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'fr.cashmag.GluonApplication'
ext.GLUON_VERSION="5.0.2"
ext.CHARM_DOWN="3.8.6"

dependencies {
    compile "com.gluonhq:charm:$GLUON_VERSION"
    compile "com.gluonhq:charm-down-plugin-orientation:$CHARM_DOWN"
}

jfxmobile {
    downConfig {
        version = '3.8.6'
        // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
        plugins 'display', 'lifecycle', 'orientation', 'statusbar', 'storage'
    }
    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

iOS模拟器

解决问题:

Unable to find a matching device [arch=x86_64, family=iPhone, name=null, sdk=null]

一个可能的解决方案是:

  • 在项目的根目录中包含一个 gradle.properties 文件,并添加:

    robovm.ipaArchs=x86_64
    

    (有关详细信息,请参阅 documentation)。

  • 运行./gradlew --info createIpa,等待任务结束。检查您的项目是否包含 build/javafxports/ios/*.app.

  • 下的应用
  • 打开Xcode,转到Xcode -> Open Developer Tool -> Simulator

  • 当 iPhone/iPad 设备屏幕出现时,从 Finder 中拖动 *.app 文件。然后它将在 sim 卡上安装该应用程序,您可以通过点击它来 运行 它。

一旦进程正常运行,您可以将 属性 还原为:

robovm.ipaArchs=arm64:thumbv7

以便为您的设备和 Apple Store 创建应用程序。

iOS 设备

解决问题:

No provisioning profile and signing identity found that matches bundle ID

如果您已经注册了 Apple Developer 计划(否则您将无法通过 Apple Store 分发您的应用程序),您需要按照以下步骤操作:

  • 转到开发人员 portal,转到 Certificates, Identifiers & Profiles
  • 转到 Certificates,并确保您已创建开发证书(用于测试)。稍后您将需要生产证书才能分发。
  • 假设现在正在开发,下载证书并安装(双击)。
  • 转到 Identifiers -> App IDs,并创建一个新的应用程序标识符。提供一个名称,并确保提供来自应用程序的确切 Bundle ID,该 ID 列在 CFBundleIdentifier 键下的 Default-Info.plist 文件中。
  • 转到Devices并添加您的测试设备,提供这些设备的UDID(转到iTunes,插入您的设备,然后单击设备序列号,它会显示出来,然后⌘ +C 粘贴)。
  • 最后,转到 Provisioning Profiles,并添加一个开发配置文件(稍后您将需要一个分发配置文件)。 Select iOS App Development, select 您之前提供的App ID,完成后下载安装(双击)。
  • 回到您的项目,您可以将其添加到您的 build.gradle 文件中:

    ios {
        ...
        iosSignIdentity = "iPhone Development: *** (^^^^)"
        iosProvisioningProfile = '$$$'
    }
    
  • 运行 ./gradlew --info launchIOSDevice,并在流程结束时查看控制台日志记录,以检查配置文件是否用于对应用程序进行签名。

请注意,您必须以相同的方式使用分发配置文件来签署您将提交到 Apple Store 的应用程序。

编辑

如果您没有加入开发者计划,您也可以使用免费的配置文件,这样您就可以在自己的设备上进行测试。

为此,您必须执行以下步骤:

  • 如果您没有可以使用的 Apple ID,可以创建一个新的 here
  • 打开 Xcode 并转到 Xcode -> Preferences -> Accounts
  • 添加您的 Apple ID
  • 在管理证书下,为 iOS 开发添加一个。
  • 现在创建一个新的Xcode项目,select一个像Single View App这样的简单模板。
  • 确保您设置的包标识符与项目中的包标识符完全相同。
  • 连接您的设备和 运行 Xcode 项目。它将在您的设备上为该空应用程序安装配置文件。
  • 退出 Xcode 并返回您的项目,尝试将其部署到 iOS 设备而不设置 iosSignIdentityiosProvisioningProfile)。