Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-11794

Hook after_build not working on iOS

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Ionic
    • None

    Description

      I discovered the bug, by following this scenario:

      clean ionic project;
      open terminal at project root;

      1. rm -rf plugins/ (remove the plugins folder)
      2. cordova add platform ios
      3. cordova build ios
      4. ls -l platforms/ios/<PROJECT_NAME>/Images.xcassets/AppIcon.appiconset/ and ls -l platforms/ios/<PROJECT_NAME>/Images.xcassets/LaunchImage.launchimage/
      5. in both folders found above, we find the Contents.json file that tells xcode which icon/splash screen goes to wich resolution
      6. cordova platform rm ios
      7. cordova platform add ios (add the platform again, but the plugins are installed from plugins/ folder found in the root of the project)
      8. cordova build ios
      9. ls -l platforms/ios/<PROJECT_NAME>/Images.xcassets/AppIcon.appiconset/ and ls -l platforms/ios/<PROJECT_NAME>/Images.xcassets/LaunchImage.launchimage/
      10. in both folders found above is missing the Contents.json file, so, after we open <PROJECT_NAME>.xcodeproj file in xcode, all the icons and launch screens are unassigned, so the app starts on the iOS device at a wrong resolution. (example: run app on iPhone 5C and the app starts at iPhone 4 resolution with black bars on top and bottom).
      

      I think this might be a cordova Bug but I am not sure.

      As a workaround, I copied the Contents.json files to another location in my project and:

      1. added an after_build hook to copy these file into platforms/ios/<PROJECT_NAME>/Images.xcassets/AppIcon.appiconset/ and platforms/ios/<PROJECT_NAME>/Images.xcassets/LaunchImage.launchimage/ paths.
      2. cordova platform rm ios
      3. cordova platform add ios
      4. cordova build ios
      5. this should be the place where the after_build hook should run.
      

      If you run cordova build ios again the hook works.

      I have noticed that the first time you run cordova build ios the message "** BUILD SUCCEEDED **" does not appear, sometimes only after the third time of running cordova build ios this message appears. From what I can tell only when the message ** BUILD SUCCEEDED ** appears the after_build hook is run.

      This issue can be reproduced with the after_compile hook as well.

      What I have done in order to achieve this "workaround" is: I have made a before_compile hook which copies the Contents.json file where it should be copied and it works.

      I hope that I described the problem well. If there are any questions you can ask me later

      Attachments

        Activity

          People

            Unassigned Unassigned
            radu.moian Radu Moian-Dusa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: