NativeScript / NativeScript/nativescript-cli

Can the Podfile generation better handle logical blocks

未關閉
#5,805 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

feature-pending-triage
主要語言
JavaScript
星號
1.1k
分支
204
平均合併
1 天 9 小時
30 天內合併 PR
8

描述

Is your feature request related to a problem? Please describe.

I wish I could apply variable logic when defining iOS deployment target in the application Podfile.

To set the IPHONEOS_DEPLOYMENT_TARGET we must define the platform version in two separate files to ensure both the target application and all dependencies meet our minimum desired version.

  1. App_Resources/iOS/build.xcconfig
    IPHONEOS_DEPLOYMENT_TARGET=16
  2. App_Resources/iOS/Podfile
    platform :ios, '16.0'

As suggested in the troubleshooting documentation, to ensure that all dependencies are also configured to this target it is suggested that we do the following... which works fine.

platform :ios, '13.0'

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
    end
  end
end

*See https://docs.nativescript.org/troubleshooting#cocoapods-could-not-find-compatible-versions-for-pod-higher-minimum-deployment-target

This makes 3 places where I need to update the target version for iOS.

Inspired by this answer, if I try to apply any kind of logic in the application Podfile, it is either stripped by the CocoaPodsPlatformManager or ignored altogether.

Doing this:

app_ios_deployment_target = Gem::Version.new('16.0')
platform :ios, app_ios_deployment_target.version

Results in this:

platform :ios, 

It looks like the Regex is trying to match a platform within quotes('") only.
^\\s*?#\\s*?(platform\\b\\s*?\\:\\s*?ios\\b(?:,\\s*?['"](.+)['"])?)

Ruby will also complain the variable app_ios_deployment_target does not exist, which is true because only the line matched by the Regex above is hoisted above any post_install hooks and all other code blocks are lost.

Describe the solution you'd like

It would be great if CocoaPodsPlatformManager.selectPlatformDataFromProjectPodfile could be expanded to match other expressions.

It would also be great if all other lines that are not the platform definition and are outside of hooks are hoisted first, so that variables could be used.

This could mean that we can have one source of truth when defining the iOS target. Which could be in App_Resources/iOS/build.xcconfig and the read from the Podfile, or better yet an environment variable.

Describe alternatives you've considered

No response

Anything else?

No response

Please accept these terms

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 lib/services/cocoapods-platform-manager.ts 開始,特別查看 selectPlatformDataFromProjectPodfile 及其平台比對運算式。追蹤 Podfile 行如何被提升,以及未加引號的 Ruby 運算式和 hooks 外部的程式碼如何處理。完成的標準是,所要求的基於變數的 deployment target 和前置條件行仍可使用,且不會被剝除。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
ruby, typescript
領域
cli, mobile
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。