[swift-users] swift redistributable without Xcode

Jordan Rose jordan_rose at apple.com
Thu May 12 12:36:01 CDT 2016


That's utils/build-toolchain.

The SDK that's needed is the actual OS X SDK that comes with Xcode. (It says that in the error message.) This is not something that people are allowed to distribute on their own; the destination computer will need to have either Xcode or Apple's Command-Line Tools package installed if you want to use any of the OS X frameworks (and not just the standard library).

Jordan



> On May 11, 2016, at 20:03, Tim Prepscius <timprepscius at gmail.com> wrote:
> 
> Or better yet.
> 
> What is the command that is used to build the downloadable swift
> packages for OSX?
> I can go from there probably.
> 
> -tim
> 
> On 5/11/16, Tim Prepscius <timprepscius at gmail.com> wrote:
>> Also,
>> 
>> So I build the thing, and I move over the swift directory to a
>> computer without Xcode.
>> 
>> I run bin/swift
>> and get:
>> 
>> swift-macosx-x86_64 tim$ bin/swift
>> ***  You are running Swift's integrated REPL,  ***
>> ***  intended for testing purposes only.       ***
>> ***  The full REPL is built as part of LLDB.   ***
>> ***  Type ':help' for assistance.              ***
>> (swift) import Foundation
>> <unknown>:0: error: cannot load underlying module for 'CoreGraphics'
>> <unknown>:0: note: did you forget to set an SDK using -sdk or SDKROOT?
>> <unknown>:0: note: use "xcrun -sdk macosx swiftc" to select the
>> default OS X SDK installed with Xcode
>> 
>> 
>> I then guess the SDK would be:
>> ./stdlib/public/SDK
>> 
>> so:
>> swift-macosx-x86_64 tim$
>> SDKROOT=/Users/tim/temp/swift-macosx-x86_64/stdlib/public/SDK
>> bin/swift
>> ***  You are running Swift's integrated REPL,  ***
>> ***  intended for testing purposes only.       ***
>> ***  The full REPL is built as part of LLDB.   ***
>> ***  Type ':help' for assistance.              ***
>> (swift) import Foundation
>> <unknown>:0: error: cannot load underlying module for 'CoreGraphics'
>> 
>> 
>> 
>> 
>> Any ideas here?
>> Is there any known build where I can build swift, copy the build to
>> another OS X computer and run it?
>> 
>> Thanks,
>> 
>> -tim
>> 
>> On 5/11/16, Tim Prepscius <timprepscius at gmail.com> wrote:
>>> Ok,
>>> 
>>> so when I build finally it:
>>> du -h -d 1
>>> 3.7M	./cmark-macosx-x86_64
>>> 81M	./llbuild-macosx-x86_64
>>> 5.6G	./lldb-macosx-x86_64
>>> 7.9G	./llvm-macosx-x86_64
>>> 18M	./ninja-build
>>> 8.4G	./swift-macosx-x86_64
>>> 47M	./swiftpm-macosx-x86_64
>>> 22G	.
>>> 
>>> 
>>> 22 gigs is a bit much?
>>> Even the 8.4gigs for just the swift directory is a bit much.
>>> 
>>> Am I running the wrong preset somehow?
>>> Should I be running a certain preset of the build-bot?
>>> 
>>> -tim
>>> 
>>> 
>>> On 5/9/16, Tim Prepscius <timprepscius at gmail.com> wrote:
>>>> Thank you,
>>>> 
>>>> Trying.
>>>> 
>>>> utils/build-toolchain local.swift tries to use ninja which fails
>>>> so I go to the swift and see "git clone
>>>> git at github.com:ninja-build/ninja.git && cd ninja" ...
>>>> which fails
>>>> 
>>>> so I do:
>>>> git clone https://github.com/ninja-build/ninja.git
>>>> 
>>>> and then I do git checkout release
>>>> like it says to
>>>> 
>>>> but that creates a branch release
>>>> I'm guessing git checkout $RELEASE
>>>> where RELEASE=v1.7.1
>>>> 
>>>> 
>>>> my updated build swift script now looks like this:
>>>> 
>>>>> cat build-apple-swift.sh
>>>> #RELEASE=swift-2.2.1-RELEASE
>>>> RELEASE=swift-DEVELOPMENT-SNAPSHOT-2016-05-03-a
>>>> 
>>>> #sudo port install cmake ninja
>>>> 
>>>> mkdir apple-swift
>>>> cd apple-swift
>>>> 
>>>> NINJA_RELEASE=v1.7.1
>>>> git clone https://github.com/ninja-build/ninja.git
>>>> (cd ninja && git checkout tags/$NINJA_RELEASE && ./configure.py
>>>> --bootstrap)
>>>> 
>>>> git clone https://github.com/apple/swift.git
>>>> (cd swift && utils/update-checkout --clone)
>>>> 
>>>> for D in *; do
>>>>  if [ -d "${D}" ]; then
>>>>    echo "checkout $RELEASE of ${D}"
>>>>    (cd ${D} && git checkout tags/$RELEASE)
>>>>  fi
>>>> done
>>>> 
>>>> #set MACOSX_DEPLOYMENT_TARGET=10.9
>>>> 
>>>> cd swift
>>>> #utils/build-script -R
>>>> utils/build-toolchain local.swift
>>>> 
>>>> ----
>>>> 
>>>> I will find out if it works in an hour or so I guess
>>>> 
>>>> -tim
>>>> 
>>>> On 5/9/16, Jordan Rose <jordan_rose at apple.com> wrote:
>>>>> Hi, Tim. The build directory contains symlinks and such and therefore
>>>>> isn’t
>>>>> really the best vehicle for distribution. There’s a build-toolchain
>>>>> script
>>>>> inside swift/utils/ that should give you a self-contained directory,
>>>>> and
>>>>> more generally there’s a notion of “install components” that can be
>>>>> used
>>>>> to
>>>>> build a self-contained directory tree as an output of build-script.
>>>>> 
>>>>> Hope that helps,
>>>>> Jordan
>>>>> 
>>>>> 
>>>>>> On May 8, 2016, at 09:33, Tim Prepscius via swift-users
>>>>>> <swift-users at swift.org> wrote:
>>>>>> 
>>>>>> Is there any way I can get "import Foundation" working on a machine
>>>>>> other than the machine I compiled with?
>>>>>> 
>>>>>> I notice that those "float.h" headers are within the llvm build,
>>>>>> however when I try to do -I of that directory it fails. (I tried as an
>>>>>> include as a framework as an include passed to the compiler)..
>>>>>> 
>>>>>> -tim
>>>>>> 
>>>>>> On 5/7/16, Tim Prepscius <timprepscius at gmail.com> wrote:
>>>>>>> Ok, so building is working
>>>>>>> with the following script:
>>>>>>> 
>>>>>>> more build-swift-script.sh
>>>>>>> RELEASE=swift-2.2.1-RELEASE
>>>>>>> 
>>>>>>> sudo port install cmake ninja
>>>>>>> 
>>>>>>> mkdir apple-swift
>>>>>>> cd apple-swift
>>>>>>> 
>>>>>>> git clone https://github.com/apple/swift.git
>>>>>>> (cd swift && utils/update-checkout --clone)
>>>>>>> 
>>>>>>> for D in *; do
>>>>>>> if [ -d "${D}" ]; then
>>>>>>>   echo "checkout $RELEASE of ${D}"
>>>>>>>   (cd ${D} && git checkout tags/$RELEASE)
>>>>>>> fi
>>>>>>> done
>>>>>>> 
>>>>>>> cd swift
>>>>>>> utils/build-script -R
>>>>>>> 
>>>>>>> -----------------------
>>>>>>> 
>>>>>>> however, running does not work.
>>>>>>> I move the entire build directory to another computer,
>>>>>>> 
>>>>>>> I go into:
>>>>>>> build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin
>>>>>>> 
>>>>>>> And run:
>>>>>>> ./swift
>>>>>>> ***  You are running Swift's integrated REPL,  ***
>>>>>>> ***  intended for testing purposes only.       ***
>>>>>>> ***  The full REPL is built as part of LLDB.   ***
>>>>>>> ***  Type ':help' for assistance.              ***
>>>>>>> (swift) import Foundation
>>>>>>> /usr/include/module.map:36:14: error: header 'float.h' not found
>>>>>>>     header "float.h" // note: supplied by compiler
>>>>>>>            ^
>>>>>>> /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:11:10:
>>>>>>> note: submodule of top-level module 'Darwin' implicitly imported here
>>>>>>> #include <sys/types.h>
>>>>>>>        ^
>>>>>>> <module-includes>:1:9: note: in file included from
>>>>>>> <module-includes>:1:
>>>>>>> #import "Headers/CoreFoundation.h"
>>>>>>>       ^
>>>>>>> /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:12:10:
>>>>>>> error: 'stdarg.h' file not found
>>>>>>> #include <stdarg.h>
>>>>>>>        ^
>>>>>>> <unknown>:0: error: could not build Objective-C module
>>>>>>> 'CoreFoundation'
>>>>>>> 
>>>>>>> ---------------
>>>>>>> 
>>>>>>> Any hints?
>>>>>>> 
>>>>>>> -tim
>>>>>>> 
>>>>>>> On 5/6/16, Tim Prepscius <timprepscius at gmail.com> wrote:
>>>>>>>> This might be a bug in your tagging system:
>>>>>>>> 
>>>>>>>> compiler-rt
>>>>>>>> llbuild
>>>>>>>> swift-corelibs-foundation
>>>>>>>> swift-corelibs-libdispatch
>>>>>>>> swift-corelibs-xctest
>>>>>>>> swiftpm
>>>>>>>> 
>>>>>>>> are missing the tag
>>>>>>>> error: pathspec 'tags/swift-2.2.1-RELEASE' did not match any file(s)
>>>>>>>> known to git.
>>>>>>>> 
>>>>>>>> although they do have tags such as:
>>>>>>>> swiftpm tprepscius$ git tag -l
>>>>>>>> 0.1.0
>>>>>>>> 0.2.0
>>>>>>>> 0.2.1
>>>>>>>> 0.2.2
>>>>>>>> swift-2.2-SNAPSHOT-2015-12-01-a
>>>>>>>> swift-2.2-SNAPSHOT-2015-12-01-b
>>>>>>>> swift-2.2-SNAPSHOT-2015-12-10-a
>>>>>>>> swift-2.2-SNAPSHOT-2015-12-18-a
>>>>>>>> swift-2.2-SNAPSHOT-2015-12-22-a
>>>>>>>> swift-2.2-SNAPSHOT-2015-12-31-a
>>>>>>>> swift-2.2-SNAPSHOT-2016-01-06-a
>>>>>>>> swift-2.2-SNAPSHOT-2016-01-11-a
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-02-03-a
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-02-08
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-02-25-a
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a
>>>>>>>> swift-DEVELOPMENT-SNAPSHOT-2016-05-03-a
>>>>>>>> 
>>>>>>>> -tim
>>>>>>>> 
>>>>>>>> 
>>>>>>>> On 5/6/16, Tim Prepscius <timprepscius at gmail.com> wrote:
>>>>>>>>> So far this seems to be working:
>>>>>>>>> 
>>>>>>>>> build-swift-script.sh
>>>>>>>>> RELEASE=swift-2.2.1-RELEASE
>>>>>>>>> 
>>>>>>>>> mkdir apple-swift
>>>>>>>>> cd apple-swift
>>>>>>>>> git clone https://github.com/apple/swift.git
>>>>>>>>> cd swift
>>>>>>>>> utils/update-checkout --clone
>>>>>>>>> 
>>>>>>>>> for D in *; do
>>>>>>>>> if [ -d "${D}" ]; then
>>>>>>>>>   echo "checkout $RELEASE of ${D}"
>>>>>>>>>   (cd ${D} && git checkout tags/$RELEASE)
>>>>>>>>> fi
>>>>>>>>> done
>>>>>>>>> 
>>>>>>>>> cd ../swift
>>>>>>>>> utils/build-script -R
>>>>>>>>> 
>>>>>>>>> ------
>>>>>>>>> 
>>>>>>>>> will see if it completes a build
>>>>>>>>> 
>>>>>>>>> -tim
>>>>>>>>> 
>>>>>>>>> On 5/6/16, Tim Prepscius <timprepscius at gmail.com> wrote:
>>>>>>>>>> Ok download says it does not work
>>>>>>>>>> 
>>>>>>>>>> silver:swift tprepscius$ utils/update-checkout --clone
>>>>>>>>>> --- Cloning 'swift' ---
>>>>>>>>>> fatal: destination path 'swift' already exists and is not an empty
>>>>>>>>>> directory.
>>>>>>>>>> utils/update-checkout: command terminated with a non-zero exit
>>>>>>>>>> status
>>>>>>>>>> 128, aborting
>>>>>>>>>> silver:swift tprepscius$ utils/update-checkout
>>>>>>>>>> --- Updating '/Users/tprepscius/Documents/Projects/llvm' ---
>>>>>>>>>> Current branch stable is up to date.
>>>>>>>>>> --- Updating '/Users/tprepscius/Documents/Projects/clang' ---
>>>>>>>>>> Current branch stable is up to date.
>>>>>>>>>> --- Updating '/Users/tprepscius/Documents/Projects/cmark' ---
>>>>>>>>>> Current branch master is up to date.
>>>>>>>>>> --- Updating '/Users/tprepscius/Documents/Projects/lldb' ---
>>>>>>>>>> Current branch master is up to date.
>>>>>>>>>> --- Updating
>>>>>>>>>> '/Users/tprepscius/Documents/Projects/swift-integration-tests'
>>>>>>>>>> ---
>>>>>>>>>> Current branch master is up to date.
>>>>>>>>>> --- Updating '/Users/tprepscius/Documents/Projects/swift' ---
>>>>>>>>>> fatal: Not a git repository (or any of the parent directories):
>>>>>>>>>> .git
>>>>>>>>>> utils/update-checkout: command terminated with a non-zero exit
>>>>>>>>>> status
>>>>>>>>>> 128, aborting
>>>>>>>>>> 
>>>>>>>>>> however I think, that it might build anyways.  will check.
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> I wonder if there is a command that I should be using instead of
>>>>>>>>>> utils/update-checkout
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Btw, I'm not writing this to be annoying.  I'm writing it so
>>>>>>>>>> someone
>>>>>>>>>> googling in the future can find the path I take to get things
>>>>>>>>>> building.
>>>>>>>>>> (I googled a *lot* trying to find Swift without Xcode on OS X)
>>>>>>>>>> 
>>>>>>>>>> -tim
>>>>>>>>>> 
>>>>>>>>>> On 5/6/16, Tim Prepscius <timprepscius at gmail.com> wrote:
>>>>>>>>>>> Hmm actually that doesn't work at all:
>>>>>>>>>>> 
>>>>>>>>>>> --- Updating '/Users/tprepscius/Documents/Projects/swift' ---
>>>>>>>>>>> First, rewinding head to replay your work on top of it...
>>>>>>>>>>> Applying: [Build system] Add presets for Swift inside the LLDB
>>>>>>>>>>> tree.
>>>>>>>>>>> Using index info to reconstruct a base tree...
>>>>>>>>>>> M	utils/build-presets.ini
>>>>>>>>>>> Falling back to patching base and 3-way merge...
>>>>>>>>>>> Auto-merging utils/build-presets.ini
>>>>>>>>>>> CONFLICT (content): Merge conflict in utils/build-presets.ini
>>>>>>>>>>> Failed to merge in the changes.
>>>>>>>>>>> Patch failed at 0001 [Build system] Add presets for Swift inside
>>>>>>>>>>> the
>>>>>>>>>>> LLDB
>>>>>>>>>>> tree.
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> I will try using the download instead of the clone of swift
>>>>>>>>>>> 
>>>>>>>>>>> On 5/6/16, Tim Prepscius <timprepscius at gmail.com> wrote:
>>>>>>>>>>>> Cool.
>>>>>>>>>>>> 
>>>>>>>>>>>> Working on this now.
>>>>>>>>>>>> 
>>>>>>>>>>>> Out of curiosity:
>>>>>>>>>>>> Let's say I clone and checkout the 2.2.1 release tag
>>>>>>>>>>>> and then run the update-checkout util
>>>>>>>>>>>> 
>>>>>>>>>>>> git clone https://github.com/apple/swift.git
>>>>>>>>>>>> cd swift
>>>>>>>>>>>> git checkout tags/swift-2.2.1-RELEASE
>>>>>>>>>>>> ./utils/update-checkout --clone
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> Will this update-checkout command clone the llvm & clang & etc
>>>>>>>>>>>> and then move to the correct tag for 2.2.1?  (if there even is
>>>>>>>>>>>> one)
>>>>>>>>>>>> or will it use HEAD all of the time?
>>>>>>>>>>>> 
>>>>>>>>>>>> -tim
>>>>>>>>>>>> 
>>>>>>>>>>>> On 5/6/16, Joe Groff <jgroff at apple.com> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On May 6, 2016, at 1:14 PM, Tim Prepscius via swift-users
>>>>>>>>>>>>>> <swift-users at swift.org> wrote:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Greetings,
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Is it possible to build swift using Xcode, and then distribute
>>>>>>>>>>>>>> swift
>>>>>>>>>>>>>> without Xcode?
>>>>>>>>>>>>>> Or, does there already is exist some link to swift on OS X
>>>>>>>>>>>>>> which
>>>>>>>>>>>>>> is
>>>>>>>>>>>>>> not contained in Xcode?
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I need a swift compiler/executable that will run on all
>>>>>>>>>>>>>> versions
>>>>>>>>>>>>>> of
>>>>>>>>>>>>>> MacOSX, not just the latest.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> A Swift app built with Xcode is self-contained and can be
>>>>>>>>>>>>> distributed
>>>>>>>>>>>>> independent of Xcode. You can target back to OS X 10.9.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -Joe
>>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> _______________________________________________
>>>>>> swift-users mailing list
>>>>>> swift-users at swift.org
>>>>>> https://lists.swift.org/mailman/listinfo/swift-users
>>>>> 
>>>>> 
>>>> 
>>> 
>> 



More information about the swift-users mailing list