Shopify / mobile-buy-sdk-ios

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.
MIT License
453 stars 198 forks source link

Cannot import Buy or Pay in Xcode 9.3 #842

Closed ajneuses closed 6 years ago

ajneuses commented 6 years ago

I'm using the mobile-buy-sdk-ios for an iOS project. With the update to Swift 4.1, I get the following error when importing Buy and Pay:

image

I run "carthage bootstrap --platform ios" on the terminal in my project directory and the version it checks out is 3.1.5.

      *** Checking out mobile-buy-sdk-ios at "3.1.5"

After the other dependencies build, Pay in Buy.xcodeproj fails

     *** Building scheme "Buy" in Buy.xcodeproj
     *** Building scheme "Pay" in Buy.xcodeproj
     Build Failed
          Task failed with exit code 65:

I looked in the log file at the specific error:

.../Carthage/Checkouts/mobile-buy-sdk-ios/Pay/PassKit+PayCardBrand.swift:55:16: error: value of type 'Array' has no member 'compactMap' return self.compactMap { ^~ ~~~~

ARCHIVE FAILED

The following build commands failed: CompileSwift normal armv7 CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler CompileSwift normal arm64 CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (4 failures)

This looks like an update made a little over a week ago to the code. Is this a compatibility issue with Swift 4.1? Should I revert my project to Swift 4.0.3? Can I (my Xcode version is 9.3)? Am I doing something wrong here?

dbart01 commented 6 years ago

I suspect what's happening here is that you have some "left over" artifacts from pre-Xcode 9.3 days. Try doing a full clean (clean build folder, as well, removing Carthage cached builds, etc. Then try rebuilding. compactMap is available starting in Swift 4.1 so if it's complaining that Array doesn't have it, maybe you're trying to build with the old tools (Swift 4.0)? Just double check that all your project / build settings are on Swift 4.1.

ajneuses commented 6 years ago

Thanks for the suggestion, I was able to resolve this issue after a few more unsuccessful cleans and rebuilds when I decided to try deleting and reinstalling everything. I found that I still had the Xcode 9.2 beta installed on my machine (this turned out to be the problem) so I got rid of that too. After deleting and reinstalling Xcode and deleting Carthage, I wasn't able to reinstall it with homebrew because the active developer path for xcrun was: /Applications/Xcode-beta.app/Contents/Developer.

Once I changed this to: /Applications/Xcode.app/Contents/Developer I was able to get the newest version of the framework and my project builds.

Sorry for all the info, I figured someone could use it if they run into a similar issue.