Skip to content

Swift Compiler Error (Xcode): Cannot find 'TARGET_IPHONE_SIMULATOR' in scope #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pamir72 opened this issue Apr 1, 2025 · 4 comments

Comments

@pamir72
Copy link

pamir72 commented Apr 1, 2025

После обновления на Xcode 16.3 не компилируется приложение.
Ошибка:

Swift Compiler Error (Xcode): Cannot find 'TARGET_IPHONE_SIMULATOR' in scope
.../.pub-cache/hosted/pub.dev/yandex_mapkit-4.1.0/ios/Classes/lite/YandexMapController.swift:235:12

Could not build the application for the simulator.
Error launching application on iPhone 16 Pro Max.

Да, кстати, прочитал, что TARGET_IPHONE_SIMULATOR deprecated

--

PS: Временная заплатка: к сожалению, не знаком со Swift и вообще написанием ПО чисто под iOS, но погуглив тему, прям сюда: pub-cache/hosted/pub.dev/yandex_mapkit-4.1.0/ios/Classes/lite/YandexMapController.swift

вместо:

private static func isM1Simulator() -> Bool {
return (TARGET_IPHONE_SIMULATOR & TARGET_CPU_ARM64) != 0
}

вставил этот код:

#if targetEnvironment(simulator)
public static func isM1Simulator() -> Bool {
return TARGET_CPU_ARM64 != 0
}
#else
public static func isM1Simulator() -> Bool { false }
#endif

Не знаю, правильно ли сделал, но после этого все скомпилировалось.
В любом случае проблемка требует нормального решения.

@alxmoroz
Copy link

alxmoroz commented Apr 1, 2025

Да, надо бы разобраться с deprecated TARGET_IPHONE_SIMULATOR
В этом PR поправлено #394

@aiserrock
Copy link

@DCrow когда докатите исправление до pubdev?
в PR поправлено #394

@Crepiks
Copy link

Crepiks commented Apr 15, 2025

Создал второй PR c исправлением — #395. Те же изменения, только причесал форматирование и докинул больше описания.

Пока решением является изменять статическую функцию isM1Simulator в локальной копии загруженной зависимости в файле YandexMapController.swift, заменяя её таким блоком кода:

private static func isM1Simulator() -> Bool {
  #if arch(arm64) && os(iOS) && targetEnvironment(simulator)
    return true
  #else
    return false
  #endif
}

@Muhammadyunusxon
Copy link

  yandex_mapkit:
    git:
      url: https://github.com/muhammadyunusxon/yandex_mapkit.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants