bamlab / fastlane-plugin-cordova

Integrate your Cordova build into your Fastlane setup
MIT License
115 stars 39 forks source link

build_number option doesn't work on iOS #9

Closed randomPoison closed 7 years ago

randomPoison commented 7 years ago

When I have the action cordova(platform: "ios", build_number: 123) in my Fastfile, it calls the Cordova command line tool with the following arguments:

cordova build ios --release --device --packageType=app-store --developmentTeam=XXXXXX --provisioningProfile=XXXXXXX --CFBundleVersion=123 -- 

fastlane-plugin-cordova appears to be passing the build number via a --CFBundleVersion argument to cordova build ios, however, according to the docs for cordova build ios and the platform docs for iOS, there's no such flag. In practice, the build number that I give to fastlane-plugin-cordova does nothing on iOS (though it works as expected for Android, yay).

From what I can tell, the only way Cordova supports of specifying the bundle version on iOS is via the ios-CFBundleVersion attribute in Config.xml. I tested it out, and I can confirm that setting the ios-CFBundleVersion in Config.xml correctly sets the bundle version for the build, even when using fastlane-plugin-cordova.

If you want fastlane-plugin-cordova to support overriding the build number (which would be useful to me for the purpose of build automation), then the "right" way of doing it would probably be to manually modify the value of the CFBundleVersion key in the PROJECT-Info.plist file in the generated Xcode project. It would also work to temporarily modify the project's Config.xml to add/modify the ios-CFBundleVersion attribute, but it seems like bad form to silently modify project's configuration file.

If anyone has any thoughts on this, please let me know. If modifying Info.plist sounds like the right approach, I can work on putting together a PR that fixes the functionality.

Almouro commented 7 years ago

Hi @excaliburHisSheath , thanks for this greatly detailed issue! :)

Modifying the Plist seems indeed like the right way to do so: you can use the update_info_plist action if needed. For instance, this is how it's used in one of my projects:

update_info_plist(
      xcodeproj: xcodeproj,
      plist_path: ENV['IOS_PLIST_PATH'],
      block: lambda { |plist|
        plist['CFBundleIdentifier'] = ENV['IOS_APP_ID']
        plist['CFBundleName'] = ENV['IOS_APP_NAME']
        plist['CFBundleDisplayName'] = ENV['IOS_APP_NAME']
        plist['CFBundleShortVersionString'] = ENV['IOS_VERSION']
        plist['CFBundleVersion'] = ENV['IOS_VERSION_BUILD_NUMBER']
      },
    )

Maybe @stalniy, who added the build number feature has more insights?

stalniy commented 7 years ago

For now, the only option is to use increment_build_number or update_info_plist. I created related issue for cordova-ios

randomPoison commented 7 years ago

@stalniy @Almouro In that case, I'll try to put together a PR that uses update_info_plist. When Cordova supports specifying CFBundleVersion via the command line, fastlane-plugin-cordova should switch to using that.

stalniy commented 7 years ago

sounds good to me :+1: