Title: Can the Podfile generation better handle logical blocks · Issue #5805 · NativeScript/nativescript-cli · GitHub
Open Graph Title: Can the Podfile generation better handle logical blocks · Issue #5805 · NativeScript/nativescript-cli
X Title: Can the Podfile generation better handle logical blocks · Issue #5805 · NativeScript/nativescript-cli
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 ...
Open Graph 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_TAR...
X 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_TAR...
Opengraph URL: https://github.com/NativeScript/nativescript-cli/issues/5805
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Can the Podfile generation better handle logical blocks ","articleBody":"### Is your feature request related to a problem? Please describe.\r\n\r\nI wish I could apply variable logic when defining iOS deployment target in the application Podfile.\r\n\r\nTo 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.\r\n\r\n1. **App_Resources/iOS/build.xcconfig**\r\n `IPHONEOS_DEPLOYMENT_TARGET=16`\r\n2. **App_Resources/iOS/Podfile**\r\n `platform :ios, '16.0'`\r\n\r\nAs 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.\r\n\r\n```\r\nplatform :ios, '13.0'\r\n\r\npost_install do |installer|\r\n installer.pods_project.targets.each do |target|\r\n target.build_configurations.each do |config|\r\n config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'\r\n end\r\n end\r\nend\r\n```\r\n*_See_ https://docs.nativescript.org/troubleshooting#cocoapods-could-not-find-compatible-versions-for-pod-higher-minimum-deployment-target\r\n\r\nThis makes 3 places where I need to update the target version for iOS.\r\n\r\nInspired by [this answer](App_Resources/iOS/build.xcconfig), if I try to apply any kind of logic in the application Podfile, it is either stripped by the [CocoaPodsPlatformManager](https://github.com/NativeScript/nativescript-cli/blob/main/lib/services/cocoapods-platform-manager.ts) or ignored altogether.\r\n\r\nDoing this:\r\n```\r\napp_ios_deployment_target = Gem::Version.new('16.0')\r\nplatform :ios, app_ios_deployment_target.version\r\n```\r\n\r\nResults in this:\r\n```\r\nplatform :ios, \r\n```\r\n\r\nIt looks like the Regex is trying to match a platform within quotes('\") only.\r\n`^\\\\s*?#\\\\s*?(platform\\\\b\\\\s*?\\\\:\\\\s*?ios\\\\b(?:,\\\\s*?['\"](.+)['\"])?)`\r\n\r\nRuby 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.\r\n\r\n\r\n\r\n### Describe the solution you'd like\r\n\r\nIt would be great if [CocoaPodsPlatformManager.selectPlatformDataFromProjectPodfile](https://github.com/NativeScript/nativescript-cli/blob/main/lib/services/cocoapods-platform-manager.ts#L139) could be expanded to match other expressions.\r\n\r\nIt 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.\r\n\r\nThis 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.\r\n\r\n### Describe alternatives you've considered\r\n\r\n_No response_\r\n\r\n### Anything else?\r\n\r\n_No response_\r\n\r\n### Please accept these terms\r\n\r\n- [X] I have searched the [existing issues](https://github.com/NativeScript/nativescript-cli/issues) as well as [StackOverflow](https://stackoverflow.com/questions/tagged/nativescript) and this has not been posted before\r\n- [X] I agree to follow this project's [Code of Conduct](https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#coc)","author":{"url":"https://github.com/insytes","@type":"Person","name":"insytes"},"datePublished":"2024-07-03T14:50:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/5805/nativescript-cli/issues/5805"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:95d3ad6c-128c-fe81-9552-5a5f76f571a6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B58C:204573:6EEFC47:92D596E:696DDD28 |
| html-safe-nonce | bac05cb45504c92524a8befad02b4bf5d4d0624c857f5153eb32d3351ca807a7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNThDOjIwNDU3Mzo2RUVGQzQ3OjkyRDU5NkU6Njk2REREMjgiLCJ2aXNpdG9yX2lkIjoiNjg2MTc0ODA5NDQwODQ0OTMyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a40ffc6fcdc02766ada61c489c0de67b2806004504c4751c91abc6978729440a |
| hovercard-subject-tag | issue:2388839540 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/nativescript-cli/5805/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6d8302bbcb94556a411d1616a314d2da5ff4cbca87c08acb3d121ffd15fa344c/NativeScript/nativescript-cli/issues/5805 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6d8302bbcb94556a411d1616a314d2da5ff4cbca87c08acb3d121ffd15fa344c/NativeScript/nativescript-cli/issues/5805 |
| og:image:alt | 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_TAR... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | insytes |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4922b452d03cd8dbce479d866a11bc25b59ef6ee2da23aa9b0ddefa6bd4d0064 |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/nativescript-cli git https://github.com/NativeScript/nativescript-cli.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 21347346 |
| octolytics-dimension-repository_nwo | NativeScript/nativescript-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21347346 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/nativescript-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7e5ae23c70136152637ceee8d6faceb35596ec46 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width