[Swift Package Manager] Use of Info-plist; use for apps

If this worked in November 2020, something has changed.

The flags are passed to the Swift compiler so, in order to pass them along to the linker, each string must be preceded by -Xlinker like this:

      linkerSettings: [
      	.unsafeFlags( ["-Xlinker", "-sectcreate",
                       "-Xlinker", "__TEXT",
                       "-Xlinker", "__info_plist",
                       "-Xlinker", "Resources/Info.plist"] )
      ]),

How the incorrect description of this usage has lasted so long in this forum, and others, is beyond me, unless I'm being really stupid .. I suspect people read the documentation but never actually tried it. The error reported elsewhere in this thread: error: unknown argument: '-sectcreate' is a direct result of the missing -Xlinker options.

I have verified that the above code works .. here's a piece of my swift build generated executable:

 . . . . 5F5F 696E 666F 5F70 6C69 7374 == "__info_plist"

and I verified that the contents of Resources/Info.plist is also embedded in the executable. SPM's linkerSettings.unsafeFlags should perhaps stuff in the -Xlinker options for us?

6 Likes