URLNavigator icon indicating copy to clipboard operation
URLNavigator copied to clipboard

xcode15+ios17beta cannot adapt with https or http pattern

Open devAlanHey opened this issue 1 year ago • 8 comments

When I run my project with Xcode15 beta-4 and iOS17 beta-3, something is wrong with the URLNavigator. image cannot work expected;

image

when the value of candidate is "https://" or "http://", candidate.urlValue is nil.

devAlanHey avatar Jul 14 '23 07:07 devAlanHey

waiting for release Xcode15 and iOS17

devAlanHey avatar Jul 17 '23 01:07 devAlanHey

I met the same bug(or a feature?) when using Xcode 15 Beta 6 + iOS 17.0 Simulator(Beta 6).

Meanwhile, Xcode 14.3.1 + iOS 17.0 Simulator(Beta 6) works.

Jinya avatar Aug 20 '23 17:08 Jinya

@Jinya yeah, the same encounter!
It‘s seems apple's issue. Apple fixed a series of beta issues including the ones I encountered. The official version is expected to resolve this issue.

Be patient and wait.

devAlanHey avatar Aug 21 '23 02:08 devAlanHey

+1, it's not fixed in iOS 17 beta 8

jiasongs avatar Sep 12 '23 06:09 jiasongs

Is this change causing this problem? @devAlanHey @devxoul

image https://developer.apple.com/documentation/foundation/nsurl/1572047-urlwithstring

MainByElse avatar Sep 12 '23 08:09 MainByElse

+1, it's not fixed in release Xcode15 and iOS17

JasonXZJ avatar Sep 26 '23 03:09 JasonXZJ

I met the same bug(or a feature?) when using Xcode 15.0 + iOS 17.1 Simulator

Meanwhile, Xcode 15.0 + iOS 17.1 Simulator works.

ETmanwenhan avatar Oct 08 '23 06:10 ETmanwenhan

只要稍微修改下匹配规则即可,将<>匹配修改为[]匹配,例如:

路由注册的代码 navigator.register("https://[path:_]") { url, _, _ -> UIViewController? in .... return vc }

URLNavigator 库中的 URLPathComponent.swift 中

extension URLPathComponent { init(_ value: String) { /* Xcode15 和 iOS 17 修改了URL的有效性校验规范,导致这种情况下无法有效初始化 URL,修改为 [path:_] 这种即可解决该问题

 苹果:https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes
 Github:https://github.com/devxoul/URLNavigator/issues/166
 */
//if value.hasPrefix("<") && value.hasSuffix(">") {
if value.hasPrefix("[") && value.hasSuffix("]") {
  let start = value.index(after: value.startIndex)
  let end = value.index(before: value.endIndex)
  let placeholder = value[start..<end] // e.g. "<int:id>" -> "int:id"
  let typeAndKey = placeholder.components(separatedBy: ":")
  if typeAndKey.count == 1 { // any-type placeholder
    self = .placeholder(type: nil, key: typeAndKey[0])
  } else if typeAndKey.count == 2 {
    self = .placeholder(type: typeAndKey[0], key: typeAndKey[1])
  } else {
    self = .plain(value)
  }
} else {
  self = .plain(value)
}

} }

quntion avatar Oct 11 '23 08:10 quntion