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:
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;
},
I was experiencing this issue in Xcode 10.1 recently and all my frameworks were referenced correctly. Seems there were some changes in the apple validation process, may be a bug, may not be on Apple's end, but all my prior builds uploaded and validated fine -- and I did not add any new frameworks since.
Upon uploading the binary to iTunesConnect, I'd see the following error:
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
Invalid Bundle - The app uses Swift, but one of the binaries could not link to it because it wasn't found. Check that the app bundles correctly embed Swift standard libraries using the "Always Embed Swift Standard Libraries" build setting, and that each binary which uses Swift has correct search paths to the embedded Swift standard libraries using the "Runpath Search Paths" build setting.
SOLUTION: After days of debugging, what worked for me was to disable 'Include bitcode for iOS content' upon uploading the archive from Xcode organizer. Seems that this option modifies the binary which caused the validator to fail.
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.
I wanted to elaborate on my experience with this issue to hopefully save someone else some time if they run into this.
Background:
@xaphod had missing libraries, when I ran the otool -L
all libraries looked correct in each of the targets.
After many rejected binaries I finally:
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
Main App Target=$(inherited)
per Cocoa pods warning suggest. This defaults to YES
and is actually displayed as YES - $(inherited)
in Xcode. Lastly, EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
per pod settings which pods do for you
Watch App=YES
Watch Extension=NO
Today Extension=NO
Before the above settings, I attempted $(inherited)
for everything to make cocoa pods happy. This clearly was a poor life decision.
I finally found attempting to export as AD HOC
would fail if the binary wasn't going to be accepted by iTunes Connect, so I could save time testing theories before throwing the build at Apple.
I attempted to compare a successful binary with a failing one but really didn't see anything in particular that stood out to me on the difference.
I still don't feel 100% comfortable with how I got this working but happy I could finally upload a binary. Cheers and good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With