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

App doesn't compile with generic destination on xcodebuild #11

Open
emadhegab opened this issue Jan 9, 2024 · 10 comments
Open

App doesn't compile with generic destination on xcodebuild #11

emadhegab opened this issue Jan 9, 2024 · 10 comments
Labels
help wanted Extra attention is needed

Comments

@emadhegab
Copy link

I try to compile my app using this command
xcodebuild -scheme 'MyApp' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator'

but it gives me error always

protocos/MyAppService.swift:5:17: external macro implementation type 'MockableMacro.MockableMacro' could not be found for macro 'Mockable()'

It will run fine if changed the destination into -destination 'platform=iOS Simulator,name=iPhone'
but that will prevent me from using the .app file it generates in the E2E testing i have.

@Kolos65
Copy link
Owner

Kolos65 commented Jan 16, 2024

I can repro this on an example project, will update you if I find anything.

@Kolos65
Copy link
Owner

Kolos65 commented Jan 16, 2024

Not sure why, but what I have found so far is that if you omit the -sdk 'iphonesimulator' flag, it compiles:
xcodebuild -scheme 'MyApp' -destination 'generic/platform=iOS Simulator'
Are you sure you need to specify the base SDK explicitly?

@emadhegab
Copy link
Author

I tried. but it crash when dragging the .app to simulator and try to run it. i think without sdk it takes the default which is probably the real device

@Kolos65 Kolos65 added the help wanted Extra attention is needed label Feb 5, 2024
@Kolos65
Copy link
Owner

Kolos65 commented Apr 2, 2024

@emadhegab I will close this for now due to inactivity, will reopen if needed.

@Kolos65 Kolos65 closed this as completed Apr 2, 2024
@carlossolana-aily
Copy link

carlossolana-aily commented Jul 30, 2024

Someting similar is happening to me when archiving in the CI (GitHub Actions, macos13, Xcode 15.0.1, but also happens in macos14 and Xcode 15.4):

** ARCHIVE FAILED **

The following build commands failed:
	ComputeTargetDependencyGraph

If I remove Mockable from all module dependencies, comment imports and macros, then it works. The command looks like:

xcodebuild -workspace MyProject.xcworkspace -scheme MyScheme -configuration MyConfig -destination 'generic/platform=iOS' -skipPackagePluginValidation clean archive

The other dependencies I use are:

        .package(url: "https://github.com/hmlongco/Factory", exact: "2.3.2"),
        .package(url: "https://github.com/Kolos65/Mockable", exact: "0.0.9"),
        .package(url: "https://github.com/realm/SwiftLint", exact: "0.55.1")

Do you have any clue about what can be going on? I really like this library, I'd love to make it work :)

@Kolos65 Kolos65 reopened this Jul 30, 2024
@carlossolana-aily
Copy link

carlossolana-aily commented Aug 2, 2024

A minor finding:
If I leave my codebase like this:

#if canImport(Mockable)
import Mockable
#endif

#if canImport(Mockable)
@Mockable
#endif
protocol BlaBla {

And my Package.swift like this:

dependencies: [
        .package(path: "../PackageA"),
        .package(path: "../PackageB"),
        .package(path: "../PackageC"),
        .package(path: "../PackageD"),
        .package(url: "https://github.com/hmlongco/Factory", exact: "2.3.2"),
        .package(url: "https://github.com/Kolos65/Mockable", exact: "0.0.9"),
        .package(url: "https://github.com/realm/SwiftLint", exact: "0.55.1")
    ],
    targets: [
        .target(name: "MyPackage",
                dependencies: ["PackageA", "PackageB", "Factory", "PackageC", "PackageD"/*, .product(name: "Mockable", package: "Mockable")*/],
                path: "Sources",
                swiftSettings: [.define("MOCKING", .when(configuration: .debug))],
                plugins: [.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLint")]),
        .testTarget(name: "MyPackageTests", dependencies: ["MyPackage", .product(name: "MockableTest", package: "Mockable")]),
    ]

Then it still works on CI, because the produced product is not included in the target, and at the same time is "easy" to activate it (just uncomment that part) without changing the actual codebase.

Still trying to figure out the cause of this issue, I'll use this as a temporary workaround.

@Kolos65
Copy link
Owner

Kolos65 commented Aug 2, 2024

@carlossolana-aily Have you tried adding -skipMacroValidation to the xcodebuild command?

@carlossolana-aily
Copy link

No, I didn't! Now I reverted everything and it works! Thank you very much! :D

@Kolos65 Kolos65 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2024
@PowerOfCreation
Copy link

PowerOfCreation commented Oct 2, 2024

@Kolos65 I have the same problem and I need to build for iphonesimulator. Adding -skipMacroValidation to the xcodebuild command doesn't help unfortunately.

error: external macro implementation type 'MockableMacro.MockableMacro' could not be found for macro 'Mockable()'; '..../(Development)-iphonesimulator/MockableMacro' produced malformed response
public protocol MyServiceName {
                ^
.../build/derived_data/SourcePackages/checkouts/Mockable/Sources/Mockable/Macro/MockableMacro.swift:41:14: note: 'Mockable()' declared here
public macro Mockable() = #externalMacro(module: "MockableMacro", type: "MockableMacro")

@Jose-Luis-Nunez
Copy link

Jose-Luis-Nunez commented Oct 2, 2024

i have the same issue like emadhegab and -skipMacroValidation did not help, would be very nice if someone can support :-)

@Kolos65 Kolos65 reopened this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants