Money icon indicating copy to clipboard operation
Money copied to clipboard

Swift 3 Support

Open joejcon1 opened this issue 9 years ago • 15 comments

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!

joejcon1 avatar Jun 25 '16 22:06 joejcon1

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 avatar Jun 25 '16 23:06 danthorpe

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 avatar Jun 26 '16 16:06 danthorpe

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.

danthorpe avatar Jul 17 '16 20:07 danthorpe

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.

Wilsonilo avatar Sep 25 '16 18:09 Wilsonilo

@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

damirstuhec avatar Oct 15 '16 17:10 damirstuhec

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?

msewell avatar Oct 19 '16 12:10 msewell

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

danthorpe avatar Oct 19 '16 13:10 danthorpe

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.

danthorpe avatar Oct 19 '16 21:10 danthorpe

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

Wilsonilo avatar Oct 19 '16 21:10 Wilsonilo

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

simonbarker avatar Nov 30 '16 18:11 simonbarker

@danthorpe I am getting the same as @simonbarker

dylankbuckley avatar Dec 12 '16 03:12 dylankbuckley

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

omdika avatar Nov 07 '17 10:11 omdika

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.

danthorpe avatar Nov 07 '17 11:11 danthorpe

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?

omdika avatar Nov 07 '17 12:11 omdika

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.

danthorpe avatar Nov 07 '17 12:11 danthorpe