Skip to content
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

[SR-4265] [SwiftPM] CURRENT_PROJECT_VERSION should be defined on generated-xcodeproj #5063

Closed
norio-nomura opened this issue Mar 16, 2017 · 9 comments
Assignees
Labels

Comments

@norio-nomura
Copy link
Contributor

Previous ID SR-4265
Radar None
Original Reporter @norio-nomura
Type Bug
Environment

swift-3.1-DEVELOPMENT-SNAPSHOT-2017-03-15-a
swift-DEVELOPMENT-SNAPSHOT-2017-03-15-a

Additional Detail from JIRA
Votes 4
Component/s Package Manager
Labels Bug
Assignee @abertelrud
Priority Medium

md5: 97683a9b8e492477adf93de57734c991

relates to:

  • SR-12926 provide a way to get the SHA of the current package in code

Issue Description:

SwiftPM generates `Info.plist` to library targets on generating Xcode project.
Those `Info.plist` contain `CFBundleVersion` key as following:

  <key>CFBundleVersion</key>
  <string>$(CURRENT_PROJECT_VERSION)</string>

But, generated Xcode project does not have settings that defines `CURRENT_PROJECT_VERSION`, so framework target is build with emtpty `CFBundleVersion` key in their `Info.plist`.
If those frameworks are used on Apps, those are rejected on validation by iTunes connect with following error:

This bundle Pyload/****.app/Frameworks/***.framework is invalid.
The Info.plist file is missing the required key: CFBundleVersion.

Xcode's template for framework target has settings that defining `CURRENT_PROJECT_VERSION` as `1` for avoiding such scenario.

SwiftPM should define `CURRENT_PROJECT_VERSION` as `1` on generating Xcode project as same as Xcode's template does.

@belkadan
Copy link

Should it actually try to infer a version number? CFBundleVersion isn't a compatibility version or anything, although it is supposed to be machine-parseable.

@abertelrud
Copy link
Contributor

`CURRENT_PROJECT_VERSION` is a build setting that `agvtool` operates on, but it mainly applies to authored Xcode projects. In the case of generated projects, I think it would make sense to use the package version for each target. It isn't clear what the right value is for the top-level package, though.

@norio-nomura
Copy link
Contributor Author

I expect to fix on following scenario that creating new library package:

  1. `git init`
  2. `swift package init --type library`
  3. `swift package generate-xcodeproj`
  4. `open <generated>.xcodeproj`
  5. developing…

On above steps, version tag is not yet created.
Of course it would be helpful, if tagged version can be applied to Xcode project in later stage on developing the library package.

@norio-nomura
Copy link
Contributor Author

Quick help in Xcode's Build Settings view says that should be integer or float:

CURRENT_PROJECT_VERSION

Value Type String

Description This setting defines the current version of the project. The value must be a integer or floating point number like 57 or 365.8.

Which is correct?

@abertelrud
Copy link
Contributor

Xcode really only has two kinds of build settings: string and string list. It's definitely not a list, so it's stored as a string. That's what the "Value Type: String" means.

But this particular build setting is then interpreted as a floating point number (of which an integer is just a special case, in the same way that `double f = 42` is the same as `double f = 42.0` in C). So I guess the correct way to think about it is that it's the string representation of a floating point number.

@belkadan
Copy link

I think the point was that floating-point numbers are not version strings, even numeric-only version strings.

@abertelrud
Copy link
Contributor

I see — I misunderstood the question as being whether `CURRENT_PROJECT_VERSION` stores a string or number.

I don't know if this helps, but I think that because it stores a string value, it can actually contain a version value such as "1.2.3", despite what the documentation says. `agvtool` seems to operate on it correctly (e.g. `next-version` works as documented, though I don't know how interesting that behavior is in the case of packages). The unparsed string value makes its way into the `CFBundleVersion` key of the `Info,plist`, so I think it's still feasible to use the package number as the value of the `CURRENT_PROJECT_VERSION` setting.

This probably also warrants a bug report on Xcode's documentation, since it seems that the value for `CURRENT_PROJECT_VERSION` follows the rules for the `CFBundleVersion` key, i.e. it's not just an "integer or floating point number" as the QuickHelp says.

@ffried
Copy link
Contributor

ffried commented Aug 6, 2020

I've opened #2851 for this. Currently, it's just setting the version to 1, so that there is a value at least. A future improvement could e.g. use the current version of a package.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
@ikesyo
Copy link
Collaborator

ikesyo commented Mar 25, 2024

generate-xcodeproj command doesn't exist anymore. Closing.

@ikesyo ikesyo closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants