Help on how to compile a project.


(Marcel Rebouças) #1

Hello all,

I’ve been using Swift for some time, and decided to learn deeper about the
language and the source code. I plan to try to modify a version of its
compiler in order to generate some code metrics (e.g. Depth of Inheritance
(DIT)) to the classes of the projects compiled by it. All in all, this is
the first time I am trying doing something like it - first time working in
a open source project -, and I’m lost.

*So, first, I would like to know if there is a way to compile xcode
projects (and all classes within it) using the Swift version that I built
from sources. *

I was able to correctly build Swift on my mac. Cloned the main
repositories, and built using swift/utils/build-script.

I am able to run .swift files using xcrun (i.e. xcrun
…/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -Ounchecked -gnone
example.swift).

But I couldn’t find a way to compile complete xcode projects, that include
UIKit and other imports.

Is it possible to do this?

In the future, I then plan to generate extra output files from the
compilation process.

Thank you very much.

Marcel Rebouças


(Max Howell) #2

So, first, I would like to know if there is a way to compile xcode projects (and all classes within it) using the Swift version that I built from sources.

Hi Marcel,

I actually do this.

What I did is:

1. Make a recursive copy of a xctoolchain.
2. Replace all the parts in that new toolchain with symlinks to the built versions
3. Edit the Info.plist to give the toolchain a unique name

It’s a hack, but currently it is otherwise quite problematic to build your own toolchain. There is a ticket open to make the build-script capable of this however, so hopefully this will be implemented.

Max


(Dmitri Gribenko) #3

build-script can do this. See my last comment in
https://github.com/apple/swift/pull/1267 for an example.

Dmitri

···

On Mon, Feb 22, 2016 at 10:08 AM, Max Howell via swift-users <swift-users@swift.org> wrote:

So, first, I would like to know if there is a way to compile xcode projects
(and all classes within it) using the Swift version that I built from
sources.

Hi Marcel,

I actually do this.

What I did is:

1. Make a recursive copy of a xctoolchain.
2. Replace all the parts in that new toolchain with symlinks to the built
versions
3. Edit the Info.plist to give the toolchain a unique name

It’s a hack, but currently it is otherwise quite problematic to build your
own toolchain. There is a ticket open to make the build-script capable of
this however, so hopefully this will be implemented.

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/


(Marcel Rebouças) #4

Hello Max and Dmitri, thank you very much for the response.

I'll try those steps/commands later tonight. I believe this will work for
me.

···

2016-02-22 15:13 GMT-03:00 Dmitri Gribenko <gribozavr@gmail.com>:

On Mon, Feb 22, 2016 at 10:08 AM, Max Howell via swift-users > <swift-users@swift.org> wrote:
> So, first, I would like to know if there is a way to compile xcode
projects
> (and all classes within it) using the Swift version that I built from
> sources.
>
>
> Hi Marcel,
>
> I actually do this.
>
> What I did is:
>
> 1. Make a recursive copy of a xctoolchain.
> 2. Replace all the parts in that new toolchain with symlinks to the built
> versions
> 3. Edit the Info.plist to give the toolchain a unique name
>
> It’s a hack, but currently it is otherwise quite problematic to build
your
> own toolchain. There is a ticket open to make the build-script capable of
> this however, so hopefully this will be implemented.

build-script can do this. See my last comment in
https://github.com/apple/swift/pull/1267 for an example.

Dmitri

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/


(Ankit Agarwal) #5

You should def look at https://github.com/apple/swift-package-manager
It won't give you UIKit but will give you Foundation etc on OSX and the
opensource Foundation (under active development) on Linux

···

On Mon, Feb 22, 2016 at 10:52 PM, Marcel Rebouças <swift-users@swift.org> wrote:

Hello all,

I’ve been using Swift for some time, and decided to learn deeper about the
language and the source code. I plan to try to modify a version of its
compiler in order to generate some code metrics (e.g. Depth of Inheritance
(DIT)) to the classes of the projects compiled by it. All in all, this is
the first time I am trying doing something like it - first time working in
a open source project -, and I’m lost.

*So, first, I would like to know if there is a way to compile xcode
projects (and all classes within it) using the Swift version that I built
from sources. *

I was able to correctly build Swift on my mac. Cloned the main
repositories, and built using swift/utils/build-script.

I am able to run .swift files using xcrun (i.e. xcrun
…/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -Ounchecked -gnone
example.swift).

But I couldn’t find a way to compile complete xcode projects, that include
UIKit and other imports.

Is it possible to do this?

In the future, I then plan to generate extra output files from the
compilation process.

Thank you very much.

Marcel Rebouças

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

--
Ankit


(Marcel Rebouças) #6

Hello Shawn, thanks for the response.

I believe creating an alternative tool chain and setting up Xcode to use it
would work for me. I didn't thought of it, since at first I thought of
doing it kinda as a third party, only using the console. I'll start looking
on how to do it with the Xcode.

···

2016-02-22 14:46 GMT-03:00 Shawn Erickson <shawnce@gmail.com>:

I believe he is asking how to get Xcode to use a locally built (and
possibly modified) version of swift/compiler. Then using Xcode pointed at
this alternate tools chain to build arbitrary projects that may be using
things from normal Apple frameworks, etc.

I have limit web access at the moment but I believe that is documented on
the org site.

On Mon, Feb 22, 2016 at 9:39 AM Ankit Agarwal via swift-users < > swift-users@swift.org> wrote:

You should def look at https://github.com/apple/swift-package-manager
It won't give you UIKit but will give you Foundation etc on OSX and the
opensource Foundation (under active development) on Linux

On Mon, Feb 22, 2016 at 10:52 PM, Marcel Rebouças <swift-users@swift.org> >> wrote:

Hello all,

I’ve been using Swift for some time, and decided to learn deeper about
the language and the source code. I plan to try to modify a version of its
compiler in order to generate some code metrics (e.g. Depth of Inheritance
(DIT)) to the classes of the projects compiled by it. All in all, this is
the first time I am trying doing something like it - first time working in
a open source project -, and I’m lost.

*So, first, I would like to know if there is a way to compile xcode
projects (and all classes within it) using the Swift version that I built
from sources. *

I was able to correctly build Swift on my mac. Cloned the main
repositories, and built using swift/utils/build-script.

I am able to run .swift files using xcrun (i.e. xcrun
…/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -Ounchecked -gnone
example.swift).

But I couldn’t find a way to compile complete xcode projects, that
include UIKit and other imports.

Is it possible to do this?

In the future, I then plan to generate extra output files from the
compilation process.

Thank you very much.

Marcel Rebouças

_______________________________________________
swift-users mailing list
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


(Shawn Erickson) #7

I believe he is asking how to get Xcode to use a locally built (and
possibly modified) version of swift/compiler. Then using Xcode pointed at
this alternate tools chain to build arbitrary projects that may be using
things from normal Apple frameworks, etc.

I have limit web access at the moment but I believe that is documented on
the org site.

···

On Mon, Feb 22, 2016 at 9:39 AM Ankit Agarwal via swift-users < swift-users@swift.org> wrote:

You should def look at https://github.com/apple/swift-package-manager
It won't give you UIKit but will give you Foundation etc on OSX and the
opensource Foundation (under active development) on Linux

On Mon, Feb 22, 2016 at 10:52 PM, Marcel Rebouças <swift-users@swift.org> > wrote:

Hello all,

I’ve been using Swift for some time, and decided to learn deeper about
the language and the source code. I plan to try to modify a version of its
compiler in order to generate some code metrics (e.g. Depth of Inheritance
(DIT)) to the classes of the projects compiled by it. All in all, this is
the first time I am trying doing something like it - first time working in
a open source project -, and I’m lost.

*So, first, I would like to know if there is a way to compile xcode
projects (and all classes within it) using the Swift version that I built
from sources. *

I was able to correctly build Swift on my mac. Cloned the main
repositories, and built using swift/utils/build-script.

I am able to run .swift files using xcrun (i.e. xcrun
…/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -Ounchecked -gnone
example.swift).

But I couldn’t find a way to compile complete xcode projects, that
include UIKit and other imports.

Is it possible to do this?

In the future, I then plan to generate extra output files from the
compilation process.

Thank you very much.

Marcel Rebouças

_______________________________________________
swift-users mailing list
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