Closed bipinvaylu closed 9 years ago
Generally the automatically generated Objective-C compatibility header shouldn't cause issues with integrating with CocoaPods. Which version of CocoaPods did used?
As a workaround, you could just disable for now the generation by setting the build setting SWIFT_INSTALL_OBJC_HEADER
to NO
, because we discourage using RealmSwift in mixed setups, where Objective-C is used alongside to Swift to access the model. But I guess from the dependencies you show in your project navigator that this is more a pure Swift project, so the workaround could be applicable.
thanks @mrackwitz, i am using CocoaPods 0.38.2 and not following you where do i need to set this. SWIFT_INSTALL_OBJC_HEADER to NO, If possible can you please guide me.
Sure, go into the build settings of your app target, copy the name of the build setting into the search field and then you can just select No
as value from the combo box.
Thanks, I did that changes, clean and rebuild but still same issue, It's still generating same ProjectName-Swift.h file. I am having ProjectName-Bridging-Header.h file. I am using some swift classes in Obj-C code.
So if your model classes should be among those classes used in Objective-C or the used classes depend on them, then you can't really use Realm Swift in this setup and would need to inherit from RLMObject
instead.
Thanks @mrackwitz
Now getting another issue:
2015-10-21 14:55:34.914 ottodj[59456:1643376] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swift._SwiftDeferredNSArray objectClassName]: unrecognized selector sent to instance 0x608000037720'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff9268c03c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8879e76e objc_exception_throw + 43
2 CoreFoundation 0x00007fff9268f0ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff925d4e24 ___forwarding___ + 1028
4 CoreFoundation 0x00007fff925d4998 _CF_forwarding_prep_0 + 120
5 Realm 0x00000001003c4952 -[RLMProperty initSwiftPropertyWithName:indexed:property:instance:] + 514
6 Realm 0x000000010038c266 +[RLMObjectSchema propertiesForClass:isSwift:] + 1174
7 Realm 0x000000010038a5e2 +[RLMObjectSchema schemaForObjectClass:] + 818
8 Realm 0x000000010049484f +[RLMSchema registerClasses:count:] + 1871
9 Realm 0x0000000100496625 _ZZ25+[RLMSchema sharedSchema]ENK3$_0clEv + 501
10 Realm 0x0000000100496425 _ZNSt3__117__call_once_proxyINS_5tupleIJZ25+[RLMSchema sharedSchema]E3$_0EEEEEvPv + 85
11 libc++.1.dylib 0x00007fff8b177332 _ZNSt3__111__call_onceERVmPvPFvS2_E + 117
12 Realm 0x0000000100494edd +[RLMSchema sharedSchema] + 413
13 Realm 0x000000010038680b +[RLMObjectBase sharedSchema] + 43
14 Realm 0x0000000100383f34 -[RLMObjectBase init] + 244
15 Realm 0x0000000100381bdb -[RLMObject init] + 59
16 ottodj 0x0000000100029dd7 _TFC6ottodj19ServerTrackMetadatacfMS0_FT_S0_ + 215
17 ottodj 0x00000001000273f1 _TFC6ottodj19ServerTrackMetadatacfMS0_FT7cueTypeOS_4Type7cueTimeSd9createdBySi10apiVersionSi6hotcueSi_S0_ + 97
18 ottodj 0x00000001000274fa _TFC6ottodj19ServerTrackMetadataCfMS0_FT7cueTypeOS_4Type7cueTimeSd9createdBySi10apiVersionSi6hotcueSi_S0_ + 122
19 ottodj 0x000000010000e045 _TFC6ottodj20SignInViewController13viewDidAppearfS0_FT_T_ + 6549
20 ottodj 0x000000010000e1b2 _TToFC6ottodj20SignInViewController13viewDidAppearfS0_FT_T_ + 34
21 AppKit 0x00007fff90620f8e -[NSViewController _sendViewDidAppear] + 160
22 AppKit 0x00007fff90576cae -[NSView(NSInternal) _windowDidOrderOnScreen] + 67
23 AppKit 0x00007fff90576d90 -[NSView(NSInternal) _windowDidOrderOnScreen] + 293
24 AppKit 0x00007fff90564c26 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 3915
25 AppKit 0x00007fff90563787 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 829
26 AppKit 0x00007fff905633db -[NSWindow orderWindow:relativeTo:] + 159
27 AppKit 0x00007fff9055a9a2 -[NSWindow makeKeyAndOrderFront:] + 47
28 AppKit 0x00007fff9063de27 __33-[NSWindowController showWindow:]_block_invoke + 367
29 QuickLookUI 0x00007fff88bce5f6 -[QLSeamlessDocumentOpener showWindow:contentFrame:withBlock:] + 105
30 AppKit 0x00007fff905f3d60 -[NSWindowController showWindow:] + 434
31 AppKit 0x00007fff9042ff54 NSApplicationMain + 1080
32 ottodj 0x00000001000617d7 main + 87
33 libdyld.dylib 0x00007fff9220e5c9 start + 1
34 ??? 0x0000000000000003 0x0 + 3
Model code is like:
public class ServerTrackMetadata: RLMObject {
dynamic var id = 0
dynamic var cueType = ""
dynamic var cueTime = 0.0
dynamic var createdBy = 0
dynamic var hotcue = -1
dynamic var apiVersion = 0
dynamic var createdAt = 0
dynamic var updatedAt = 0
public convenience init(cueType: Type, cueTime: Double, createdBy: Int, apiVersion: Int, hotcue:Int) {
self.init() //Getting error at this line
self.cueType = cueType.rawValue
self.cueTime = cueTime
self.createdBy = createdBy
self.apiVersion = apiVersion
self.hotcue = hotcue
}
public convenience init(metadata: JSON) {
self.init() //Getting error at this line
if let id = metadata["id"].int,
let cueType = metadata["cueType"].string,
let cueTime = metadata["cueTime"].double,
let createdBy = metadata["createdBy"].int,
let apiVersion = metadata["apiVersion"].int,
let createdAt = metadata["createdAt"].int,
let updatedAt = metadata["updatedAt"].int {
self.id = id
self.cueType = cueType
self.cueTime = cueTime
self.createdBy = createdBy
self.apiVersion = apiVersion
self.createdAt = createdAt
self.updatedAt = updatedAt
}
}
override public static func primaryKey() -> String? {
return "id"
}
Just initialising model
let trackMetadata = ServerTrackMetadata(cueType: Type.Start, cueTime: 1234, createdBy: 1234, apiVersion: 1, hotcue: 123)
As this error isn't related to your previous issue, I'd prefer if you'd open a new issue with that error. This makes it easier in the future for other users to find help by existing issues.
Nevertheless I don't think that the specific model and the crash are directly related. From the stack trace, I'm pretty sure It's caused by initializing your first model instance, which triggers the lazy-loading of the schema.
It seems like you defined a property as Swift array e.g. linkedObjects = [Foo]()
, which doesn't work for several reasons. Instead you've to define your to-many relationships with the provided List
-type e.g. linkedObjects = List<Foo>
.
Is my assumption correct and does that help?
Anyway please open up a new issue, and copy-paste your question over there, I'll take care of moving my comment over as well and provide you further guidance as needed.
I am integrating RealmSwift framework to my OS X project.
I changed Track class to extend Object instead of NSObject, I am getting this error in ProjectName-Swift.h
I am using CocoaPods for dependency management. I did googling for this issue but didn't get much.
Added RealmSwift dependency like this
I am using: XCode 7, Swift 2.0, CocoaPods