Skip to content

Commit 2281871

Browse files
authored
Restore DDLog usages in ShareExtensionCore (#24458)
* Revert CocoaLumberjackSwift removal in ShareExtensionCore - Build fails The build fails with Undefined symbols for architecture arm64: "_OBJC_CLASS_$_DDLog", referenced from: in SharedCoreDataStack.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) That's obviously why CocoaLumberjackSwift was removed, but we'll fix it in the next commit. * Add CocoaLumberjack (Objective-C) to ShareExtensionCore - Fixes build
1 parent fc406d6 commit 2281871

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

Modules/Package.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ let package = Package(
9595
"BuildSettingsKit",
9696
"SFHFKeychainUtils",
9797
"WordPressShared",
98+
// Even though the extension is all in Swift, we need to include the Objective-C
99+
// version of CocoaLumberjack to avoid linking issues with other dependencies that
100+
// use it.
101+
//
102+
// Example:
103+
//
104+
// Undefined symbols for architecture arm64:
105+
// "_OBJC_CLASS_$_DDLog", referenced from:
106+
// in SharedCoreDataStack.o
107+
.product(name: "CocoaLumberjack", package: "CocoaLumberjack"),
108+
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
98109
.product(name: "WordPressKit", package: "WordPressKit-iOS"),
99110
],
100111
resources: [.process("Resources/Extensions.xcdatamodeld")]

Modules/Sources/ShareExtensionCore/Data/SharedCoreDataStack.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22
import CoreData
3-
// import CocoaLumberjackSwift
3+
import CocoaLumberjackSwift
44
import BuildSettingsKit
55
import WordPressKit
66

@@ -39,7 +39,7 @@ public final class SharedCoreDataStack {
3939
let container = SharedPersistentContainer(name: "SharedCoreDataStack", managedObjectModel: SharedCoreDataStack.model)
4040
container.loadPersistentStores { (storeDescription, error) in
4141
if let error = error as NSError? {
42-
// DDLogError("Error loading persistent stores: \(error), \(error.userInfo)")
42+
DDLogError("Error loading persistent stores: \(error), \(error.userInfo)")
4343
}
4444
}
4545
return container
@@ -71,7 +71,7 @@ public final class SharedCoreDataStack {
7171
do {
7272
try managedContext.save()
7373
} catch let error as NSError {
74-
// DDLogError("Error saving context: \(error), \(error.userInfo)")
74+
DDLogError("Error saving context: \(error), \(error.userInfo)")
7575
}
7676
}
7777
}
@@ -120,7 +120,7 @@ extension SharedCoreDataStack {
120120
do {
121121
postUploadOp = try managedContext.existingObject(with: postUploadOpObjectID) as? PostUploadOperation
122122
} catch {
123-
// DDLogError("Error loading PostUploadOperation Object with ID: \(postUploadOpObjectID)")
123+
DDLogError("Error loading PostUploadOperation Object with ID: \(postUploadOpObjectID)")
124124
}
125125
return postUploadOp
126126
}
@@ -151,7 +151,7 @@ extension SharedCoreDataStack {
151151
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "MediaUploadOperation")
152152
request.predicate = NSPredicate(format: "(groupID == %@)", groupID)
153153
guard let results = (try? managedContext.fetch(request)) as? [MediaUploadOperation] else {
154-
// DDLogError("Failed to fetch MediaUploadOperation for group ID: \(groupID)")
154+
DDLogError("Failed to fetch MediaUploadOperation for group ID: \(groupID)")
155155
return nil
156156
}
157157
return results
@@ -195,7 +195,7 @@ extension SharedCoreDataStack {
195195
do {
196196
uploadOps = try managedContext.fetch(request) as! [MediaUploadOperation]
197197
} catch {
198-
// DDLogError("Failed to fetch MediaUploadOperation: \(error)")
198+
DDLogError("Failed to fetch MediaUploadOperation: \(error)")
199199
}
200200

201201
return uploadOps
@@ -217,7 +217,7 @@ extension SharedCoreDataStack {
217217
do {
218218
uploadOp = try managedContext.existingObject(with: uploadOpObjectID) as? UploadOperation
219219
} catch {
220-
// DDLogError("Error setting \(status.stringValue) status for UploadOperation Object with ID: \(uploadOpObjectID) — could not fetch object.")
220+
DDLogError("Error setting \(status.stringValue) status for UploadOperation Object with ID: \(uploadOpObjectID) — could not fetch object.")
221221
return
222222
}
223223
uploadOp?.currentStatus = status
@@ -260,7 +260,7 @@ extension SharedCoreDataStack {
260260
///
261261
public func updateMediaOperation(for fileName: String, with sessionID: String, remoteMediaID: Int64?, remoteURL: String?, width: Int32?, height: Int32?) {
262262
guard let mediaUploadOp = fetchMediaUploadOp(for: fileName, with: sessionID) else {
263-
// DDLogError("Error loading UploadOperation Object with File Name: \(fileName)")
263+
DDLogError("Error loading UploadOperation Object with File Name: \(fileName)")
264264
return
265265
}
266266

@@ -305,7 +305,7 @@ extension SharedCoreDataStack {
305305
///
306306
public func updatePostOperation(with status: UploadOperation.UploadStatus, remotePostID: Int64, forPostUploadOpWithObjectID postUploadOpObjectID: NSManagedObjectID) {
307307
guard let postUploadOp = (try? managedContext.existingObject(with: postUploadOpObjectID)) as? PostUploadOperation else {
308-
// DDLogError("Error loading PostUploadOperation Object with ID: \(postUploadOpObjectID)")
308+
DDLogError("Error loading PostUploadOperation Object with ID: \(postUploadOpObjectID)")
309309
return
310310
}
311311
postUploadOp.currentStatus = status
@@ -324,7 +324,7 @@ extension SharedCoreDataStack {
324324
do {
325325
uploadOp = try managedContext.existingObject(with: uploadOpObjectID) as? UploadOperation
326326
} catch {
327-
// DDLogError("Error loading UploadOperation Object with ID: \(uploadOpObjectID)")
327+
DDLogError("Error loading UploadOperation Object with ID: \(uploadOpObjectID)")
328328
return
329329
}
330330
uploadOp?.backgroundSessionTaskID = taskID.int32Value

Modules/Sources/ShareExtensionCore/ShareMediaFileManager.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22
import BuildSettingsKit
3-
// import CocoaLumberjackSwift
3+
import CocoaLumberjackSwift
44

55
/// Encapsulates media file operations relative to the shared container's Media directory.
66
///
@@ -26,7 +26,7 @@ public final class ShareMediaFileManager: Sendable {
2626
do {
2727
try fileManager.createDirectory(at: mediaDirectoryURL, withIntermediateDirectories: true, attributes: nil)
2828
} catch {
29-
// DDLogError("Error creating local media directory: \(error)")
29+
DDLogError("Error creating local media directory: \(error)")
3030
}
3131
}
3232
return mediaDirectoryURL
@@ -57,7 +57,7 @@ public final class ShareMediaFileManager: Sendable {
5757
includingPropertiesForKeys: nil,
5858
options: .skipsHiddenFiles)
5959
} catch {
60-
// DDLogError("Error retrieving contents of shared container media directory: \(error)")
60+
DDLogError("Error retrieving contents of shared container media directory: \(error)")
6161
return
6262
}
6363

@@ -68,12 +68,12 @@ public final class ShareMediaFileManager: Sendable {
6868
try fileManager.removeItem(at: url)
6969
removedCount += 1
7070
} catch {
71-
// DDLogError("Error while removing Media at path: \(error.localizedDescription) - \(url.path)")
71+
DDLogError("Error while removing Media at path: \(error.localizedDescription) - \(url.path)")
7272
}
7373
}
7474
}
7575
if removedCount > 0 {
76-
// DDLogInfo("Shared container media: removed \(removedCount) file(s) during cleanup.")
76+
DDLogInfo("Shared container media: removed \(removedCount) file(s) during cleanup.")
7777
}
7878
}
7979

@@ -91,9 +91,9 @@ public final class ShareMediaFileManager: Sendable {
9191
if fileManager.fileExists(atPath: fullPath.path) {
9292
do {
9393
try fileManager.removeItem(at: fullPath)
94-
// DDLogInfo("Shared container media: removed \(fullPath.path) during cleanup.")
94+
DDLogInfo("Shared container media: removed \(fullPath.path) during cleanup.")
9595
} catch {
96-
// DDLogError("Error while removing Media file at path: \(error.localizedDescription) - \(fullPath.path)")
96+
DDLogError("Error while removing Media file at path: \(error.localizedDescription) - \(fullPath.path)")
9797
}
9898
}
9999
}

0 commit comments

Comments
 (0)