Search code examples
iosswiftxcodeswift3alamofire

Can't build project with Alamofire 4.1.0, Xcode 8, and Swift 3 - no such file or directory


I have an iOS project that I haven't updated in almost a year, but now I need to add a feature. After working through the normal headaches of having to update Swift (since I have updated Xcode in the meantime), I have one remaining problem that seems to have to do with Alamofire not wanting to build with the following error (no such file or directory):

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/David/Library/Developer/Xcode/DerivedData/Dealer_Dashboard-darqlvvgqwnvdybcswbtllluwvjw/Build/Intermediates/Dealer\ Dashboard.build/Debug-iphonesimulator/Dealer\ Dashboard.build/Script-210B7DE0B605AB4E3AA431FD.sh
    cd "/Users/David/Documents/TC-Dev/Dealer Dashboard"
    /bin/sh -c \"/Users/David/Library/Developer/Xcode/DerivedData/Dealer_Dashboard-darqlvvgqwnvdybcswbtllluwvjw/Build/Intermediates/Dealer\ Dashboard.build/Debug-iphonesimulator/Dealer\ Dashboard.build/Script-210B7DE0B605AB4E3AA431FD.sh\"

mkdir -p /Users/David/Library/Developer/Xcode/DerivedData/Dealer_Dashboard-darqlvvgqwnvdybcswbtllluwvjw/Build/Products/Debug-iphonesimulator/Dealer Dashboard.app/Frameworks
rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "/Users/David/Library/Developer/Xcode/DerivedData/Dealer_Dashboard-darqlvvgqwnvdybcswbtllluwvjw/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework" "/Users/David/Library/Developer/Xcode/DerivedData/Dealer_Dashboard-darqlvvgqwnvdybcswbtllluwvjw/Build/Products/Debug-iphonesimulator/Dealer Dashboard.app/Frameworks"
building file list ... done

sent 196 bytes  received 20 bytes  432.00 bytes/sec
total size is 1965425  speedup is 9099.19
Code Signing /Users/David/Library/Developer/Xcode/DerivedData/Dealer_Dashboard-darqlvvgqwnvdybcswbtllluwvjw/Build/Products/Debug-iphonesimulator/Dealer Dashboard.app/Frameworks/Alamofire.framework with Identity -
/usr/bin/codesign --force --sign -  --preserve-metadata=identifier,entitlements /Users/David/Library/Developer/Xcode/DerivedData/Dealer_Dashboard-darqlvvgqwnvdybcswbtllluwvjw/Build/Products/Debug-iphonesimulator/Dealer Dashboard.app/Frameworks/Alamofire.framework
/Users/David/Library/Developer/Xcode/DerivedData/Dealer_Dashboard-darqlvvgqwnvdybcswbtllluwvjw/Build/Products/Debug-iphonesimulator/Dealer: No such file or directory

If I manually create the directory "Dealer", it gets past that error and I get a new one that is similar. My project is named "Dealer Dashboard" (with a space), and as you may notice, this and all of the other failing paths seem to get truncated at the space, so I did a search and found this issue, which seems to have been resolved over a year ago (but maybe it resurfaced in this version?) https://github.com/CocoaPods/CocoaPods/issues/3754 It looks like it's creating a valid directory, but then trying to sign code that's in an invalid/truncated version of that directory. Everything worked fine when I was working with Swift 2.2 and an older version of Alamofire.

What I have tried: I have updated Xcode as of today, I have updated CocoaPods to version 1.2.0.beta.1 and removed all other versions, I have updated my podfile and run pod setup and pod update and I am now on Alamofire 4.1.0 and SwiftyJSON 3.0.0 (according to podfile.lock). I have deleted everything from DerivedData multiple times and emptied the trash and cleaned the solution and restarted Xcode and the computer in various orders, and have not had any luck. I have seen many other links to similar problems, but none of the answers seem to work in my case.

Is this a bug in AlamoFire related to the space in my project name, or can somebody else recommend something to try? If it is a bug, the link I posted recommends a "sneaky" workaround that links to a huge podfile, but 98% of my development time is spent in Windows and .Net, and I cannot see through all of the unrelated code and settings to figure out what they are really trying to get me to do... it looks like it has to do with "def predictabilize_uuids", but I have no idea what that means or does, or which lines of code I need to move over to my project to implement it. I suspect that I am too late to rename my project so that it doesn't contain a space, since it's already in the App Store and I need to push this as an update, so I need to find a solution or workaround. Any help would be appreciated!


Solution

  • One of the comments by freak4pc in this post helped me: https://github.com/CocoaPods/CocoaPods/issues/3754

    In the file tree in Xcode, expand "Pods", expand "Targets Support Files", expand "Pods-[Project Name]", and edit "Pods-[Project Name]-frameworks.sh. Look for the section that deals with framework signing. change the following line:

    local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1""
    

    to this: (add single quotes around the "$1" at the end)

    local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '"$1"'"
    

    Clean the project and build again - in my case it worked as expected.