Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] MacCatalyst x86_64 is building with macOS flags and not macabi #172

Open
paulocoutinhox opened this issue Mar 28, 2023 · 6 comments
Open
Assignees
Labels

Comments

@paulocoutinhox
Copy link

paulocoutinhox commented Mar 28, 2023

Hi,

Im trying build for mac catalyst with x86_64 arch, but it "understand" that is for macOS:

cmake -S . -B /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64 -GXcode -DCMAKE_TOOLCHAIN_FILE=/Users/paulo/Developer/workspaces/cpp/xplpc/cmake/ios.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DXPLPC_TARGET=swift -DXPLPC_ADD_CUSTOM_DATA=ON -DXPLPC_DEPENDENCY_TOOL=conan -DXPLPC_TARGET_GROUP=mac-catalyst -DXPLPC_CONAN_FILES=/Users/paulo/Developer/workspaces/cpp/xplpc/build/conan/swift-ios/mac-catalyst/x86_64 -DPLATFORM=MAC_CATALYST -DDEPLOYMENT_TARGET=13.1 -DCMAKE_OSX_DEPLOYMENT_TARGET=13.1 -DSDK_VERSION=11.0 -DARCHS=x86_64 -DXPLPC_ENABLE_INTERFACE=ON -DENABLE_ARC=ON

But the compilation line generated is:

builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name xplpc -O -whole-module-optimization -enforce-exclusivity\=checked @/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/Objects-normal/x86_64/xplpc.SwiftFileList -DXPLPC_SERIALIZER_JSON -DXPLPC_TARGET_SWIFT -DSPDLOG_FMT_EXTERNAL -DSPDLOG_COMPILED_LIB -swift-version 5 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -target x86_64-apple-macos10.15 -enable-bare-slash-regex -Xfrontend -serialize-debugging-options -enable-library-evolution -swift-version 5 -I /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/lib -I /Users/paulo/Developer/workspaces/cpp/xplpc/objc/lib/include -I /Users/paulo/Developer/workspaces/cpp/xplpc/c/lib/include -I /Users/paulo/Developer/workspaces/cpp/xplpc/cxx/lib/include -I /Users/paulo/Developer/workspaces/cpp/xplpc/cxx/custom/include -F /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/lib -c -num-threads 10 -output-file-map /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/Objects-normal/x86_64/xplpc-OutputFileMap.json -use-frontend-parseable-output -save-temps -no-color-diagnostics -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/Objects-normal/x86_64/xplpc.swiftmodule -emit-module-interface-path /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/Objects-normal/x86_64/xplpc.swiftinterface -emit-private-module-interface-path /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/Objects-normal/x86_64/xplpc.private.swiftinterface -Xcc -I/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/swift-overrides.hmap -Xcc -I/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/lib/include -Xcc -I/Users/paulo/Developer/workspaces/cpp/xplpc/objc/lib/include -Xcc -I/Users/paulo/Developer/workspaces/cpp/xplpc/c/lib/include -Xcc -I/Users/paulo/Developer/workspaces/cpp/xplpc/cxx/lib/include -Xcc -I/Users/paulo/Developer/workspaces/cpp/xplpc/cxx/custom/include -Xcc -isystem -Xcc /Users/paulo/.conan/data/spdlog/1.11.0/_/_/package/e1b2c13852eddae04a1bb4b78c1a94e612ad50d0/include -Xcc -isystem -Xcc /Users/paulo/.conan/data/fmt/9.1.0/_/_/package/fe73e68f47c5cf9c888429adab68548777ef40b3/include -Xcc -isystem -Xcc /Users/paulo/.conan/data/nlohmann_json/3.11.2/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -Xcc -I/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/DerivedSources-normal/x86_64 -Xcc -I/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/DerivedSources/x86_64 -Xcc -I/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/DerivedSources -Xcc -DCMAKE_INTDIR\=\"Release\" -Xcc -Dxplpc_EXPORTS -Xcc -DXPLPC_SERIALIZER_JSON -Xcc -DXPLPC_TARGET_SWIFT -Xcc -DSPDLOG_FMT_EXTERNAL -Xcc -DSPDLOG_COMPILED_LIB -emit-objc-header -emit-objc-header-path /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/Objects-normal/x86_64/xplpc-Swift.h -import-underlying-module -Xcc -ivfsoverlay -Xcc /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/unextended-module-overlay.yaml -working-directory /Users/paulo/Developer/workspaces/cpp/xplpc
cd /Users/paulo/Developer/workspaces/cpp/xplpc
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target x86_64-apple-macos10.15 -fmessage-length\=245 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -stdlib\=libc++ -Wno-trigraphs -fpascal-strings -O1 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -DCMAKE_INTDIR\=\"Release\" -Dxplpc_EXPORTS -DXPLPC_SERIALIZER_JSON -DXPLPC_TARGET_SWIFT -DSPDLOG_FMT_EXTERNAL -DSPDLOG_COMPILED_LIB -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -I/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/lib/include -I/Users/paulo/Developer/workspaces/cpp/xplpc/objc/lib/include -I/Users/paulo/Developer/workspaces/cpp/xplpc/c/lib/include -I/Users/paulo/Developer/workspaces/cpp/xplpc/cxx/lib/include -I/Users/paulo/Developer/workspaces/cpp/xplpc/cxx/custom/include -isystem /Users/paulo/.conan/data/spdlog/1.11.0/_/_/package/e1b2c13852eddae04a1bb4b78c1a94e612ad50d0/include -isystem /Users/paulo/.conan/data/fmt/9.1.0/_/_/package/fe73e68f47c5cf9c888429adab68548777ef40b3/include -isystem /Users/paulo/.conan/data/nlohmann_json/3.11.2/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -I/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/DerivedSources-normal/x86_64 -I/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/DerivedSources/x86_64 -I/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/DerivedSources -F/Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/lib -DNDEBUG -std\=c++17 -fPIC -MMD -MT dependencies -MF /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/Objects-normal/x86_64/CNativePlatformProxy.d --serialize-diagnostics /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/Objects-normal/x86_64/CNativePlatformProxy.dia -c /Users/paulo/Developer/workspaces/cpp/xplpc/c/lib/src/xplpc/proxy/CNativePlatformProxy.cpp -o /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64/build/xplpc.build/Release/Objects-normal/x86_64/CNativePlatformProxy.o

You can see that it is using:

-target x86_64-apple-macos10.15

The CMake log:

[INFO] Building for arch x86_64...
-- [DEFAULTS] Using explicit named language support! E.g., enable_language(CXX) is needed in the project files.
-- [DEFAULTS] Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!
-- [DEFAULTS] Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!
-- [DEFAULTS] Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!
-- Not setting any manual command-line buildflags, since Xcode is selected as the generator. Modifying the Xcode build-settings directly instead.
-- Configuring macosx build for platform: MAC_CATALYST, architecture(s): x86_64
-- Using SDK: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk
-- Using C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Using CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-- Using libtool: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
-- Using install name tool: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool
-- Autoconf target triple: x86_64-apple-ios13.1-macabi
-- Using minimum deployment version: 13.1 (SDK version: 11.0)
-- Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!
-- Using Xcode version: 14.2
-- CMake version: 3.26.1
-- Using a data_ptr size of: 8
-- Bitcode: Disabled
-- ARC: Enabled
-- Hiding symbols: Enabled
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Component target declared 'fmt::fmt'
-- Conan: Component target declared 'spdlog::spdlog'
-- Conan: Target declared 'nlohmann_json::nlohmann_json'
-- XPLPC Target: swift
-- XPLPC Interface: Enabled
-- XPLPC Custom Data: cxx/custom
-- The Swift compiler identification is Apple 5.7.2
-- Check for working Swift compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend
-- Check for working Swift compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend - works
-- Configuring done (4.6s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/paulo/Developer/workspaces/cpp/xplpc/build/swift-ios/mac-catalyst/x86_64
@paulocoutinhox
Copy link
Author

Also, CMake guys sad that the flag CMAKE_XCODE_EFFECTIVE_PLATFORMS don't exists.

https://github.com/leetal/ios-cmake/blob/master/ios.toolchain.cmake#L487

The thread is here:
https://gitlab.kitware.com/cmake/cmake/-/issues/24650#note_1347059

@pgbo
Copy link

pgbo commented Apr 17, 2023

If you use -G xcode in the generate cmake config command, the source code internally will be compiled using -target x86_64-apple-Macos10.15. If -G xcode is not used, will use -target x86_64-apple-ios13.1-macabi. Since the CMakeLists.txt of my project is configured with many Xcode-related properties, I need to compile the source code using the project generated by XCode.

After generating the XCode project, at the build stage I used the command xcodebuild-configuration Release-parallelizeTargets -jobs 2 ARCHS=x86_64 -sdk macosx SUPPORTS_MAC_CATALYST=YES -project myproject.xcodeproj -scheme myproject -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' to generate the maccatalyst framework, This command uses -target x86_64-apple-ios13.1-macabi internally. You get the same effect as not use -G xcode.

@jhakulin
Copy link
Contributor

Having the same issue here, would like to use Xcode generator e.g. for module map generation, however for Maccatalyst target hitting this issue. Any ideas why/how to get target selected for maccatalyst?

@feldkurat
Copy link

I think I have the same issue. I generate framework .xcodeproject with CMake and use it in big app when debugging.
It is the only way to debug for me.
For now I can add Mac(Catalyst) platform manually.
Building without '-G Xcode' works good, thanks for your work !

@borrrden
Copy link

This is pretty important because frameworks built using standard CMake Makefiles will not pass app store review for lack of certain properties like MinimumSystemVersion, etc. This can be worked around by using "custom Info.plist" but the Xcode target will do all of this automatically.

@leetal
Copy link
Owner

leetal commented Jul 18, 2024

Will look into this the coming week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants