KeyError:'DEPLOYMENT_TARGET_CLANG_FLAG_NAME' run building in Xcode 13

34gzjxbg  于 2023-05-23  发布在  其他
关注(0)|答案(1)|浏览(149)

自从升级到Xcode 13后,我在Xcode上构建nativescript应用程序时收到错误

./.build_env_vars.sh: line 454: declare: UID: readonly variable
NSLD: Swift bridging header '*-Swift.h' not found under '/Users/gaetan.delsaux/Library/Developer/Xcode/DerivedData/mbwsinventoryapp-egjrwafdujqbnuemdmqazirgunfd/Build/Intermediates.noindex/mbwsinventoryapp.build/Debug-iphonesimulator/mbwsinventoryapp.build/Objects-normal/x86_64'
Generating metadata...~/PhpstormProjects/mbws-inventory-app/platforms/ios/internal/metadata-generator/bin ~/PhpstormProjects/mbws-inventory-app/platforms/ios
Python version: 2.7.18 (v2.7.18:8d21aa21f2, Apr 19 2020, 20:48:48) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
Traceback (most recent call last):
  File "./build-step-metadata-generator.py", line 41, in <module>
    deployment_target_flag_name = env("DEPLOYMENT_TARGET_CLANG_FLAG_NAME")
  File "./build-step-metadata-generator.py", line 14, in env
    return os.environ[env_name]
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py", line 40, in __getitem__
    raise KeyError(key)
KeyError: 'DEPLOYMENT_TARGET_CLANG_FLAG_NAME'
Command Ld failed with a nonzero exit code

我看了看,我找到的答案都是与目标C有关的。
有没有人遇到过这个问题,并找到了解决方案?

ovfsdjhp

ovfsdjhp1#

解决方案是将NativeScript升级到6.5.5或更高版本,其中包含补丁。
如果您对技术细节感兴趣,或者来自其他项目,请继续阅读。
在Xcode 13.3及以上版本中,环境变量DEPLOYMENT_TARGET_CLANG_NAMEDEPLOYMENT_TARGET_CLANG_ENV_NAME不再存在。
您可以通过使用EFFECTIVE_PLATFORM_NAME手动确定这些值来解决这个问题:

platform = env("EFFECTIVE_PLATFORM_NAME")
if platform is "-iphoneos":
    flag = "-miphoneos-version-min"
    target = "IPHONEOS_DEPLOYMENT_TARGET"
elif platform is "-iphonesimulator":
    flag = "-mios-simulator-version-min"
    target = "IPHONEOS_DEPLOYMENT_TARGET"
elif platform is "-watchos"
    flag = "-mwatchos-version-min"
    target = "WATCHOS_DEPLOYMENT_TARGET"
elif platform is "-watchossimulator"
    flag = "-mwatchos-simulator-version-min"
    target = "WATCHOS_DEPLOYMENT_TARGET"
elif platform is "-appletvos"
    flag = "-mappletvos-version-min"
    target = "APPLETVOS_DEPLOYMENT_TARGET"
elif platform is "-appletvsimulator":
    flag = "-mappletvsimulator-version-min"
    target = "APPLETVOS_DEPLOYMENT_TARGET"
else:
    flag = "-mmacosx-version-min"
    target = "MACOSX_DEPLOYMENT_TARGET"

感谢https://github.com/NativeScript/ios-jsc/pull/1296的作者演示了这项技术。

相关问题