caiyue1993 / IceCream

Sync Realm Database with CloudKit
MIT License
1.93k stars 243 forks source link

Use latest RealmSwift #256

Open leoz opened 2 years ago

leoz commented 2 years ago

Use latest RealmSwift v10.21.1. Example was updated, tested and seems to be working.

caiyue1993 commented 2 years ago

Hi @leoz, thanks for the PR and looks nice! I'll look into it and consider the compatible plan. Appreciate for the hard work!

leoz commented 2 years ago

@caiyue1993 , no worries. Thank you for the awesome job creating this package!

brightspread commented 2 years ago

There is a problem with archiving Realm 10.7.7 version on Xcode 13. Please consider to merge this commit.

leoz commented 2 years ago

Hey @caiyue1993 , could you please share the plan of integrating the support for the recent realm? Is there anything I could help with?

jshrager commented 2 years ago

Any updates on this? I have been unable to archive my app for the past few months. I couldn’t archive until I upgraded Realm then when I did that I got an IceCream error!

kleber-maia commented 2 years ago

I'd suggest everyone to just reference this PR's commit directly until it gets merged into master.

halzo826 commented 2 years ago

I'm using machine language translation, so sorry for the weird English! ListBase has been removed in the latest version of Realm, but if you just want to get the Count or contents of a List, you can use RLMSwiftCollectionBase.

Specifically, you can use the following CKRecordConvertible.swift /// We may get List here /// The item cannot be casted as List /// It can be casted at a low-level type ListBase guard let list = item as? RLMSwiftCollectionBase, list._rlmCollection.count > 0 else { break } var referenceArray = [CKRecord.Reference]() let wrappedArray = list._rlmCollection

leoz commented 2 years ago

I'm using machine language translation, so sorry for the weird English! ListBase has been removed in the latest version of Realm, but if you just want to get the Count or contents of a List, you can use RLMSwiftCollectionBase.

Specifically, you can use the following CKRecordConvertible.swift /// We may get List here /// The item cannot be casted as List /// It can be casted at a low-level type ListBase guard let list = item as? RLMSwiftCollectionBase, list._rlmCollection.count > 0 else { break } var referenceArray = CKRecord.Reference let wrappedArray = list._rlmCollection

@halzo826, good point! This change is already included in this CR. Thank you very much!

jshrager commented 2 years ago

I'd suggest everyone to just reference this PR's commit directly until it gets merged into master.

Can you guide me on how to do this? I’m currently integrating IceCream via Cocoapods - presumably I should remove this in my Podfile then download this pull request and just copy the files in manually?

kleber-maia commented 2 years ago

I'd suggest everyone to just reference this PR's commit directly until it gets merged into master.

Can you guide me on how to do this? I’m currently integrating IceCream via Cocoapods - presumably I should remove this in my Podfile then download this pull request and just copy the files in manually?

I don't think you can achieve that with Cocoapods. The manual way you described should work. In my case, since I'm using Swift Packages, it's pretty seamless: just provide the commit's SHA in the dialog box.

image
jshrager commented 2 years ago

Oh perfect, will remove via Cocoapods and try and add back in as a package. I’m sure I can get that working.

just to confirm, that will then build ok using the latest realm?

kleber-maia commented 2 years ago

Oh perfect, will remove via Cocoapods and try and add back in as a package. I’m sure I can get that working.

just to confirm, that will then build ok using the latest realm?

If you add IceCream via Swift Packages, you may as well remove Realm from Cocoapods / elsewhere. Since Realm is a "sub-dependency", Xcode will install Realm 10.21.1 and keep it updated according to IceCream package definitions. At least, this is what I did, since I don't want to use a newer version of Realm not tested with IceCream.

leoz commented 2 years ago

Updated with latest realm-swift v10.22.0.

leoz commented 2 years ago

Updated to RealmSwift v10.23.0. Example app works fine.

leoz commented 2 years ago

Updated to RealmSwift v10.25.0. @caiyue1993 , FYI.

hdcola commented 2 years ago

This PR solves the dependency problem, so why is there no merge yet?

hdcola commented 2 years ago
leoz commented 2 years ago

@hdcola , updated to RealmSwift 10.28.1. Check it out.

leoz commented 2 years ago

Hey @caiyue1993 , any chance we could merge it in?

hdcola commented 2 years ago

Hey @caiyue1993 , any chance we could merge it in?

He told me , maybe we have a branch use 10.2x RealmSwift.

leoz commented 2 years ago

@hdcola , this is a great idea! We could make e.g. "master -> 4.x.x" (or whichever is stable) and create a new permanent branch e.g. "next -> 10.2x.x" and bump the pod version major there so both could be released independently. LMK, if you want me to move this to the branch.

hdcola commented 2 years ago

@hdcola , this is a great idea! We could make e.g. "master -> 4.x.x" (or whichever is stable) and create a new permanent branch e.g. "next -> 10.2x.x" and bump the pod version major there so both could be released independently. LMK, if you want me to move this to the branch.

yes, this is a good idea

leoz commented 2 years ago

@caiyue1993 , could you please (if your are ok with the proposal above) create a new branch "next" off your "master" so I could update the pull request please?

alfredcc commented 2 years ago

@leoz Thank you. Update RealmRswift also solves this issue https://github.com/RxSwiftCommunity/RxRealm/issues/179

alfredcc commented 2 years ago

Hi there, About the compatible We have updated realm from 10.7.7 to 10.28.2. iCloud Sync seems ok. And what we have learned is remember to keep using old style @objc dynamic and func primaryKey() -> String?.

leoz commented 2 years ago

@alfredcc , hey! I have updated an example app in this repo as well as my own project to use @Persisted and @Persisted(primaryKey: true) and did not notice any issue. What specific problem do you see?

alfredcc commented 2 years ago

@leoz, If we use @Persisted first, it's ok. The issue is if we upgrade from @objc dynamic to @Persisted Or downgrade from @Persisted to @objc dynamic, data will broken

leoz commented 2 years ago

@alfredcc , I see. This makes sense. Thank you for heads up! :-)

leoz commented 1 year ago

Updated to RealmSwift 10.28.3

GoodLuckBobe commented 1 year ago

I want to make a copy of the inherited object as a temporary object. I want to use handyjson. I need to implement the initialization method of the class, but this causes icecream to not work when synchronizing table data for example: class Dog: Object,HandyJSON { @objc dynamic var id = NSUUID().uuidString @objc dynamic var name = "" @objc dynamic var age = 0 @objc dynamic var isDeleted = false

static let AVATAR_KEY = "avatar"
@objc dynamic var avatar: CreamAsset?

// Relationships usage in Realm: https://realm.io/docs/swift/latest/#relationships
@objc dynamic var owner: Person? // to-one relationships must be optional

override class func primaryKey() -> String? {
    return "id"
}
required override init() {
    super.init()
}

required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

}

GoodLuckBobe commented 1 year ago

@leoz can you help me,I don't know why

leoz commented 1 year ago

@GoodLuckBobe , will check in ~3 weeks. Traveling at the moment...

JamesJunsungKim commented 1 year ago

I was just curious about when this will be merged. any plan?

leoz commented 1 year ago

@caiyue1993 , could you create a new brunch in your repo named e.g. "next" or "realm-latest" so I could land this please finally?

caiyue1993 commented 1 year ago

Hey @leoz , realm-latest branch has just been created.

Pre-congrats for the hard work!

leoz commented 1 year ago

@caiyue1993 , Great! Thank you! Just changed the base branch to "realm-latest".

leoz commented 1 year ago

@caiyue1993 , anything you would like me to change to get this merged into the branch?

kushsolitary commented 1 year ago

@leoz thank you for this PR!

kleber-maia commented 1 year ago

After Apple's SwiftData announcement, is anyone else considering migrating away from Realm + IceCream? 😅 Their statements and the WWDC videos look damn promising. 🚀

Create models with Swift Model your data using regular Swift types with @Model, with no additional files or tools to manage. SwiftData can automatically infer many relationships and you can use clear declarations like @Attribute(.unique) to describe constraints. Like SwiftUI, the source of truth is in your code.

Automatic persistence SwiftData builds a custom schema using your models and maps their fields efficiently to the underlying storage. Objects managed by SwiftData are fetched from the database when needed and automatically saved at the right moment, with no additional work on your part. You can also take full control using the ModelContext API.

CloudKit syncing Your data can be stored in files using DocumentGroup and synced via iCloud Drive, or you can use CloudKit to sync data between devices.

dbmrq commented 1 year ago

Yes! 😍😍

Update us if you give it a try!

faizy-ahmed commented 7 months ago

I'm using machine language translation, so sorry for the weird English! ListBase has been removed in the latest version of Realm, but if you just want to get the Count or contents of a List, you can use RLMSwiftCollectionBase.

Specifically, you can use the following CKRecordConvertible.swift /// We may get List here /// The item cannot be casted as List /// It can be casted at a low-level type ListBase guard let list = item as? RLMSwiftCollectionBase, list._rlmCollection.count > 0 else { break } var referenceArray = CKRecord.Reference let wrappedArray = list._rlmCollection

It worked for me, Thanks! @halzo826