Verwenden von RealmSwift in einem Framework: die meisten Symbole gefunden, aber nicht alleIOS

Programmierung für iOS
Anonymous
 Verwenden von RealmSwift in einem Framework: die meisten Symbole gefunden, aber nicht alle

Post by Anonymous »

Ich erstelle ein iOS -Framework (sowohl ein .framework als auch ein .xcframework), das einen Teil meines Quellcodes enthält, der RealmSwift verwendet. can, for example, use the framework to open the db, add items, fetch items etc. etc. However if I attempt to reference a Results object then I get:

dyld[11749]: Symbol not found:
_$s10RealmSwift7ResultsVyxGSlAASl5countSivgTW
< /blockquote>
Warum könnte dies sein?public class ObjectA: Object, Codable {
@objc dynamic var category: String = ""

override public static func primaryKey() -> String? {
return "category"
}
}
public func addA(key:String) {
do {
let objectA = ObjectA()
objectA.category = key

let realm = try Realm(configuration: configuration!)
try? realm.write {
realm.add(objectA, update: Realm.UpdatePolicy.all)
}
} catch let error as NSError {
NSLog(TAG + "ERROR calling add() \(error.code) \(error.description)")
}
}
public func getAllAs() -> Results {
let realm = try! Realm(configuration: configuration!)
let items = realm.objects(ObjectA.self)
return items
}
< /code>
und Code, die es aufrufen: < /p>
RealmDatabase.instance().addA(key: "something") //ok
let found = RealmDatabase.instance().findObjectA(key: "something") //ok
let allA = RealmDatabase.instance().getAllAs() // ok
let c = allA.count // not ok
< /code>
Wenn die obigen 4 Zeilen im Framework enthalten sind, führt dies zum Fehler. Wenn die letzte Zeile weggelassen wird, wird der Code erfolgreich ausgeführt.target 'TheFramework' do
use_frameworks!
pod 'Realm', '10.49.1'
pod 'RealmSwift', '10.49.1'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
< /code>
Die POD -Datei für die App mit dem Framework lautet: < /p>
target 'ReferenceApp' do
project 'ReferenceApp.xcodeproj'
use_frameworks!
pod 'Realm', '10.49.1'
pod 'RealmSwift', '10.49.1'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
end
end
end
< /code>
Im Framework Xcode -Projekt wird der Abschnitt Frameworks & Bibliotheken für die Pods.framework so eingestellt, dass sie nicht einbettet. Build Library for Distribution ist auf Ja eingestellt. Warum führt nur ein kleiner Teil der API zu einem Symbol, der keinen Fehler gefunden hat?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post