kylef / heroku-buildpack-swift

Heroku build pack for Swift
BSD 3-Clause "New" or "Revised" License
508 stars 0 forks source link

Get different swift errors on heroku than local #34

Closed tettoffensive closed 6 years ago

tettoffensive commented 6 years ago

I'm not too sure how to make sure I'm compiling with the same version of swift that I am with swift build or Xcode as I am on heroku.

I'm often getting errors on heroku that I don't get locally.

For example these are errors that I get on heroku, when my code compiles fine locally:

/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Configuration/DiskConfig.swift:19:31: error: use of undeclared type 'FileProtectionType'
              protectionType: FileProtectionType? = nil) {
                              ^~~~~~~~~~~~~~~~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Configuration/DiskConfig.swift:15:30: error: use of undeclared type 'FileProtectionType'
  public let protectionType: FileProtectionType?
                             ^~~~~~~~~~~~~~~~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/AsyncStorage.swift:7:27: error: use of undeclared type 'DispatchQueue'
  public let serialQueue: DispatchQueue
                          ^~~~~~~~~~~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/AsyncStorage.swift:9:44: error: use of undeclared type 'DispatchQueue'
  init(storage: StorageAware, serialQueue: DispatchQueue) {
                                           ^~~~~~~~~~~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/AsyncStorageAware.swift:6:20: error: use of undeclared type 'DispatchQueue'
  var serialQueue: DispatchQueue { get }
                   ^~~~~~~~~~~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/AsyncStorageAware.swift:6:20: error: use of undeclared type 'DispatchQueue'
  var serialQueue: DispatchQueue { get }
                   ^~~~~~~~~~~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/DiskStorage.swift:72:17: warning: result of call to 'createFile(atPath:contents:attributes:)' is unused
    fileManager.createFile(atPath: filePath, contents: data, attributes: nil)
                ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/DiskStorage.swift:107:33: error: cannot convert value of type 'URL' to type 'NSURL' in coercion
      let resourceValues = try (url as NSURL).resourceValues(forKeys: resourceKeys)
                                ^~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/DiskStorage.swift:169:23: error: cannot convert value of type 'String' to type 'NSString' in coercion
      let filePath = (path as NSString).appendingPathComponent(pathComponent)
                      ^~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/MemoryStorage.swift:23:46: error: cannot convert value of type 'String' to type 'NSString' in coercion
    guard let capsule = cache.object(forKey: key as NSString) else {
                                             ^~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/MemoryStorage.swift:35:32: error: cannot convert value of type 'String' to type 'NSString' in coercion
    cache.removeObject(forKey: key as NSString)
                               ^~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/MemoryStorage.swift:41:38: error: cannot convert value of type 'String' to type 'NSString' in coercion
    cache.setObject(capsule, forKey: key as NSString)
                                     ^~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/MemoryStorage.swift:64:43: error: cannot convert value of type 'String' to type 'NSString' in coercion
    if let capsule = cache.object(forKey: key as NSString), capsule.expiry.isExpired {
                                          ^~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/Storage.swift:40:67: error: use of unresolved identifier 'DispatchQueue'
                                                     serialQueue: DispatchQueue(label: "Cache.AsyncStorage.SerialQueue"))
                                                                  ^~~~~~~~~~~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/Storage.swift:35:42: error: use of unresolved identifier 'DispatchQueue'
                            serialQueue: DispatchQueue(label: "Cache.SyncStorage.SerialQueue"))
                                         ^~~~~~~~~~~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/SyncStorage.swift:7:32: error: use of undeclared type 'DispatchQueue'
  fileprivate let serialQueue: DispatchQueue
                               ^~~~~~~~~~~~~
/app/tmp/cache/.build/checkouts/Cache.git-8536391383938420078/Source/Shared/Storage/SyncStorage.swift:9:44: error: use of undeclared type 'DispatchQueue'
  init(storage: StorageAware, serialQueue: DispatchQueue) {
                                           ^~~~~~~~~~~~~
error: terminated(1): /app/tmp/cache/swiftenv/versions/4.0/usr/bin/swift-build-tool -f /app/tmp/cache/.build/release.yaml main
tettoffensive commented 6 years ago

I needed to put import Dispatch in all the places where DispatchQueue was used in the library Cache that I included.

FileProtectionType doesn't appear to be implemented yet (11-28-2017) on ubuntu so I put guards around that for now.

Other errors like coercion such as url as NSURL and string as NSString errored also, so I had to find work arounds for those.

It's quite a laborious process to get all the errors solved when your dev env is osx.