Skip to content

Podfile generation broken on livesync #3549

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

Closed
vcooley opened this issue Apr 26, 2018 · 19 comments · Fixed by #3900
Closed

Podfile generation broken on livesync #3549

vcooley opened this issue Apr 26, 2018 · 19 comments · Fixed by #3900

Comments

@vcooley
Copy link

vcooley commented Apr 26, 2018

Which platform(s) does your issue occur on?

iOS

Please provide the following version numbers that your issue occurs with:

  • CLI: 4.0.0
  • Cross-platform modules: 4.0.0
  • Runtime(s): 4.0.1
  • Plugin(s):
    "nativescript-advanced-webview": "^1.1.3",
    "nativescript-angular": "~5.3.0",
    "nativescript-async": "^1.0.2",
    "nativescript-bottombar": "^3.0.8",
    "nativescript-directions": "^1.2.0",
    "nativescript-drop-down": "^3.2.4",
    "nativescript-floatingactionbutton": "^3.0.0",
    "nativescript-geolocation": "^3.0.0",
    "nativescript-google-maps-sdk": "^2.6.0",
    "nativescript-gradient": "^2.0.1",
    "nativescript-input-mask": "^1.0.0",
    "nativescript-iqkeyboardmanager": "~1.1.0",
    "nativescript-ng-shadow": "^2.0.0",
    "nativescript-plugin-firebase": "^5.3.0",
    "nativescript-pro-ui": "^3.3.0",
    "nativescript-snackbar": "^2.0.0",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-unit-test-runner": "^0.3.4",

Please tell us how to recreate the issue in as much detail as possible.

Running tns run ios --clean with this configuration produces a working build, however any changes made to the code cause the Podfile to be rebuilt in a way that causes a recursion error.

Here is my Podfile (from platforms/ios) after the initial build:

use_frameworks!

target "myproject" do
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-bottombar/platforms/ios/Podfile 
 use_frameworks!
pod 'MiniTabBar', :git => 'https://github.com/rhanb/MiniTabBar.git'
def post_install1 (installer)
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.0'
        end
    end
end 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-floatingactionbutton/platforms/ios/Podfile 
 pod 'MNFloatingActionButton', '~> 0.1.5' 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-google-maps-sdk/platforms/ios/Podfile 
 source 'https://github.com/CocoaPods/Specs.git'

pod 'GoogleMaps' 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-input-mask/platforms/ios/Podfile 
 pod 'InputMask', :path => '~/Projects/input-mask-ios'

def post_install2 (installer)
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.0'
    end
  end
end 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-iqkeyboardmanager/platforms/ios/Podfile 
 pod 'IQKeyboardManager', '~> 4.0.0'
 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-plugin-firebase/platforms/ios/Podfile 
 pod 'Firebase', '~> 4.11.0' 
pod 'Firebase/Auth'

# Uncomment if you want to enable Realtime DB
pod 'Firebase/Database'

# Uncomment if you want to enable Cloud Firestore
pod 'Firebase/Firestore'

# Uncomment if you want to enable Remote Config
#pod 'Firebase/RemoteConfig'

# Uncomment if you want to enable Crash Reporting
#pod 'Firebase/Crash'

# Uncomment if you want to enable Crashlytics
pod 'Fabric'
pod 'Crashlytics'
# Crashlytics works best without bitcode
def post_install3 (installer)
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ENABLE_BITCODE'] = "NO"
        end
    end
end

# Uncomment if you want to enable FCM (Firebase Cloud Messaging)
#pod 'Firebase/Messaging'

# Uncomment if you want to enable Firebase Storage
#pod 'Firebase/Storage'

# Uncomment if you want to enable AdMob
#pod 'Firebase/AdMob'

# Uncomment if you want to enable Invites and/or Dynamic Links
#pod 'Firebase/Invites'

# Uncomment if you want to enable Facebook Authentication
#pod 'FBSDKCoreKit'
#pod 'FBSDKLoginKit'

# Uncomment if you want to enable Google Authentication
#pod 'GoogleSignIn' 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-snackbar/platforms/ios/Podfile 
 pod 'SSSnackbar', :git => 'https://github.com/EddyVerbruggen/SSSnackbar.git', :tag => '0.1.2.4' 
 # End Podfile 

end
post_install do |installer|
  post_install1 installer
  post_install2 installer
  post_install3 installer
end

And here is my Podfile after making a change within my application's code. The problem occurs in the post_install1 method, which recursively calls itself, but the entire Podfile is mangled:

use_frameworks!

target "myproject" do
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-bottombar/platforms/ios/Podfile 
 use_frameworks!
pod 'MiniTabBar', :git => 'https://github.com/rhanb/MiniTabBar.git'
def post_install1 (installer)
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.0'
        end
    end
end 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-floatingactionbutton/platforms/ios/Podfile 
 pod 'MNFloatingActionButton', '~> 0.1.5' 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-google-maps-sdk/platforms/ios/Podfile 
 source 'https://github.com/CocoaPods/Specs.git'

pod 'GoogleMaps' 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-input-mask/platforms/ios/Podfile 
 pod 'InputMask', :path => '~/Projects/input-mask-ios'

def post_install2 (installer)
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.0'
    end
  end
end 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-iqkeyboardmanager/platforms/ios/Podfile 
 pod 'IQKeyboardManager', '~> 4.0.0'
 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-plugin-firebase/platforms/ios/Podfile 
 pod 'Firebase', '~> 4.11.0' 
pod 'Firebase/Auth'

# Uncomment if you want to enable Realtime DB
pod 'Firebase/Database'

# Uncomment if you want to enable Cloud Firestore
pod 'Firebase/Firestore'

# Uncomment if you want to enable Remote Config
#pod 'Firebase/RemoteConfig'

# Uncomment if you want to enable Crash Reporting
#pod 'Firebase/Crash'

# Uncomment if you want to enable Crashlytics
pod 'Fabric'
pod 'Crashlytics'
# Crashlytics works best without bitcode
def post_install3 (installer)
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ENABLE_BITCODE'] = "NO"
        end
    end
end

# Uncomment if you want to enable FCM (Firebase Cloud Messaging)
#pod 'Firebase/Messaging'

# Uncomment if you want to enable Firebase Storage
#pod 'Firebase/Storage'

# Uncomment if you want to enable AdMob
#pod 'Firebase/AdMob'

# Uncomment if you want to enable Invites and/or Dynamic Links
#pod 'Firebase/Invites'

# Uncomment if you want to enable Facebook Authentication
#pod 'FBSDKCoreKit'
#pod 'FBSDKLoginKit'

# Uncomment if you want to enable Google Authentication
#pod 'GoogleSignIn' 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-snackbar/platforms/ios/Podfile 
 pod 'SSSnackbar', :git => 'https://github.com/EddyVerbruggen/SSSnackbar.git', :tag => '0.1.2.4' 
 # End Podfile 

end
def post_install1 (installer)
  post_install1 installer
  post_install2 installer
  post_install3 installer# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-bottombar/platforms/ios/Podfile 
 use_frameworks!
pod 'MiniTabBar', :git => 'https://github.com/rhanb/MiniTabBar.git'
def post_install2 (installer)
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.0'
        end
    end
end 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-input-mask/platforms/ios/Podfile 
 pod 'InputMask', :path => '~/Projects/input-mask-ios'

def post_install3 (installer)
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.0'
    end
  end
end 
 # End Podfile 
# Begin Podfile - /Users/vincecooley/Projects/myproject/node_modules/nativescript-plugin-firebase/platforms/ios/Podfile 
 pod 'Firebase', '~> 4.11.0' 
pod 'Firebase/Auth'

# Uncomment if you want to enable Realtime DB
pod 'Firebase/Database'

# Uncomment if you want to enable Cloud Firestore
pod 'Firebase/Firestore'

# Uncomment if you want to enable Remote Config
#pod 'Firebase/RemoteConfig'

# Uncomment if you want to enable Crash Reporting
#pod 'Firebase/Crash'

# Uncomment if you want to enable Crashlytics
pod 'Fabric'
pod 'Crashlytics'
# Crashlytics works best without bitcode
def post_install4 (installer)
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ENABLE_BITCODE'] = "NO"
        end
    end
end

# Uncomment if you want to enable FCM (Firebase Cloud Messaging)
#pod 'Firebase/Messaging'

# Uncomment if you want to enable Firebase Storage
#pod 'Firebase/Storage'

# Uncomment if you want to enable AdMob
#pod 'Firebase/AdMob'

# Uncomment if you want to enable Invites and/or Dynamic Links
#pod 'Firebase/Invites'

# Uncomment if you want to enable Facebook Authentication
#pod 'FBSDKCoreKit'
#pod 'FBSDKLoginKit'

# Uncomment if you want to enable Google Authentication
#pod 'GoogleSignIn' 
 # End Podfile 

end
post_install do |installer|
  post_install1 installer
  post_install2 installer
  post_install3 installer
  post_install4 installer
end
@DickSmith
Copy link

This seems to be caused by having comments in the merged podfiles as mentioned here:
EddyVerbruggen/nativescript-plugin-firebase#684

@speigg
Copy link

speigg commented May 24, 2018

My pod file keeps getting messed up as well. Increasingly so every time I try to build.

@NathanWalker
Copy link
Contributor

NathanWalker commented May 25, 2018

@rosen-vladimirov If you have a branch in progress perhaps could post it and reference this issue just so others can see movement here as it's big issue affecting many at moment.

@rosen-vladimirov
Copy link
Contributor

Hey guys, we've investigated this issue and I confirm the unexpected behavior. It can be easily reproduced by executing the following commands:

$ tns create myApp
$ cd myApp
$ tns plugin add nativescript-input-mask
$ tns plugin add nativescript-bottombar
$ tns run ios
$ tns run ios

We are working on a fix and I'll write back once we have more information.

@rosen-vladimirov rosen-vladimirov added this to the 4.1.1 milestone May 29, 2018
@noumaans
Copy link

FWIW, we are experiencing this on iOS even if you simply issue:

$ tns prepare ios
$ tns build ios --bundle

I believe there is no livesync when one issues a tns build (but I might be wrong).

The podfile issue also occurs on repeated tns builds:

$ tns build ios --bundle
$ tns build ios --bundle

The only way around this is to remove platform, add platform, skip the prepare step and issue build directly (for every single build iteration).

$ tns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 4.0.2 version and is up to date.
✔ Component tns-core-modules has 4.2.0-2018-05-28-04 version and is up to date.
✔ Component tns-android has 4.2.0-2018-05-29-02 version and is up to date.
✔ Component tns-ios has 4.1.0-2018-05-25-01 version and is up to date.

@rosen-vladimirov
Copy link
Contributor

Hey @noumaans ,
Can you please post your package.json as well, so we can investigate this scenario as well. Currently I've noticed the problem occurs when several of the plugins have postinstall scripts and also when CLI tries to prepare the plugins several times. The steps I've described include the nativescript-input-mask plugin, which currently has issue with its Podfile (I've logged an issue here: vcooley/nativescript-input-mask#2). In case all plugins have correct Podfiles, CLI should be able to handle them correctly at least in incremental builds, i.e. when the preparation of the plugins is skipped.

@noumaans
Copy link

@rosen-vladimirov

$ grep nativescript package.json 
  "nativescript": {
    "nativescript-angular": "^5.3.0",
    "nativescript-appavailability": "^1.3.1",
    "nativescript-appversion": "^1.4.1",
    "nativescript-bottombar": "^3.0.8",
    "nativescript-carousel": "^3.1.0",
    "nativescript-directions": "^1.2.0",
    "nativescript-geolocation": "^4.2.6",
    "nativescript-google-maps-sdk": "^2.6.0",
    "nativescript-gradient": "^2.0.1",
    "nativescript-iqkeyboardmanager": "^1.3.0",
    "nativescript-localstorage": "^1.1.5",
    "nativescript-ngx-fonticon": "4.1.0",
    "nativescript-phone": "^1.3.1",
    "nativescript-plugin-firebase": "^6.0.2",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-ui-dataform": "^3.6.0",
    "nativescript-ui-listview": "^3.5.7",
    "nativescript-web-image-cache": "^4.2.4",
    "nativescript-css-loader": "^0.26.1",
    "nativescript-dev-appium": "^3.3.0",
    "nativescript-dev-sass": "^1.5.0",
    "nativescript-dev-typescript": "^0.7.1",
    "nativescript-dev-webpack": "^0.11.0",
    "nativescript-worker-loader": "~0.8.1",

@nicHoch
Copy link

nicHoch commented Jun 12, 2018

same for me:


		"nativescript-appversion": "~1.4.1",
		"nativescript-bitmap-factory": "^1.7.1",
		"nativescript-bottom-navigation": "^1.2.0",
		"nativescript-clipboard": "^1.1.7",
		"nativescript-directions": "^1.0.5",
		"nativescript-dom": "^2.0.0",
		"nativescript-feedback": "^1.1.2",
		"nativescript-geolocation": "^3.0.0",
		"nativescript-google-maps-sdk": "^2.6.0",
		"nativescript-iqkeyboardmanager": "^1.3.0",
		"nativescript-master-technology": "^1.1.1",
		"nativescript-orientation": "^1.6.1",
		"nativescript-permissions": "^1.2.3",
		"nativescript-plugin-firebase": "^5.3.1",
		"nativescript-pro-ui": "^3.2.0",
		"nativescript-pulltorefresh": "^2.1.1",
		"nativescript-screenshot": "0.0.2",
		"nativescript-slides": "^2.2.12",
		"nativescript-social-login": "^4.0.1",
		"nativescript-sqlite": "^2.0.1",
		"nativescript-theme-core": "^1.0.4",
		"nativescript-webview-interface": "^1.4.2",

✔ Getting NativeScript components versions information...
✔ Component nativescript has 4.1.0 version and is up to date.
✔ Component tns-core-modules has 4.1.0 version and is up to date.
✔ Component tns-android has 4.1.2 version and is up to date.
✔ Component tns-ios has 4.1.0 version and is up to date.

@vcooley
Copy link
Author

vcooley commented Jun 12, 2018

I've done some investigation today. I've found that this problem is caused with certain combinations of plugins with Podfiles. For instance when I remove either nativescript-input-mask or nativescript-bottombar from my package and node_modules everything seems to work as expected.

I'm working on the issue mentioned by @rosen-vladimirov above. However in the meantime if you need to use the nativescript-input-mask plugin you can drop this unzip the dependency to ~/Projects/input-mask-ios.
input-mask-ios.zip

@rosen-vladimirov rosen-vladimirov modified the milestones: 4.1.1, 4.1.2 Jun 14, 2018
@rosen-vladimirov
Copy link
Contributor

Hey @vcooley , the issue is in CLI when regenerating the Podfile and I'm working on a fix. We'll do our best to release it in one of the next patches release of NativeScript CLI.

@rosen-vladimirov rosen-vladimirov modified the milestones: 4.1.2, 4.2.0 Jun 26, 2018
@NathanWalker
Copy link
Contributor

npm i -g nativescript@next fixes this issue 👍

Thanks for the fix.

@rosen-vladimirov
Copy link
Contributor

Hey @NathanWalker ,
Thanks to @sis0k0 we have fixed the case when --bundle is passed in the next version of CLI. The full fix for the Podfile regeneration will be included in 4.2.0. Thanks for your patience and cooperation.

@NathanWalker
Copy link
Contributor

The issue has surfaced again on iOS. disregard next - still an issue.

@rosen-vladimirov
Copy link
Contributor

rosen-vladimirov commented Jul 24, 2018

Hey guys,

I would like to share some details about this case, why it reappeared in master branch and what's the current plan for the fix.
The issue has been reported some time ago and at first we had some troubles reproducing it. After that we've successfully reproduced one case, but it seems to be caused by incorrect version of the nativescript-input-mask plugin. After some investigation, we confirmed there's a problem with CLI regenerating Podfile when more than one plugin has a Podfile with post_install hook.
However, we were still not sure what triggers the regeneration of Podfile - on theory it shouldn't happen when the node_modules are not modified.

Meanwhile we've received reports for similar issues for Android, where all plugins' .aar files have been rebuilt whenever there's a change in node_modules. All the reports included passing --bundle flag to the build, so we've investigated this case particularly.
At this point we did not have an idea what causes the unexpected regeneration of Podfile and rebuilding of .aar files when they shouldn't be rebuilt.
After some investigation, we have found some issues when --bundle flag is passed and these PRs should have fixed them: #3708 and #3711
The second PR "fixed" the issues with .aar and Podfile regeneration. However, we did not notice we've broken processing of any change in node_modules - CLI was checking the state of node_modules only if you pass --syncAllFiles. This works for tns run command, but it causes really strange and unexpected behavior when you run commands like tns build <platform> or tns prepare <platform> - the changes in node_modules are never processed and moved to the device.
So we had to deal with this case and this PR was born. The description contains all the details, but the most important part is that all CLI commands like tns prepare <platform>, tns build <platform> and the initial execution of tns run <platform> (i.e. the first part of the execution of this command, not only the first time when you run it) will check the state of node_modules and prepare the files from it in case it is necessary.
The PR had a fix for rebuilding .aar files only when the source files of the plugin had changed. However, we were unable to apply the same fix for iOS at this point. So that's what caused the issue with Podfile regeneration to reappear in master branch.

We have not stopped looking into this case, but the solution of the incorrect regeneration is not a simple one. Also, we were still not sure why the Podfile is regenerated on your side.
After further investigation and by using the information provided by @NathanWalker , we were able to understand what's happening - during development, Nathan is changing some files (like .scss, .ts, etc.) in a linked plugin. CLI detects the change and as the plugin is in node_modules, CLI decides to prepare the node_modules again. For iOS this includes regeneration of the Podfile. As the applied change is not in the <plugin dir>/platforms/ios/... CLI should not regenerate the project's Podfile in such case. And that's exactly what this PR does.
This PR will allow a development workflow where a change in node_modules is applied and it is not inside plugin's native part. Please note that CLI was not designed to support changes in node_modules with such details, i.e. to understand if the plugin requires rebuild, etc. The current fixes allow such workflow and the whole approach could be considered as new feature for CLI.
Anyway, the last PR will improve the workflow, but it will not fix the issue when multiple plugins have Podfiles with post_install hooks. In case you apply a change in any of the Podfiles of such plugins, CLI will still regenerate the project's Podfile and it will again brake the project.
In order to fix this, we have applied some complex changes, they are still on a branch as more tests must be added. You can give it a try by using the vladimirov/fix-podfile-issues-2 branch of NativeScript CLI. Currently it does not include the fixes from #3768 as this allows easier reproducing of the issue. The branch has a high regression potential, so we'll be very careful before merging it.

Please note that we have plans to merge #3768 and include it in 4.2.0 release. This should resolve your development workflow issues. The real fix for Podfile regeneration most probably will be included in the 4.2.1 release as it needs to be tested carefully.

Hope this clears the case. We've not stopped working and investigating this issue. The main problem we had is to understand why CLI decides to prepare node_modules again. In order to resolve such issues faster in the future, please share all details about your steps, what's your exact workflow and where you apply changes in your source.

@NathanaelA

This comment was marked as abuse.

@rosen-vladimirov
Copy link
Contributor

Hey @NathanaelA , the mentioned PR should fix exactly this behavior - no matter if you pass --syncAllFiles or not, CLI should not reprepare native parts of plugins in case they are not changed. That's what the PR fixes as behavior. It will soon land in the next, so you'll be able to give it a try.

@rosen-vladimirov
Copy link
Contributor

So @NathanaelA , @NathanWalker - the fix is in master branch and in CLI's next version. Can you give it a try and see if it resolves your issue?

@DickSmith
Copy link

Hey @rosen-vladimirov,

I can confirm nativescript@next is working for the project @NathanWalker has been referring too. Both with and without --syncAllFiles.

Thanks again. :D

@NathanWalker
Copy link
Contributor

Nice work @rosen-vladimirov 🙌 ❤️

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

Successfully merging a pull request may close this issue.

10 participants