We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5415

Summary: fatal error: 'Cocoa/Cocoa.h' file not found in iOS build
Product: SDL Reporter: Steve Robinson <ssrobins>
Component: buildAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: sezeroz
Version: 2.0.15   
Hardware: iPhone/iPod touch   
OS: macOS 10.15   

Description Steve Robinson 2020-12-25 07:12:11 UTC
When trying to build 2.0.14 from source on iOS using CMake, I get this error:
SDL_sysurl.m:24:9: fatal error: 'Cocoa/Cocoa.h' file not found
#import <Cocoa/Cocoa.h>

Since this is using Cocoa, I don't think it's meant for iOS. So I fixed it by changing this in CMakeLists.txt:
file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/macosx/*.m)
set(SOURCE_FILES ${SOURCE_FILES} ${MISC_SOURCES})
set(HAVE_SDL_MISC TRUE)

To:
if(NOT IOS)
  file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/macosx/*.m)
  set(SOURCE_FILES ${SOURCE_FILES} ${MISC_SOURCES})
  set(HAVE_SDL_MISC TRUE)
endif()

Environment:
CMake: 3.19.2
Xcode: 12.3
macOS: 11.1
Comment 1 Ozkan Sezer 2020-12-27 03:50:31 UTC
I _think_ the fix should be like in the following patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1670,7 +1670,11 @@
     message_error("SDL_FILE must be enabled to build on MacOS X")
   endif()
 
-  file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/macosx/*.m)
+  if(IOS OR TVOS)
+    file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/ios/*.m)
+  else()
+    file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/macosx/*.m)
+  endif()
   set(SOURCE_FILES ${SOURCE_FILES} ${MISC_SOURCES})
   set(HAVE_SDL_MISC TRUE)
Comment 2 Steve Robinson 2020-12-27 06:31:06 UTC
Yup, that's a way better fix. Verified that it worked. Thanks!
Comment 3 Ozkan Sezer 2020-12-27 11:02:49 UTC
(In reply to Steve Robinson from comment #2)
> Yup, that's a way better fix. Verified that it worked. Thanks!

Patch applied as https://hg.libsdl.org/SDL/rev/cf578732c7e7
Closing as fixed.