Swinject crashes swiftc in Xcode 9

Created on 6 Jun 2017  路  21Comments  路  Source: Swinject/Swinject

When building Swinject with Xcode 9, Swinject causes a segmentation fault in swiftc. I know this isn't your fault (the compiler shouldn't crash) but I thought I should mention it here. I've also filed this with Apple as rdar://32589507

To reproduce: Clone the repo as it is right now. Open Swinject.xcodeproj in Xcode 9. Build. Swiftc will have a segmentation fault and die, causing a build failure.

question

Most helpful comment

Changing code in ObjectScope.Standard.swift fixed the issue for me:

screen shot 2017-06-07 at 2 05 40 pm

All 21 comments

@atomicbird, thank you for the radar link, sorry for autocomplete spelling

@atomicbird probably meant for you :)

A redacted version is at http://www.openradar.me/radar?id=6150666519052288 (the original contained details of my project that I can't put on OpenRadar).

Changing code in ObjectScope.Standard.swift fixed the issue for me:

screen shot 2017-06-07 at 2 05 40 pm

Thanks everyone for investigating the issue!!!

Please use swift4 branch for now if you try Swinject with Xcode 9 beta馃挭

Carthage:

github "Swinject/Swinject"

CocoaPods:

pod 'Swinject', :git => 'https://github.com/Swinject/Swinject.git', :branch => 'swift4'

Hi everyone,
It's a little bit confused as this branch works for swift 3.2 but not for swift 4

@andrei-kuzma, please take it easy. I just wondered which one in xcode9, swift4 or swift3-4 was good as the branch name, and picked swift4 for simplicity and not to stick on xcode especially for linux users.

I think we'll support Swift 3 and 4 in swift4 branch. I found some problems to compile the source as Swift 4. I think we can fix the problems with both Swift 3 and 4 supported. If the branch swift4 looks redundant, we can merge the branch to master soon.

@yjm607 Can you create a PR with your solution? It will solve problems for the current master branch.

@kerry Sure will do. It will be my first PR to a pubic project.. Exciting!

Hmm I just realized that I don't have permission to commit to the project... looks like /swift4 branch already has my changes, but if someone else who has permission can open a PR to master that would be great.

@yjm607 You definitely won't be able to commit to the project. You will have to create a pull request. Create a fork. Make changes there. Then create a pull request from your fork to the main repo

@kerry Maybe I'm doing something wrong here... I forked from master, made changes, and tried to push to remote. I get the following error..
screen shot 2017-06-08 at 7 51 33 am

@yjm607 because you are pushing onto the main repo instead of your fork. See the url "https://github.com/Swinject/Swinject/", this should have been "https://github.com/yjm607/Swinject"

Thanks @yjm607 and @kerry for the investigation馃憤 Please check swift4 branch that has the same workaround馃槂

As of today:

Engineering has determined that your bug report (32589507) is a duplicate of 32618754 and will be closed.

No telling when it'll be fixed but it looks like Swinject is handling it nicely.

What about the compatibility of Swinject with branch 'swift4' and SwinjectStoryboard?

Segmentation fault happens when using SwinjectStoryboard and Swinject (swift4 branch). Have anybody investigated that?

That happens if we pass the controller as protocol (ProjectsListViewInputProtocol).

container.storyboardInitCompleted(ProjectsListViewController.self) { (r, controller: ProjectsListViewInputProtocol) in
            let presenter = r.resolve(ProjectsListPresenterProtocol.self, argument: controller)!
            controller.presenter = presenter
}

Is it possible to use SwinjectAutoregistration and satisfy dependencies while using the swift4 branch?
I asked the question (with more details) on stack overflow.

EDIT
By specifying this github repo as the source for the pod, it works fine. [See my answer] (https://stackoverflow.com/a/44825451/873436).

I confirmed Xcode 9 beta 4 resolved the original issue. If you use Xcode 9 beta 4 or later, you can use master with both Xcode 8 and 9 (beta 4).

Swinject 2.1.1 supports both Xcode 8.3 and 9 beta, and both Swift 3 and 4.
https://github.com/Swinject/Swinject/releases/tag/2.1.1

If you use Xcode beta, make sure it is beta 4 or later.

Was this page helpful?
0 / 5 - 0 ratings