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 - fatal error: 'Cocoa/Cocoa.h' file not found in iOS build
Summary: fatal error: 'Cocoa/Cocoa.h' file not found in iOS build
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: 2.0.15
Hardware: iPhone/iPod touch macOS 10.15
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-25 07:12 UTC by Steve Robinson
Modified: 2020-12-27 11:02 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.