xaphod xaphod - 4 days ago 4
Swift Question

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

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 path error 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 is this? 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.

Update 1 - I also cannot export as an ADHOC build from xcode organizer, it fails for the same reason on the "compile bitcode" step. Runtime search paths are set like this:

Runtime search paths in build settings

Here is a log snippet from the failed export, any ideas how to fix these? I see no reason why these libs are missing.

Debug: Command took 0 seconds
Debug: Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks/WatchKit.framework/WatchKit.tbd
Debug: Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks/Foundation.framework/Foundation.tbd
Debug: Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/usr/lib/libobjc.A.tbd
Debug: Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/usr/lib/libSystem.B.tbd
Debug: Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd
Debug: Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks/UIKit.framework/UIKit.tbd
Debug: Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks/WatchConnectivity.framework/WatchConnectivity.tbd
Debug: Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/usr/lib/libobjc.A.tbd
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


Stderr:
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1974:in `block in CompileOrStripBitcodeInBundle'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1931:in `each'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1931:in `CompileOrStripBitcodeInBundle'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1921:in `block in CompileOrStripBitcodeInBundle'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1920:in `each'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1920:in `CompileOrStripBitcodeInBundle'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2106:in `ProcessIPA'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2674:in `<main>'
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;
},

Answer

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)

Edit: I figured this out by creating a new, empty watch project in xcode 8, and cross-referencing the differences between build-settings in the new xcode 8 template project, and my crusty old ancient project. The settings above are what the xcode 8 template project has.

Comments