|
Hey y'all - not sure if this is the right place to post, but I opened xcode today to see an error mesage: "Could not build Objective-C module 'Cocoa'" I'm a newbie (day 2 of 100 days) so am really not sure how to fix this -- lmk if you have any ideas! TIA |
|
|
|
This is happening to me too, but in a Playground. I don't see a Build Settings for a Playground - is there one? If so, where is it? |
SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today! Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
|
|
Ah yes @buxley - this is happening to me in when I use xcode's playground! In the inspector (click the icon to the right of the '+' button in the top right corner to open the inspector), under playground settings, I changed the platform to 'iOS'; then I changed the import statement to "import UIKit" (or import SwiftUI), and now I don't have any errors. But if I change the playground settings back to 'macOS', the issue with 'import Cocoa' still persists. Tried importing other libraries too, but same error each time. Not sure how to fix it, but I'm trying to learn to build an iOS app (rather than a mac app; and in any case, I'm just practicing with playgrounds and haven't actually started a project), so maybe I can just ignore the issue for now lol |
|
got same error. Could not build Objective-C module 'Cocoa' anyone know how to fix this? TIA |
|
+1 to this. I have a MacBook on Ventura still and it does not have the issue, but my MacBook on Sonoma does. @lil-pizza 's workaround got rid of the error for me. |
|
If you can import Foundation and AppKit without an error, that combination is equivalent to import Cocoa. |
|
|
|
I've been having the same problem ever since I had upgraded Xcode to version 15.0.1 (I didn't have this problem with Xcode 15.0) and tried every solution/workaround I could find on the Internet (including clean re-installation of Xcode) but to no avail. After seeing the reports from others for the same problem here (led by a DuckDuckGo search), I was convinced that this was a bug with either Xcode 15.0.1 or macOS 14.0 or both (a compatibility issue?). So I gave up on trying and waited for Apple to release a fix in some way. Today, after learning that Apple released macOS Sonoma 14.1, I gave it another try by upgrading macOS from 14.0 to 14.1, deleting my original Playground as well as all the content of the ~/Library/Developer/Xcode/DerivedData directory. After all that preparation, I started Xcode and created a new, empty Playground for macOS and voila, problem solved! No more "Could not build Objective-C module 'Cocoa'" error in the Playground! I hope this helps and happy hacking! |
|
14.1 fixed it for me as well. I didn't even have to make a new playground. Cocoa imported right out of the gate. |
|
|
|
|
|
I have 14.3 and it is still doing it to me I'm just frustrated... anyone have any idea how I should fix this? |
SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.