rhx / SwiftGtk

A Swift wrapper around gtk-3.x and gtk-4.x that is largely auto-generated from gobject-introspection
https://rhx.github.io/SwiftGtk/
BSD 2-Clause "Simplified" License
317 stars 26 forks source link

XcodeGen adds incorrect flags #22

Closed Kiwijane3 closed 4 years ago

Kiwijane3 commented 4 years ago

The xcodegen.sh script currently adds six linker flags that cause errors: three -framework flags, and the isolated strings Cocoa, Carbon, and CoreGraphics. I think these might be meant to be together, .i.e, "-framework Cocoa" is meant to be output, but instead "-framework" and "Cocoa" are output separately. This can be resolved by manually removing these flags. Since the project compiles without the frameworks, they could just be removed.

rhx commented 4 years ago

-framework and Cocoa need to be separate parameters, otherwise the linker won't parse them correctly. This is actually done by the Swift Package Manager, based on the the flags passed in from pkg-config.

What is the issues you are having? I have tested this with the current Xcode 11.4.1 under Catalina and it's working fine for me (and has been for several years with different Xcode versions).

One thing to check: did you select your Mac as the target? The project won't work with an iOS target.

Kiwijane3 commented 4 years ago

Have you tried running xcoden.sh. I think the issue is new, as my older projects worked fine. To be more specific, the issue seems to be that “-framework” and “Cocoa” occur on separate lines in the project settings and are separated in the linker invocation. I think they should be one line so they occur together, as “-framework Cocoa”, whereas they are currently separated.

rhx commented 4 years ago

Sure, I use xcodegen.sh all the time. And yes, -framework and Cocoa need to be two separate parameters (Xcode will separe them by a space when calling the linker). You can easily test that a single parameter won't work if you pass this manually to the linker used by Swift on the command line using quotes, e.g.:

ld "-framework Cocoa"

will give you an error message ld: unknown option: -framework Cocoa, while

ld -framework Cocoa

recognises the two separate parameters -framework and Cocoa as the framework option with Cocoa as a parameter.

rhx commented 4 years ago

Also, if you look at the git log forxcodegen.sh, you can see that it hasn't changed since 2018. It has been working fine with every Xcode version since.

Check that the Xcode (and thus Swift) version you use on the command line is the same that you use to open the generated project. E.g. xcode-select -p should yield

/Applications/Xcode.app/Contents/Developer

if your current Xcode.app is in the /Applications folder. E.g. for Xcode 11.4.1 if you run the swift --version command, you should get

Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)
Target: x86_64-apple-darwin19.5.0
Kiwijane3 commented 4 years ago

Sorry, I’m not being very clear. I know they need to be separate, but they’re occurring in completely different places in the linker invocation, not next to each other. I’ll look into the versions and see if there’s a discrepancy.

Kiwijane3 commented 4 years ago

I looked into it further, and it looks like this is no longer an issue. Sorry to bother you.

Kiwijane3 commented 4 years ago

Might have been some particular issue I was having with Xcode 11.3.1, I don't know.