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

cmake with Xcode and CocoaPods - compile problem #12333

Open
noktius opened this issue Apr 4, 2024 · 1 comment
Open

cmake with Xcode and CocoaPods - compile problem #12333

noktius opened this issue Apr 4, 2024 · 1 comment

Comments

@noktius
Copy link

noktius commented Apr 4, 2024

Report

What did you do?

I have a large mobile app project written in C++ (Qt) with many internal and external dependencies, as well as subprojects (Qt Creator), submodules and interconnections. For many years I’ve used qmake to generate Xcode project (with CocoaPods!), with many workarounds and hooks. I’ve decided to switch to cmake

I’ve created many different CMakeLists for each subproject, dependency and 3rd party library in my project. Xcode project generates fine using cmake and CMakeLists, but a huge problem arises when I run pod install (CocoaPods).

Because I have subprojects and submodules, I also have many targets in Xcode (basically for each subproject/submodule — CMakeLists). That’s fine, because I have different versions of my app and can turn on/off modules etc. But some core modules need external CocoaPods (ex. Firebase)…

Here is the problem. Because I have many targets inside my Xcode project, I have to define targets to install CocoaPods. I can’t define CocoaPods for the whole project, because there is no abstract target.

target “app-core" do
    project “my-app"

    pod 'Firebase/Core'
    pod 'Firebase/Messaging'
end

target "firebase-mlkit" do
    project “my-app"

    pod 'GoogleMLKit/BarcodeScanning'
end

For example, like this. After generating a pure Xcode project using cmake, I run pod install and generate a workspace. This workspace seems to be broken.

What did you expect to happen?

It opens fine, I can check all settings, all seems to be good, all schemas are there.. but the project cannot be built. I have ca. 20 submodules (targets), during compilation pretty all of them are compiling fine, but not the ones from Podfile! This is the problem.

For example, if I have only 2 targets in Podfile (like I mentioned before), each compilation I get

Link my-app
No such file or directory: '/Users/…../builds/my-app/app-core/Debug-iphonesimulator/libapp-core.a'
No such file or directory: '/Users/…../builds/my-app/3rdparty/firebase-mlkit/src/Debug-iphonesimulator/libfirebase-mlkit.a'

What happened instead?

So the Xcode cannot produce .a during this compilation. All other .a were compiled successfully. But! Those 2 targets (target “app-core" and target "firebase-mlkit”) do exist in Xcode Workspace, they can be chosen and observed! I can even receive errors from source code in this targets, so the compiler does "visit" those targets and tries to compile them!

I have to use CocoaPods, because Google doesn't support SPM.

CocoaPods Environment

Stack

   CocoaPods : 1.15.2
        Ruby : ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
    RubyGems : 3.5.4
        Host : macOS 14.4.1 (23E224)
       Xcode : 15.3 (15E204a)
         Git : git version 2.40.0
Ruby lib dir : /opt/homebrew/Cellar/ruby/3.3.0/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/bin/pod

Plugins

cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.1
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0

Project that demonstrates the issue

Private project.

I’ve tried:

  1. All possible combinations of Podfile (no targets, all targets, abstract targets…) — it seems like cmake makes his own connections and settings that Podfile just breaks..

  2. Many different suggestions from Google, like:

    set(COCOAPODS_FRAMEWORK_SEARCH_PATHS "............/Pods/**")
    set(CMAKE_XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS "${COCOAPODS_FRAMEWORK_SEARCH_PATHS}")

    set_target_properties(firebase-mlkit PROPERTIES XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS "${COCOAPODS_FRAMEWORK_SEARCH_PATHS}")
    set_target_properties(firebase-mlkit PROPERTIES XCODE_ATTRIBUTE_CONFIGURATION_BUILD_DIR "${BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)")
    set_target_properties(firebase-mlkit PROPERTIES XCODE_ATTRIBUTE_LIBRARY_SEARCH_PATHS "${COCOAPODS_FRAMEWORK_SEARCH_PATHS}")

  3. Many crazy hard-coded settings directly in Xcode — nothing helped.

  4. File-difference betweet Xcode-projects on different stages - that's overkill.
    Does anyone have any idea what could help in this situation? Why Xcode doesn't generate .a for the targets, that were changed with CocoaPods? Did I miss a setting, a path or an argument somewhere?

(cmake 3.29.0, Qt 6.7, Xcode 15.3, cocoapods 1.15.2)

@noktius
Copy link
Author

noktius commented Apr 11, 2024

I've created a test CMake repository that clearly demonstrates this issue. Please refer to the repository linked below for a detailed view and reproducible example: https://github.com/noktius/cmake-cocoapods-example/

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

No branches or pull requests

1 participant