tuist / tuist

Tuist's CLI
https://tuist.io
MIT License
4.61k stars 559 forks source link

Xcode 13 - Dependencies.swift - bitcode not enabled for dependency error #3526

Closed zdnk closed 2 years ago

zdnk commented 3 years ago

Describe the bug When generating project with SPM dependencies in Dependencies.swift, and using Apollo and opening generated workspace in Xcode 13, the build fails because Apollo is not built with bitcode, I checked the Tuist generated Apollo project build settings and bitcode is enabled.

It works fine in Xcode 12!

Screenshot 2021-09-30 at 12 53 11

Example project: https://github.com/zdnk/tuist-apollo-dependency-example

It only occurs when:

Last tested on Tuist 2.0.2, Xcode 13

UPDATE: seems to happening for any dependency linked to framework which is then linked to app.

To Reproduce Project.swift

import ProjectDescription

let baseSettings = SettingsDictionary()
    .bitcodeEnabled(true)

let project = Project(
    name: "TuistApollo",
    settings: .settings(base: baseSettings),
    targets: [
        // App
        .init(
            name: "App",
            platform: .iOS,
            product: .app,
            productName: "TuistApollo",
            bundleId: "com.TuistApollo.application",
            deploymentTarget: .iOS(targetVersion: "14.0", devices: .iphone),
            infoPlist: .default,
            sources: [
                "Targets/TuistApollo/Sources/*.swift",
            ],
            dependencies: [
                .external(name: "Apollo"),
                .target(name: "API"),
            ]
        ),

        .init(
            name: "API",
            platform: .iOS,
            product: .framework,
            productName: "API",
            bundleId: "com.TuistApollo.api",
            deploymentTarget: .iOS(targetVersion: "14.0", devices: .iphone),
            infoPlist: .default,
            sources: [
                "Targets/TuistAPI/Sources/*.swift",
            ],
            dependencies: [
                .external(name: "Apollo"),
            ]
        ),

    ]
)

Dependencies.swift

import ProjectDescription

let dependencies = Dependencies(
    swiftPackageManager: [
        .remote(url: "https://github.com/apollographql/apollo-ios.git", requirement: .upToNextMajor(from: "0.43.0")),
    ],
    platforms: [.iOS]
)

Generate the project/workspace:

tuist dependencies fetch
tuist generate

Desktop (please complete the following information):

zdnk commented 3 years ago

any pointer where/what is the issue?

zdnk commented 3 years ago

same on 2.0.1

danieleformichelli commented 3 years ago

Hey @zdnk 👋 Could you please attach a sample project to reproduce the issue (e.g. as done here)?

zdnk commented 3 years ago

I am unable to reproduce it in clean project :/ No idea what the issue is.

zdnk commented 3 years ago

Figured it out, it only occurs when:

  1. bullding for device or archiving
  2. the Apollo dependency is linked in framework which is linked in the app
import ProjectDescription

let baseSettings = SettingsDictionary()
    .bitcodeEnabled(true)

let project = Project(
    name: "TuistApollo",
    settings: .settings(base: baseSettings),
    targets: [
        // App
        .init(
            name: "App",
            platform: .iOS,
            product: .app,
            productName: "TuistApollo",
            bundleId: "com.TuistApollo.application",
            deploymentTarget: .iOS(targetVersion: "14.0", devices: .iphone),
            infoPlist: .default,
            sources: [
                "Targets/TuistApollo/Sources/*.swift",
            ],
            dependencies: [
                .external(name: "Apollo"),
                .target(name: "API"),
            ]
        ),

        .init(
            name: "API",
            platform: .iOS,
            product: .framework,
            productName: "API",
            bundleId: "com.TuistApollo.api",
            deploymentTarget: .iOS(targetVersion: "14.0", devices: .iphone),
            infoPlist: .default,
            sources: [
                "Targets/TuistAPI/Sources/*.swift",
            ],
            dependencies: [
                .external(name: "Apollo"),
            ]
        ),

    ]
)
zdnk commented 3 years ago

here is the whole example project: https://github.com/zdnk/tuist-apollo-dependency-example

danieleformichelli commented 3 years ago

@zdnk could you update the first message with:

zdnk commented 3 years ago

Done, hope thats enough.

zdnk commented 3 years ago

UPDATE: seems to happening for any dependency linked to framework which is then linked to app.

zdnk commented 3 years ago

Any idea what's causing this? I had to revert back to using packages in Project.swift

danieleformichelli commented 3 years ago

I think the problem is the .bitcodeEnabled(true) setting. I think that in order to enable bitcode in your target, all its dependencies needs to have bitcode enabled as well. Not sure if/how tuist is handling it at the moment (regardless of the SPM dependencies integration), maybe @kwridan, @pepibumur, or @fortmarek knows more 🙏

zdnk commented 3 years ago

Well, as I mentioned, I check the projects generated for SPM dependencies and they actually have Bitcode enabled, so I don't know what is the issue.

marciliojrs commented 3 years ago

I'm having the same issue. Everything working when building for simulators but I'm getting the same message for device builds.

thedavidharris commented 3 years ago

Try flipping ENABLE_TESTING_SEARCH_PATHS = YES in any of the xcodeproj files for a converted SPM module to NO as I believe that will fix it.

marciliojrs commented 3 years ago

@thedavidharris there's a way to do that through Dependencies.swift file?

zdnk commented 2 years ago

version 2.1.0 or newer using tuist generate just outputs

Using version 2.1.1 defined at /ios-app/.tuist-version

And thats it, nothing is generated.

Using 2.0.0:

Couldn't find target 'CSQLite' at '/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/GRDB.swift' Consider creating an issue using the following link: https://github.com/tuist/tuist/issues/new/choose

zdnk commented 2 years ago

Try flipping ENABLE_TESTING_SEARCH_PATHS = YES in any of the xcodeproj files for a converted SPM module to NO as I believe that will fix it.

@thedavidharris After moving GRDB back to packages in Project.swift this workaround works with 2.1.1 :) Now does this break anything else, why is it causing this issue and how to fix it?

wattson12 commented 2 years ago

Now does this break anything else, why is it causing this issue and how to fix it?

I'm interested if this breaks anything, but I've added a PR which adds this change for all SPM packages to help test https://github.com/tuist/tuist/pull/3653

zdnk commented 2 years ago

after checking with Tuist 2.3.0, the issue when running tuist generate and it does not do anything when GRDB (https://github.com/zdnk/GRDB.swift) is in Dependencies.swift as SPM package is stil there.

zdnk commented 2 years ago

also, Tuist/Dependencies/SwiftPackageManager is empty

danieleformichelli commented 2 years ago

@zdnk this looks like a different error wrt the original one, could you please open a separate issue and provide all the required information? 🙏