在运行时获取配置文件的EXPIRATION日期?

iOS编程是有趣的

我有一个应用程序,我经常通过即席分发方法将其传递给测试人员。这些测试人员中的一些人“随时待命”,并且对调配配置文件和季度到期足够了解,并且可以(如果我忘了)给我一些帮助,以重建一个新版本供他们测试。

但是,有些用户似乎总是到停止运行的位置,然后对此and之以鼻,尽管他们可能忽略了iOS级别的提醒。

我的问题是,我可以通过编程方式掌握运行时的到期日期,并且可以自己发出“应用内”警报或系统通知来提醒他们拉下较新版本吗?

尼古拉·苏万吉耶夫(Nikolay Suvandzhiev)

迅捷版:

// Returns `nil` if it fails
private func getProvisioningProfileExpirationDateAsString() -> String? {
    guard
        let profilePath = Bundle.main.path(forResource: "embedded", ofType: "mobileprovision"),
        let profileData = try? Data(contentsOf: URL(fileURLWithPath: profilePath)),
        // Note: We use `NSString` instead of `String`, because it makes it easier working with regex, ranges, substring etc.
        let profileNSString = NSString(data: profileData, encoding: String.Encoding.ascii.rawValue)
        else {
        print("WARNING: Could not find or read `embedded.mobileprovision`. If running on Simulator, there are no provisioning profiles.")
        return nil
    }


    // NOTE: We have the `[\\W]*?` check to make sure that variations in number of tabs or new lines in the future does not influence the result.
    guard let regex = try? NSRegularExpression(pattern: "<key>ExpirationDate</key>[\\W]*?<date>(.*?)</date>", options: []) else {
        print("Warning: Could not create regex.")
        return nil
    }

    let regExMatches = regex.matches(in: profileNSString as String, options: [], range: NSRange(location: 0, length: profileNSString.length))

    // NOTE: range `0` corresponds to the full regex match, so to get the first capture group, we use range `1`
    guard let rangeOfCapturedGroupForDate = regExMatches.first?.range(at: 1) else {
        print("Warning: Could not find regex match or capture group.")
        return nil
    }

    let dateAsString = profileNSString.substring(with: rangeOfCapturedGroupForDate)
    return dateAsString
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在运行时列出设备上的所有临时配置文件并获取其到期日期

来自分类Dev

使NLog配置文件用户在运行时定义

来自分类Dev

如何在运行时修改配置文件

来自分类Dev

在运行时获取Maven Java项目中激活的配置文件名称的列表

来自分类Dev

当Firefox运行时,如何查找正在运行的Firefox配置文件?

来自分类Dev

如何在运行时在春季加载其他bean配置文件

来自分类Dev

在运行时在Ansible 1.9中指定SSH配置文件

来自分类Dev

是否可以在运行时在不同的Winform项目上使用不同的配置文件?

来自分类Dev

在Bazel工具链配置文件中获取包的运行时路径

来自分类Dev

在运行时配置EJB查找

来自分类Dev

在运行时更新Dropwizard配置

来自分类Dev

Robotframework:使用“获取当前日期”以特定格式在运行时获取日期

来自分类Dev

在运行时获取RelativeLayout的尺寸

来自分类Dev

Android:在运行时获取TargetSDKVersion

来自分类Dev

在运行时获取jar版本

来自分类Dev

在运行时获取服务版本

来自分类Dev

在运行时获取NoSuchMethodError

来自分类Dev

在运行时获取输入类型

来自分类Dev

在运行时获取服务版本

来自分类Dev

在运行时获取数据

来自分类Dev

在运行时合并ResX文件?

来自分类Dev

在运行时加载JSON文件

来自分类Dev

在运行时加载JSON文件

来自分类Dev

在运行时读取 plist 文件

来自分类Dev

修改活动配置文件并刷新Spring Boot应用程序中的ApplicationContext运行时

来自分类Dev

K运行时的明显“配置文件”之间有什么区别?

来自分类Dev

在Gunicorn上运行时,如何使用python的cProfile对Django应用进行配置文件

来自分类Dev

如何在运行时从 Esper 配置对象获取 eventType

来自分类Dev

如何在运行时从程序包中以编程方式配置karaf / etc文件?

Related 相关文章

  1. 1

    在运行时列出设备上的所有临时配置文件并获取其到期日期

  2. 2

    使NLog配置文件用户在运行时定义

  3. 3

    如何在运行时修改配置文件

  4. 4

    在运行时获取Maven Java项目中激活的配置文件名称的列表

  5. 5

    当Firefox运行时,如何查找正在运行的Firefox配置文件?

  6. 6

    如何在运行时在春季加载其他bean配置文件

  7. 7

    在运行时在Ansible 1.9中指定SSH配置文件

  8. 8

    是否可以在运行时在不同的Winform项目上使用不同的配置文件?

  9. 9

    在Bazel工具链配置文件中获取包的运行时路径

  10. 10

    在运行时配置EJB查找

  11. 11

    在运行时更新Dropwizard配置

  12. 12

    Robotframework:使用“获取当前日期”以特定格式在运行时获取日期

  13. 13

    在运行时获取RelativeLayout的尺寸

  14. 14

    Android:在运行时获取TargetSDKVersion

  15. 15

    在运行时获取jar版本

  16. 16

    在运行时获取服务版本

  17. 17

    在运行时获取NoSuchMethodError

  18. 18

    在运行时获取输入类型

  19. 19

    在运行时获取服务版本

  20. 20

    在运行时获取数据

  21. 21

    在运行时合并ResX文件?

  22. 22

    在运行时加载JSON文件

  23. 23

    在运行时加载JSON文件

  24. 24

    在运行时读取 plist 文件

  25. 25

    修改活动配置文件并刷新Spring Boot应用程序中的ApplicationContext运行时

  26. 26

    K运行时的明显“配置文件”之间有什么区别?

  27. 27

    在Gunicorn上运行时,如何使用python的cProfile对Django应用进行配置文件

  28. 28

    如何在运行时从 Esper 配置对象获取 eventType

  29. 29

    如何在运行时从程序包中以编程方式配置karaf / etc文件?

热门标签

归档