下記のように修正することでエクステンション側でデータを取得できました。
アプリ側
// AppDelegate.swift
var fileNum = 0
var config = Realm.Configuration.defaultConfiguration
var realmFileURL = config.fileURL!.deletingLastPathComponent().appendingPathComponent("u0.realm")
let fileMng = FileManager.default
if !fileMng.fileExists(atPath: realmFileURL.path) {
realmFileURL = config.fileURL!.deletingLastPathComponent().appendingPathComponent("u1.realm")
fileNum = 1
}
let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.sample.myapp")!
if fileNum == 0 {
config.fileURL = url.appendingPathComponent("u0.realm")
} else {
config.fileURL = url.appendingPathComponent("u1.realm")
}
Realm.Configuration.defaultConfiguration = config
エクステンション側
// TodayViewController.swift
var config = Realm.Configuration.defaultConfiguration
let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.sample.myapp")!
var realmFileURL = url.appendingPathComponent("u0.realm")
let fileMng = FileManager.default
if !fileMng.fileExists(atPath: realmFileURL.path) {
realmFileURL = url.appendingPathComponent("u1.realm")
}
config.fileURL = realmFileURL
Realm.Configuration.defaultConfiguration = config