Swift Package Manager questions


(Edward Connell) #1

Hi, I've written a Swift (with some C) framework the builds and runs
cleanly in Xcode 8.
A critical feature of my project is for my framework to run on MacOS, iOS,
and Linux.
I am trying to figure out how to build using the SPM so I can run on Ubuntu.
I'm not so happy with the project structure now, but at least I think I am
almost there.

I've hit a sticking point that I can't seem to figure out. The SPM sets the
target SDK to 10.10 by default.
Features in Swift 3.0 that I am using require at least 10.11. When I type:

*swift build -Xcc -I/usr/local/include -Xswiftc -j4 -Xlinker
-L/usr/local/lib -Xlinker -lpng -Xlinker -ljpeg*

The build bombs with:

"... error: 'init(fileURLWithPath:relativeTo:)' is only available on OS X
10.11 or newer"

How do I set the correct OS version??

I looked at the Xcode settings and tried to pass them through, but there
seems to be an argument parsing error by SPM.
I am currently trying:

*swift build -Xcc -I/usr/local/include -Xswiftc -j4 -Xswiftc -sdk
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
-Xswiftc -target x86_64-apple-macosx10.12 -Xlinker -L/usr/local/lib
-Xlinker -lpng -Xlinker -ljpeg*

And I get:

error: unknown command:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk

So it seems it thinks the parameter is a command.

*How do you set the sdk and target versions through swift build to fix this
problem?*

Thanks, Ed

*Configuration*:

MacBook Pro (Retina, 13-inch, Early 2015)

Sierra 10.12 (16A323)

Xcode Version 8.0 (8A218a)


(Ankit Agarwal) #2

Hi,

Currently in Swift 3 release of SwiftPM, you cannot override this setting.
A proper solution to this problem is yet to be built in SwiftPM however in
the mean time this patch was landed to allow overrides by passing custom
args: https://github.com/apple/swift-package-manager/pull/715
It is available in a recent trunk snapshot from swift.org

Also, while passing custom arguments to swift build, escape each argument
with the prefix eg:
*`-Xswiftc -target x86_64-apple-macosx10.12` **should be:** `**-Xswiftc
-target **-Xswiftc **x86_64-apple-macosx10.12`*

···

On Mon, Oct 17, 2016 at 5:23 AM, Edward Connell via swift-users < swift-users@swift.org> wrote:

Hi, I've written a Swift (with some C) framework the builds and runs
cleanly in Xcode 8.
A critical feature of my project is for my framework to run on MacOS, iOS,
and Linux.
I am trying to figure out how to build using the SPM so I can run on
Ubuntu.
I'm not so happy with the project structure now, but at least I think I am
almost there.

I've hit a sticking point that I can't seem to figure out. The SPM sets
the target SDK to 10.10 by default.
Features in Swift 3.0 that I am using require at least 10.11. When I type:

*swift build -Xcc -I/usr/local/include -Xswiftc -j4 -Xlinker
-L/usr/local/lib -Xlinker -lpng -Xlinker -ljpeg*

The build bombs with:

"... error: 'init(fileURLWithPath:relativeTo:)' is only available on OS X
10.11 or newer"

How do I set the correct OS version??

I looked at the Xcode settings and tried to pass them through, but there
seems to be an argument parsing error by SPM.
I am currently trying:

*swift build -Xcc -I/usr/local/include -Xswiftc -j4 -Xswiftc -sdk
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
-Xswiftc -target x86_64-apple-macosx10.12 -Xlinker -L/usr/local/lib
-Xlinker -lpng -Xlinker -ljpeg*

And I get:

error: unknown command: /Applications/Xcode.app/
Contents/Developer/Platforms/MacOSX.platform/Developer/
SDKs/MacOSX10.12.sdk

So it seems it thinks the parameter is a command.

*How do you set the sdk and target versions through swift build to fix
this problem?*

Thanks, Ed

*Configuration*:

MacBook Pro (Retina, 13-inch, Early 2015)

Sierra 10.12 (16A323)

Xcode Version 8.0 (8A218a)

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

--
Ankit


(Edward Connell) #3

Thanks Ankit,
Should I be able to pick up that change with Xcode 8.1 beta 3 (latest)? Oct
10th.

Ed

···

On Mon, Oct 17, 2016 at 11:42 AM, Ankit Agarwal <ankit@ankit.im> wrote:

Hi,

Currently in Swift 3 release of SwiftPM, you cannot override this setting.
A proper solution to this problem is yet to be built in SwiftPM however in
the mean time this patch was landed to allow overrides by passing custom
args: https://github.com/apple/swift-package-manager/pull/715
It is available in a recent trunk snapshot from swift.org

Also, while passing custom arguments to swift build, escape each argument
with the prefix eg:
*`-Xswiftc -target x86_64-apple-macosx10.12` **should be:** `**-Xswiftc
-target **-Xswiftc **x86_64-apple-macosx10.12`*

On Mon, Oct 17, 2016 at 5:23 AM, Edward Connell via swift-users < > swift-users@swift.org> wrote:

Hi, I've written a Swift (with some C) framework the builds and runs
cleanly in Xcode 8.
A critical feature of my project is for my framework to run on MacOS,
iOS, and Linux.
I am trying to figure out how to build using the SPM so I can run on
Ubuntu.
I'm not so happy with the project structure now, but at least I think I
am almost there.

I've hit a sticking point that I can't seem to figure out. The SPM sets
the target SDK to 10.10 by default.
Features in Swift 3.0 that I am using require at least 10.11. When I type:

*swift build -Xcc -I/usr/local/include -Xswiftc -j4 -Xlinker
-L/usr/local/lib -Xlinker -lpng -Xlinker -ljpeg*

The build bombs with:

"... error: 'init(fileURLWithPath:relativeTo:)' is only available on OS
X 10.11 or newer"

How do I set the correct OS version??

I looked at the Xcode settings and tried to pass them through, but there
seems to be an argument parsing error by SPM.
I am currently trying:

*swift build -Xcc -I/usr/local/include -Xswiftc -j4 -Xswiftc -sdk
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
-Xswiftc -target x86_64-apple-macosx10.12 -Xlinker -L/usr/local/lib
-Xlinker -lpng -Xlinker -ljpeg*

And I get:

error: unknown command: /Applications/Xcode.app/Conten
ts/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk

So it seems it thinks the parameter is a command.

*How do you set the sdk and target versions through swift build to fix
this problem?*

Thanks, Ed

*Configuration*:

MacBook Pro (Retina, 13-inch, Early 2015)

Sierra 10.12 (16A323)

Xcode Version 8.0 (8A218a)

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

--
Ankit


(Daniel Dunbar) #4

Hi Ed,

No, the package manager in the Xcode 8.1 beta only has minimal bug fixes.

You can, however, get this by grabbing a snapshot toolchain from http://swift.org/download.

- Daniel

···

On Oct 17, 2016, at 12:10 PM, Edward Connell via swift-users <swift-users@swift.org> wrote:

Thanks Ankit,
Should I be able to pick up that change with Xcode 8.1 beta 3 (latest)? Oct 10th.

Ed

On Mon, Oct 17, 2016 at 11:42 AM, Ankit Agarwal <ankit@ankit.im <mailto:ankit@ankit.im>> wrote:
Hi,

Currently in Swift 3 release of SwiftPM, you cannot override this setting.
A proper solution to this problem is yet to be built in SwiftPM however in the mean time this patch was landed to allow overrides by passing custom args: https://github.com/apple/swift-package-manager/pull/715
It is available in a recent trunk snapshot from swift.org <http://swift.org/>

Also, while passing custom arguments to swift build, escape each argument with the prefix eg:
`-Xswiftc -target x86_64-apple-macosx10.12` should be: `-Xswiftc -target -Xswiftc x86_64-apple-macosx10.12`

On Mon, Oct 17, 2016 at 5:23 AM, Edward Connell via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
Hi, I've written a Swift (with some C) framework the builds and runs cleanly in Xcode 8.
A critical feature of my project is for my framework to run on MacOS, iOS, and Linux.
I am trying to figure out how to build using the SPM so I can run on Ubuntu.
I'm not so happy with the project structure now, but at least I think I am almost there.

I've hit a sticking point that I can't seem to figure out. The SPM sets the target SDK to 10.10 by default.
Features in Swift 3.0 that I am using require at least 10.11. When I type:

swift build -Xcc -I/usr/local/include -Xswiftc -j4 -Xlinker -L/usr/local/lib -Xlinker -lpng -Xlinker -ljpeg

The build bombs with:

"... error: 'init(fileURLWithPath:relativeTo:)' is only available on OS X 10.11 or newer"

How do I set the correct OS version??

I looked at the Xcode settings and tried to pass them through, but there seems to be an argument parsing error by SPM.
I am currently trying:

swift build -Xcc -I/usr/local/include -Xswiftc -j4 -Xswiftc -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -Xswiftc -target x86_64-apple-macosx10.12 -Xlinker -L/usr/local/lib -Xlinker -lpng -Xlinker -ljpeg

And I get:

error: unknown command: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
So it seems it thinks the parameter is a command.

How do you set the sdk and target versions through swift build to fix this problem?

Thanks, Ed

Configuration:

MacBook Pro (Retina, 13-inch, Early 2015)

Sierra 10.12 (16A323)

Xcode Version 8.0 (8A218a)

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

--
Ankit

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