Invalid Bundle error from iTC, cannot submit app - because 4 swift dylibs fail to embed

Pretty desperate, because my app is broken on iOS 10 and I can't submit the fix because itunes connect keeps rejecting the build.


My app runs fine on devices & simulators, but when I submit it, I get the Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search patherror emailed to me about half an hour after the upload completes successfully.


Following the advice on this thead here, namely running

otool -L
, I can see that the app's main executable has all of its
@rpath/...dylib
files in the
Frameworks/
folder as expected, but, the appex's executable is missing some Swift libs.


Here's the output from

otool -L
on the appex:


Watch Extension:
    /System/Library/Frameworks/WatchKit.framework/WatchKit (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1349.0.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation (compatibility version 150.0.0, current version 1348.0.0)
    /System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 3599.4.0)
    /System/Library/Frameworks/WatchConnectivity.framework/WatchConnectivity (compatibility version 1.0.0, current version 116.0.0)
    @rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftCoreLocation.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftDarwin.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftDispatch.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftFoundation.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftHomeKit.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftSceneKit.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftUIKit.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftWatchKit.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftsimd.dylib (compatibility version 1.0.0, current version 800.0.46)


The following are NOT in the

Frameworks/
folder (but all the others are):


    @rpath/libswiftHomeKit.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftSceneKit.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftWatchKit.dylib (compatibility version 1.0.0, current version 800.0.46)
    @rpath/libswiftsimd.dylib (compatibility version 1.0.0, current version 800.0.46)


Why are these swift dylibs missing? I regenerated my pods project via

pod install
, didn't change anything. I didn't see any warnings. I checked the build (archive)'s log output, no warnings there either. How can I get these included like they should be?

In my main app's target, Always Embed Swift Standard Libraries is set to yes. In Watch and Watch Appex targets, this is set to no to avoid the rejection for having duplicates (good). I tried setting

EMBEDDED_CONTENT_CONTAINS_SWIFT
to yes in my appex as described in that other thread, but that didn't make any difference.

Accepted Reply

It took 12 hours to figure this out, but this is what fixed it -- changing the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES build setting like this:


App target (main target) -- set to NO (mine was YES)

Watch target -- set to YES (mine was NO)

Watch App Extension target -- set to NO (mine was YES)

Replies

Also, I cannot export to an ADHOC build from xcode for the same reason. It fails on the comiling from bitcode step.

Here are some snippets, anyone know how to fix these? I checked that my runtime search paths include executable_path/frameworks, loader_path/frameworks, inherited etc... all of those were already there


  Debug: Search Path: ['/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin', '/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/usr/lib', '/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks']
    error: libswiftCore.dylib not found in dylib search path


2016-09-14 15:33:40 +0000  /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool exited with 1
2016-09-14 15:33:40 +0000  ipatool JSON: {
    alerts =     (
                {
            code = 2554;
            description = "Configuration issue: platform AppleTVSimulator.platform doesn't have any non-simulator SDKs; ignoring it";
            info =             {
            };
            level = WARN;
        },
                {
            code = 2554;
            description = "Configuration issue: platform iPhoneSimulator.platform doesn't have any non-simulator SDKs; ignoring it";
            info =             {
            };
            level = WARN;
        },
                {
            code = 2554;
            description = "Configuration issue: platform WatchSimulator.platform doesn't have any non-simulator SDKs; ignoring it";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftCore.dylib: Could not find image to link for armv7k in /private/var/folders/yl/mw_r1p4j3vj2mfp32rqs0y7r0000gn/T/XcodeDistPipeline.6Tu/Root/Payload/Photobooth.app/Frameworks/libswiftCore.dylib";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftCoreGraphics.dylib: Could not find image to link for armv7k in /private/var/folders/yl/mw_r1p4j3vj2mfp32rqs0y7r0000gn/T/XcodeDistPipeline.6Tu/Root/Payload/Photobooth.app/Frameworks/libswiftCoreGraphics.dylib";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftCoreLocation.dylib: Could not find image to link for armv7k in /private/var/folders/yl/mw_r1p4j3vj2mfp32rqs0y7r0000gn/T/XcodeDistPipeline.6Tu/Root/Payload/Photobooth.app/Frameworks/libswiftCoreLocation.dylib";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftDarwin.dylib: Could not find image to link for armv7k in /private/var/folders/yl/mw_r1p4j3vj2mfp32rqs0y7r0000gn/T/XcodeDistPipeline.6Tu/Root/Payload/Photobooth.app/Frameworks/libswiftDarwin.dylib";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftDispatch.dylib: Could not find image to link for armv7k in /private/var/folders/yl/mw_r1p4j3vj2mfp32rqs0y7r0000gn/T/XcodeDistPipeline.6Tu/Root/Payload/Photobooth.app/Frameworks/libswiftDispatch.dylib";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftFoundation.dylib: Could not find image to link for armv7k in /private/var/folders/yl/mw_r1p4j3vj2mfp32rqs0y7r0000gn/T/XcodeDistPipeline.6Tu/Root/Payload/Photobooth.app/Frameworks/libswiftFoundation.dylib";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftHomeKit.dylib: Could not resolve @rpath in @rpath/libswiftHomeKit.dylib from Watch Extension";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftObjectiveC.dylib: Could not find image to link for armv7k in /private/var/folders/yl/mw_r1p4j3vj2mfp32rqs0y7r0000gn/T/XcodeDistPipeline.6Tu/Root/Payload/Photobooth.app/Frameworks/libswiftObjectiveC.dylib";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftSceneKit.dylib: Could not resolve @rpath in @rpath/libswiftSceneKit.dylib from Watch Extension";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftUIKit.dylib: Could not find image to link for armv7k in /private/var/folders/yl/mw_r1p4j3vj2mfp32rqs0y7r0000gn/T/XcodeDistPipeline.6Tu/Root/Payload/Photobooth.app/Frameworks/libswiftUIKit.dylib";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftWatchKit.dylib: Could not resolve @rpath in @rpath/libswiftWatchKit.dylib from Watch Extension";
            info =             {
            };
            level = WARN;
        },
                {
            code = 284;
            description = "Failed to resolve linkage dependency Watch Extension armv7k -> @rpath/libswiftsimd.dylib: Could not resolve @rpath in @rpath/libswiftsimd.dylib from Watch Extension";
            info =             {
            };
            level = WARN;
        },

It took 12 hours to figure this out, but this is what fixed it -- changing the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES build setting like this:


App target (main target) -- set to NO (mine was YES)

Watch target -- set to YES (mine was NO)

Watch App Extension target -- set to NO (mine was YES)