google / promises

Promises is a modern framework that provides a synchronization construct for Swift and Objective-C.
Apache License 2.0
3.8k stars 294 forks source link

Changed "Runpath Search Paths" build setting to @executable_path/Frameworks #96

Closed nzhuk closed 5 years ago

nzhuk commented 5 years ago

The previous value - $(TOOLCHAIN_DIR)/usr/lib/swift/macosx - caused the built framework binary to have the following otool -l output:

Load command 24
          cmd LC_RPATH
      cmdsize 112
         path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx (offset 12)

This caused errors during binary upload to the app store. In particular, App Store Connect sent an e-mail with the following error message:

Dear Developer,

We identified one or more issues with a recent delivery for your app, "TheApp". Please correct the following issues, then upload again.

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.

This same error can be also seen by making Xcode archive export while having app thinning and bitcode compilation enabled:

$ cat export_options.plist 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>method</key>
    <string>development</string>
    <key>thinning</key>
    <string>iPhone7,1</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>xxx</key>
        <string>yyy</string>
    </dict>
</dict>
</plist>
xcodebuild -exportArchive -exportOptionsPlist  export_options.plist  -archivePath /path/to/archive.xcarchive  -exportPath exported-archive

Output:

error: exportArchive: ipatool failed with an exception: #<CmdSpec::NonZeroExcitException: Command exited with pid 55583 exit 1:
/Applications/Xcode.app/Contents/Developer/usr/bin/bitcode-build-tool -v -t /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin -L /var/folders/zj/sn8dz1wx4y7c03lc6tvd4zd00000gn/T/ipatool20190215-54450-15zcqlz/thinned-out/armv7/Payload/StandaloneApp.app/Frameworks/FBLPromises.framework --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk -o /var/folders/zj/sn8dz1wx4y7c03lc6tvd4zd00000gn/T/ipatool20190215-54450-15zcqlz/thinned-out/armv7/Payload/StandaloneApp.app/Frameworks/Promises.framework/Promises --generate-dsym /var/folders/zj/sn8dz1wx4y7c03lc6tvd4zd00000gn/T/ipatool20190215-54450-15zcqlz/thinned-out/armv7/Payload/StandaloneApp.app/Frameworks/Promises.framework/Promises.dSYM --strip-swift-symbols /var/folders/zj/sn8dz1wx4y7c03lc6tvd4zd00000gn/T/ipatool20190215-54450-15zcqlz/thinned-in/armv7/Payload/StandaloneApp.app/Frameworks/Promises.framework/Promises

I contacted Apple through DTS program, and their recommendation was to use @executable_path/Frameworks as value for the Runpath Search Paths build setting.

googlebot commented 5 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

Googlers can find more info about SignCLA and this PR by following this link.

nzhuk commented 5 years ago

I signed it!

ghost commented 5 years ago

Hi Nikita, Thank you for the PR! Do you mind adding the following for each target in the xcodeproj to ensure that everything works for iOS, watchOS, tvOS, and macOS?

LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";

It appears that iOS, watchOS, and tvOS use @executable_path/Frameworks; whereas, macOS uses @executable_path/../Frameworks.

Thank you!

ghost commented 5 years ago

Thank you for the update!

nzhuk commented 5 years ago

My pleasure. Thanks for great framework!