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

Migration to XCode7 causes crash #2676

Closed
vladoh-inova opened this issue Oct 14, 2015 · 3 comments
Closed

Migration to XCode7 causes crash #2676

vladoh-inova opened this issue Oct 14, 2015 · 3 comments
Labels

Comments

@vladoh-inova
Copy link

We used realm version 0.90.5 in XCode 6.4 and the models were made in swift. Now project was migrated to XCode7 (swift 2.0).

Model:

class SharingSettingsModel: RLMObject {
    dynamic var name: String = ""
    dynamic var isOn: Bool = false
    dynamic var timeStamp: Double = 0.0
    dynamic var account: SharingAccountModel?
}

// Sharing Account model (e.g. name = "HEALTH", settings = <SharingSettingsModel, ...>)
class SharingAccountModel: RLMObject {
    dynamic var name: String = ""
    dynamic var isConnected: Bool = false
    dynamic var settings = RLMArray(objectClassName: SharingSettingsModel.className())

    override class func primaryKey() -> String {
        return "name"
    }
}

When using realm version 0.90.5 application crashed when using default realm:

let realm = RLMRealm.defaultRealm()
#0  0x000000010d74ee1f in tightdb::Descriptor::insert_column_link(unsigned long, tightdb::DataType, tightdb::StringData, tightdb::Table&, tightdb::LinkType) ()
#1  0x000000010d73787f in tightdb::Table::add_column_link(tightdb::DataType, tightdb::StringData, tightdb::Table&, tightdb::LinkType) ()
#2  0x000000010d5f1a8b in RLMCreateColumn(RLMRealm*, tightdb::Table&, RLMProperty*) [inlined] at /tmp/rel/tightdb_objc/Realm/RLMObjectStore.mm:97
#3  0x000000010d5f19da in RLMRealmCreateTables(RLMRealm*, RLMSchema*, bool) [inlined] at /tmp/rel/tightdb_objc/Realm/RLMObjectStore.mm:200
#4  0x000000010d5f12de in RLMUpdateRealmToSchemaVersion at /tmp/rel/tightdb_objc/Realm/RLMObjectStore.mm:252
#5  0x000000010d614535 in +[RLMRealm realmWithPath:key:readOnly:inMemory:dynamic:schema:error:] at /tmp/rel/tightdb_objc/Realm/RLMRealm.mm:512
#6  0x000000010d613e8e in +[RLMRealm realmWithPath:readOnly:error:] at /tmp/rel/tightdb_objc/Realm/RLMRealm.mm:408
#7  0x000000010d613dfa in +[RLMRealm defaultRealm] at /tmp/rel/tightdb_objc/Realm/RLMRealm.mm:396
#8  0x000000010d5dcec7 in ViewController.buttonWritePressed(AnyObject) -> () at /Users/vladoh/Desktop/RealmTest/RealmTest/ViewController.swift:57
#9  0x000000010d5dd166 in @objc ViewController.buttonWritePressed(AnyObject) -> () ()
#10 0x000000010e75b1fa in -[UIApplication sendAction:to:from:forEvent:] ()
#11 0x000000010e8bf504 in -[UIControl sendAction:to:forEvent:] ()
#12 0x000000010e8bf7d0 in -[UIControl _sendActionsForEvents:withEvent:] ()
#13 0x000000010e8be906 in -[UIControl touchesEnded:withEvent:] ()
#14 0x000000010e7c5aa3 in -[UIWindow _sendTouchesForEvent:] ()
#15 0x000000010e7c6691 in -[UIWindow sendEvent:] ()
#16 0x000000010e778752 in -[UIApplication sendEvent:] ()
#17 0x000000010e753fcc in _UIApplicationHandleEventQueue ()
#18 0x000000010de6b0a1 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#19 0x000000010de60fcc in __CFRunLoopDoSources0 ()
#20 0x000000010de60483 in __CFRunLoopRun ()
#21 0x000000010de5fe98 in CFRunLoopRunSpecific ()
#22 0x0000000111fa3ad2 in GSEventRunModal ()
#23 0x000000010e759676 in UIApplicationMain ()
#24 0x000000010d5de27d in main at /Users/vladoh/Desktop/RealmTest/RealmTest/AppDelegate.swift:12
#25 0x000000011072092d in start ()

Then realm was updated to latest version 0.95.3. Everything works fine, except when using existing files from version 0.90.5 with the same model it crashes when trying to create Realm.

Back trace

#0  0x0000000198657270 in __pthread_kill ()
#1  0x00000001986f5160 in pthread_kill ()
#2  0x00000001985ceaa0 in abort ()
#3  0x00000001013ebd80 in uncaught_exception_handler ()
#4  0x0000000100d15d2c in RLMInstallUncaughtExceptionHandler::$_0::operator()(NSException*) const [inlined] at /Users/realm/workspace/objc_ios/tightdb_objc/Realm/RLMRealmUtil.mm:75
#5  0x0000000100d15bb4 in RLMInstallUncaughtExceptionHandler::$_0::__invoke(NSException*) at /Users/realm/workspace/objc_ios/tightdb_objc/Realm/RLMRealmUtil.mm:63
#6  0x00000001861c85ec in __handleUncaughtException ()
#7  0x0000000197e943b4 in _objc_terminate() ()
#8  0x000000019767dbb4 in std::__terminate(void (*)()) ()
#9  0x000000019767d478 in __cxa_throw ()
#10 0x0000000197e94204 in objc_exception_throw ()
#11 0x0000000100d1f6d8 in RLMSetErrorOrThrow(NSError*, NSError* __autoreleasing*) at /Users/realm/workspace/objc_ios/tightdb_objc/Realm/RLMUtil.mm:276
#12 0x0000000100d105ac in +[RLMRealm realmWithConfiguration:error:] at /Users/realm/workspace/objc_ios/tightdb_objc/Realm/RLMRealm.mm:433
#13 0x0000000100d0fa7c in +[RLMRealm realmWithPath:key:readOnly:inMemory:dynamic:schema:error:] at /Users/realm/workspace/objc_ios/tightdb_objc/Realm/RLMRealm.mm:352
#14 0x0000000100d0f6e0 in +[RLMRealm realmWithPath:] at /Users/realm/workspace/objc_ios/tightdb_objc/Realm/RLMRealm.mm:307
#15 0x0000000100c102ac in @nonobjc RLMRealm.__allocating_init(path : String) -> RLMRealm ()
#16 0x0000000100c0bb7c in SharingSettings.realm.getter at /Users/vladoh/Documents/micoach_ios/code/miCoach/miCoach/BusinessLogic/Sharing/SharingSettings.swift:29
#17 0x0000000100c0e0dc in SharingSettings.isSharingAccountAlreadyExists(SharingAccount) -> Bool at /Users/vladoh/Documents/micoach_ios/code/miCoach/miCoach/BusinessLogic/Sharing/SharingSettings.swift:165
#18 0x0000000100c0db78 in SharingSettings.createNewSharingAccount(SharingAccount) -> () at /Users/vladoh/Documents/micoach_ios/code/miCoach/miCoach/BusinessLogic/Sharing/SharingSettings.swift:139

There is no console log from Realm. Do you have any tip or advice how to proceed. If you need addition data please don't hesitate.

@jpsim jpsim added the T-Help label Oct 14, 2015
@bdash
Copy link
Contributor

bdash commented Oct 14, 2015

The RLMRealm initializer you're calling, RLMRealm(path:), doesn't provide for returning an error to its caller if something is wrong. It throws an Objective-C exception in such cases. If you update your code to use the throwing initializer (RLMRealm(configuration:)), the error will be returned to your Swift code. That error include more information about what's going wrong. Feel free to share the error here if you need assistance in understanding its cause.

Out of interest, is there a reason you're using the Objective-C API from Swift rather than the Swift API directly?

@jpsim jpsim added the pending label Oct 14, 2015
@vladoh-inova
Copy link
Author

The initialisation was changed to use RLMRealm(configuration:) and crash has gone. It look like I didn't port initialisation changes properly.

We use objective-C api because of legacy code and was quickest way to upgrade it. I embedded swift version and found that some code has to be modified and embedded frameworks are supported for version from 8.0 and on. Our app supports iOS7. Is there a way to use swift realm framework for earlier versions?

@realm-ci realm-ci removed the pending label Oct 15, 2015
@jpsim
Copy link
Contributor

jpsim commented Oct 15, 2015

Is there a way to use swift realm framework for earlier versions?

No, Swift frameworks in general are only support on iOS 8 or later. Closing since you've resolve your problem.

@jpsim jpsim closed this as completed Oct 15, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants