PromiseKit: Problem with Archive with Xcode Version 7.3.1 (7D1014)

I am having issues with creating an archive when using PromiseKit with the newest Xcode. When trying to run an archive task I get a following error:

1. While emitting IR SIL function @_TZFE10PromiseKitCSo20NSNotificationCenter4oncefSSCS_19NotificationPromise for 'once' at /Users/mpigulski/Development/PromiseKitArchiveTest/Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+Promise.swift:22:12 Segmentation fault: 11

I have attached a test project that allows to reproduce this: PromiseKitArchiveTest.zip

So to reproduce use Xcode Version 7.3.1 (7D1014):

  • open the project using PromiseKitArchiveTest.xcworkspace
  • go for Product -> Archive

Archive will fail. Help.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 64
  • Comments: 46 (15 by maintainers)

Commits related to this issue

Most upvoted comments

If you’re using Cocoapods, and not using anything in the subspec PromiseKit/Foundation, a less hacky solution (not deleting files, changing repo etc.) is to split up the pods in your Podfile:

pod 'PromiseKit/CorePromise'
pod 'PromiseKit/UIKit'
# etc.

I need the subspec PromiseKit/Foundation. @MikeThomas1 's solution is working for me. But I am using Cocoapods and do not want to adjusting the pods project setting manually. So I just add this script to my podfile and it works fine.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    next unless (target.name == 'PromiseKit')
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
    end
  end
end

Having the same issue after upgrading to 7.3.1 - my project can build correctly but will not archive.

UPDATE: NSNotificationCenter+Promise/AnyPromise files are removed on this branch.

Easy fix for everybody: https://github.com/rad3ks/PromiseKit/tree/bug/415

Use in Podfile:

pod 'PromiseKit',
    :git => 'git@github.com:rad3ks/PromiseKit.git',
    :branch => 'bug/415'

I wonder do we really need

extension NSNotificationCenter {
    public class func _once(name: String) -> NotificationPromise
}

?

Unfortunately I haven’t had extensive time to research this today, though I am giving it as much time as I can. More than likely though this is simply a swift bug. And although there may be a way we can work around it in our code, it might be simpler to just revert to the prior version of Xcode for the time being or, if you’re not using it, remove the NSNotificationCenter+Promise.swift file. In the meantime I will continue looking for a solution.

@hiromi2424 My code is here: https://gist.github.com/mnespor/be0d60bfefc04e54608b3cf67cbf0c43. To be clear, this is an exploration of the problem, not a fix—it breaks anything that uses the NSNotificationCenter extension.

Another work around is to simply remove NSNotificationCenter+Promise.swift from the PromiseKit target. There is no need to edit the file itself or remove the file at all. Just uncheck it’s target membership status.

Assuming you don’t need that category, here’s a post_install step for your Podfile that doesn’t require switching to a fork:

post_install do |installer|
    filename = 'Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+Promise.swift'
    contents = '// This file removed due to Swift compiler bug https://bugs.swift.org/browse/SR-1427\n'\
               '// PromiseKit tracking of this issue: https://github.com/mxcl/PromiseKit/issues/415\n'
    system("chmod +w #{filename}; printf \"#{contents}\" > #{filename}; chmod -w #{filename}")
end

Sorry if there’s a more standard way than dropping to bash, I’m not an expert in CocoaPods internals or Ruby for that matter.

yes I just test it and it works thanks!

It doesn’t make a lot of sense to have it IMHO. Notifications are inherently multi-fire things but Promises aren’t.

I wonder do we really need

extension NSNotificationCenter {
    public class func once(name: String) -> NotificationPromise
}

I wish I hadn’t added it considering this bug. But sadly we can’t remove it without breaking API compat. OTOH Swift makes keeping long-term major semantic versions near-impossible (considering bugs and regular syntax changes) so maybe we should just drop it and bump to 4.

NOTE THIS MEANS A PREMATURE BUMP TO PMK4

The problem is also with CLLocationManager+Promise.swift

Another temporary fix if you dont use the particular class NSNotificationCenter+Promise.swift , I commented it in a fork : https://github.com/philippeauriach/PromiseKit/tree/fix-archive-xcode-7 You can use it with cocoapod : pod 'PromiseKit', :git => 'https://github.com/philippeauriach/PromiseKit.git', :commit => '266cfeb5073277b757efc4a37aa049efc96c596f'

Alright, I think we’re good now. 3.2.1 has the fix and is live on the Cocoapods trunk. If you updated to 3.2.1 yesterday you may need to pod cache clean PromiseKit and pod install again.

Again, apologies to all and thanks for bearing with us.

Seems like a new bug in Swift’s type inference? Changing public class NotificationPromise: Promise<[NSObject: AnyObject]> to public class NotificationPromise<T>: Promise<T> prevents the segmentation fault

Looking at https://bugs.swift.org/browse/SR-1427, this was first reported 8 days ago. I suspect that reverting to Xcode 7.3 for now will fix.