NativeScript / NativeScript/nativescript-cli

Can the Podfile generation better handle logical blocks

Ouverte
#5,805 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

feature-pending-triage
Langage dominant
JavaScript
Étoiles
1.1k
Forks
204
Merge moyen
1 j 9 h
PR mergées (30 j)
8

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par lib/services/cocoapods-platform-manager.ts, en particulier par selectPlatformDataFromProjectPodfile et son expression de correspondance de plateforme. Suivez la manière dont les lignes du Podfile sont remontées, ainsi que la manière dont les expressions Ruby non placées entre guillemets et le code situé en dehors des hooks sont traités. Le travail est terminé lorsque le deployment target basé sur une variable demandé et les lignes prérequises restent utilisables sans être supprimés.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
ruby, typescript
Domaine
cli, mobile
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.