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

1. I recall there’s a way to make a command-line tool in macOS have an “Info.plist” file, which is compiled/linked in the executable’s data segment. I used Xcode back then. Is there a way to do this through “swift build”? (I think the Xcode directions are in Apple’s Code Signing Guide.) (I can’t use Xcode here since that project file is generated from swift-build!)

2. I don’t think the Package Manager can be used to create GUI apps, but can it be used to set up library code which is called from a Xcode project for a GUI app?

···


Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

I recall there’s a way to make a command-line tool in macOS have an “Info.plist” file, which is compiled/linked in the executable’s data segment.

Correct. Xcode has explicit support for this, namely the “Create Info.plist Section in Binary” build setting (`CREATE_INFOPLIST_SECTION_IN_BINARY`). This uses the file from the standard “Info.plist File” (`INFOPLIST_FILE`) build setting.

Is there a way to do this through “swift build”?

The above is implemented in terms of the `-sectcreate __TEXT __info_plist /path/to/file` linker option, which you can read about in <x-man-page://1/ld>. If you create a dummy Xcode command line tool project, you can look at the build transcript to see how it works.

I kinda presume that SPM has a way to pass in custom linker options but I don’t have direct experience with that.

Share and Enjoy

···

On 22 Aug 2017, at 06:13, Daryle Walker via swift-users <swift-users@swift.org> wrote:
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

I haven’t yet had the pleasure of investigating what’s available in
3.2/4.0’s swiftpm, but I did once hack this together in the 3.x
toolchain using a dummy module:

Hierarchy:
Sources/
-- InfoPlist
---- Dummy.c
---- include/
------ InfoPlist.h

InfoPlist.h:

__attribute__((used, section("__TEXT,__info_plist")))
static const char __darwin_info_plist[] = "<##escaped XML string##>";

__attribute__((used))
static inline void includeInfoPlist(void) {
    (void)(__darwin_info_plist);
}

partial main.swift:

import InfoPlist

includeInfoPlist()

I sure do hope there’s a better way to do this now, but just throwing it
out there for posterity.

Sincerely,
Zachary Waldowski
zach@waldowski.me[mailto:zach@waldowski.me]

···

On Tue, Aug 22, 2017, at 03:30 AM, Quinn The Eskimo! via swift-users wrote:

On 22 Aug 2017, at 06:13, Daryle Walker via swift-users > <swift-users@swift.org> wrote:

> I recall there’s a way to make a command-line tool in macOS have an “Info.plist” file, which is compiled/linked in the executable’s data segment.

Correct. Xcode has explicit support for this, namely the “Create
Info.plist Section in Binary” build setting
(`CREATE_INFOPLIST_SECTION_IN_BINARY`). This uses the file from the
standard “Info.plist File” (`INFOPLIST_FILE`) build setting.

> Is there a way to do this through “swift build”?

The above is implemented in terms of the `-sectcreate __TEXT __info_plist
/path/to/file` linker option, which you can read about in
<x-man-page://1/ld>. If you create a dummy Xcode command line tool
project, you can look at the build transcript to see how it works.

I kinda presume that SPM has a way to pass in custom linker options but I
don’t have direct experience with that.

Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Any advances on this story?

Terms of Service

Privacy Policy

Cookie Policy