Found an unexpected Mach-O header code: 0x72613c21

After updating to Xcode beta 2 and fixing the new build errors (mostly Foundation and UIKit class functions becoming properties) I'm getting a build error on my main app target:

CopySwiftLibs /Users/davbeck/Library/Developer/Xcode/DerivedData/Engagement-evkgwhedhxhvxvbtbsxvdzuxhben/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/Engagement.app
    cd /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10
    export CODESIGN_ALLOCATE=/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    export DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer
    export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    export SDKROOT=/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk
    builtin-swiftStdLibTool --copy --verbose --sign - --scan-executable /Users/davbeck/Library/Developer/Xcode/DerivedData/Engagement-evkgwhedhxhvxvbtbsxvdzuxhben/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/Engagement.app/Engagement --scan-folder /Users/davbeck/Library/Developer/Xcode/DerivedData/Engagement-evkgwhedhxhvxvbtbsxvdzuxhben/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/Engagement.app/Frameworks --scan-folder /Users/davbeck/Library/Developer/Xcode/DerivedData/Engagement-evkgwhedhxhvxvbtbsxvdzuxhben/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/Engagement.app/PlugIns --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/FLAnimatedImage.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/NYTPhotoViewer.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/TNKRefreshControl.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/TNKImagePickerController.framework --scan-folder /Users/davbeck/Library/Developer/Xcode/DerivedData/Engagement-evkgwhedhxhvxvbtbsxvdzuxhben/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/RealmUI.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/AFNetworking.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/OnePasswordExtension.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/KVOController.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/PhoneNumberKit.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/FMDB.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/TNKFoundation.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/UTIKit.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/CRToast.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/SlackTextViewController.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/FormatterKit.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Crashlytics.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/CacheKit.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/Locksmith.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Fabric.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/JGProgressHUD.framework --scan-folder /Users/davbeck/Library/Developer/Xcode/DerivedData/Engagement-evkgwhedhxhvxvbtbsxvdzuxhben/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/RealmCore.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/Analytics.framework --scan-folder /Users/davbeck/Documents/Development/ACS/Realm/RealmEngagement.iOS10/Carthage/Build/iOS/SocketIOClientSwift.framework --platform iphonesimulator --destination /Users/davbeck/Library/Developer/Xcode/DerivedData/Engagement-evkgwhedhxhvxvbtbsxvdzuxhben/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/Engagement.app/Frameworks --strip-bitcode --resource-destination /Users/davbeck/Library/Developer/Xcode/DerivedData/Engagement-evkgwhedhxhvxvbtbsxvdzuxhben/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/Engagement.app --resource-library libswiftRemoteMirror.dylib
error: Found an unexpected Mach-O header code: 0x72613c21

Oddly it looks to be related to the swift libraries?

Replies

Same here. Could not find a solution yet.


Project using Swift 2.3 by the way.

Yeah, im having the same problem!, hope this is an easy fix

Me too.

I also am having this error. Think this might be a bug in beta 2 for Xcode 8? I am using Swift 3.

Same Probleme here. Also no solution yet sadly.

I am having this problem as well when using CocoaPods.


A PodFile without the below line works. With it, it produces this problem.
pod 'Kanna', git: 'https://github.com/tid-kijyun/Kanna.git', branch: 'swift3.0'

I found this issue at the CocoaPods GitHub repo which offers some workarounds. The Podfile post_install step is working for me.
https://github.com/CocoaPods/CocoaPods/issues/5598

Same Problem here. no solution....😕

Tried removing some frameworks, changing provisioning profiles, no success. Can't build for device nor simulator. When I get some time I'll create a new project and little by little move code into it to try to find out where's the problem.

Just tried with a clean Swift project plus CocoaPods. The problem arises as soon as you add a Swift pod. Pure Objective-C pods are fine, but as soon as there's a Swift pod in the workspace, the unexpected Mach-O error appears.


Possibly some build setting change needed after pod install. Still looking...

Okay, this workaround solve it for me:


https://github.com/CocoaPods/CocoaPods/issues/5598#issuecomment-230662508


Basically you want all targets to be set to not always include Swift libs. Though doing this manually (before I found the above automatic workaround) was a bit 50/50 for me. It worked in some combinations in my thrown together test project, but failed in others, and I couldn't see why. So ... there might be more to it. But for now the above workaround got my proper project compiling and running. YMMV.

If you are using Swift pods, add this to your Podfile:


post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO'
        end
    end
end

Thanks for the suggestion. In our case, when I add that to the Podfile, we're able to get the Pod-generated framework to compile (which was previously failing), but still see the same mach-o issue when the swift libraries are being copied into the host app as the last step in the build process.

In looking for similar issues, I found this forum post, which is a similar error message, but with unexpected code "0x752f2123". The answer there was:


It looks like someone is treating a shell script as a Mach-O executable. 0x752f2123 is ASCII for “u/!#" or, byte reversed, “#!/u”, that is, the sort of thing you’d expect to find at the start of a shell script.


Based on that, an ascii code conversion of "0x752f2123" is "ra<!", which byte reversed would be "!<ar".


This doesn't mean much to me, but maybe it will trigger an idea for someone else.

I got the same error mesage, am not using CocoaPods, and have a build setting Always Embed Swift Standard Libraries = NO. I tried removing Fabric & Crashlytics frameworks and references and can now run without the Mach error.