danthorpe / Money

Swift value types for working with money & currency
MIT License
933 stars 91 forks source link

Swift 3 Support #52

Open joejcon1 opened 8 years ago

joejcon1 commented 8 years ago

Hi,

Are there any intentions for an update to support Swift 3 for this library? If not I'm happy to take a stab at it and submit a PR if you're open to it.

Thanks for a great library!

danthorpe commented 8 years ago

Yeah - definitely got plans to update/maintain it for Swift 3. Need to look through the some of the changes in Foundation though - as ideally would like to improve the underlying decimal number maths to be more Swifty/ValueType.

Will have some progress during the week I expect.

danthorpe commented 8 years ago

Unfortunately at the moment, this is sort of reliant on Swift 3.0 version of ValueCoding too, which has it's own issues, see: https://github.com/danthorpe/ValueCoding/pull/18.

danthorpe commented 8 years ago

There is a pull request, #55 which has Swift 3.0 support for Money.

There are a few breaking changes - mostly around Locale getting its name taken by NSLocale, so this is now Localization.

Similarly there are number of other Swift 3.0 style name changes.

Wilsonilo commented 7 years ago

Hey @danthorpe sorry for the question but to use the branch of Swift 3 with pods... I've being trying to use it and still pulls the one for 2.3, again sorry, may be something really dumb to do.

damirstuhec commented 7 years ago

@danthorpe I'm still getting lots of errors when building Swift 3 project with your #55 PR.

screen shot 2016-10-15 at 19 12 07 screen shot 2016-10-15 at 19 12 16
msewell commented 7 years ago

I'm using Money through Cocoapods.

pod 'Money',
     :git => 'https://github.com/danthorpe/Money.git',
     :branch => 'swift/3.0'

Using the latest swift/3.0 branch commit (44199cde8ecbeeca09ae9d54c7ccc982bfbe8d8c) lets me build Money in my Swift 3 app, but since Money.podspec still points to ValueCoding 1.5 as its dependency (instead of ValueCoding 2.x, which is the version written in Swift 3), I cannot use Money through CocoaPods.

What is the recommended workaround for using Money in a Swift 3 app at present? Should I not be using CocoaPods to install Money?

danthorpe commented 7 years ago

Hi @msewell - yeah, sorry - known issue r.e. the .podspec will hopefully get this sorted asap - ran out of time at the weekend.

danthorpe commented 7 years ago

Done! Sorry it took so long to update - real job and ProcedureKit have got in the way! Anyway, can now do this

pod 'Money', '~> 2'

for CocoaPods, or this:

github "danthorpe/Money" "~> 2"

for Carthage.

Wilsonilo commented 7 years ago

Thanks @danthorpe for your hard work! T("T)

simonbarker commented 7 years ago

Just updating a project to swift 3 and using the suggest line above

pod 'Money', '~> 2

I get this error on pod install

Analyzing dependencies
[!] Unable to satisfy the following requirements:

- `Money (~> 2)` required by `Podfile`

None of your spec sources contain a spec satisfying the dependency: `Money (~> 2)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.

I assume I've missed something simple, any help would be great

dylankbuckley commented 7 years ago

@danthorpe I am getting the same as @simonbarker

omdika commented 6 years ago

Hi @danthorpe ! I am using Money 2.0.1 for my Swift 3.2 project using Xcode 9.0 and I getting some errors like this: screen shot 2017-11-07 at 17 45 49 is there something I've missed? thanks

danthorpe commented 6 years ago

Hi @omdika - You can point your pod to this branch: feature/MNY-79_updates_for_xcode_9 which builds for Swift 3.2. Please feedback to PR #84 .

It's not yet 100% complete - let me know how you go. There were lots of sneaky changes related to decimal support in Swift 3.2.

omdika commented 6 years ago

Thanks for your quick help @danthorpe , previous error is missing now. But there is another one: screen shot 2017-11-07 at 18 40 53 screen shot 2017-11-07 at 18 41 06 have I missed something?

danthorpe commented 6 years ago

Yeah, haven't spent much time with custom currencies at the moment, and CustomCurrencyType doesn't exist anymore. Or at least, not at the moment.

Instead, you can try conforming to CurrencyProtocol instead. You are the first person to bump into this.