Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build target missing ObjectivePGP framework (dyld: Library not loaded) #247

Closed
davidjb opened this issue Feb 26, 2019 · 5 comments
Closed

Comments

@davidjb
Copy link
Contributor

davidjb commented Feb 26, 2019

Attempting to build passforios for the first time, following the build instructions, the compilation works and the app starts up on the simulator, but crashes immediately with:

dyld: Library not loaded: @rpath/ObjectivePGP.framework/ObjectivePGP
  Referenced from: /Users/user/Library/Developer/CoreSimulator/Devices/[snip]/data/Containers/Bundle/Application/[snip]/pass.app/pass
  Reason: image not found

Looking into why, when pod install is run, the Cocoapods Embed Pods Frameworks object gets removed from the pass.xcodeproj/project.pbxproj file. Without this present, the ObjectivePGP pod is presumably unknown to Xcode and thus isn't linked in. I could manually add in the ObjectivePGP.framework into the target's General settings in Xcode and that would work but that would be working around the actual problem.

Here's what my .pbxproj file looks immediately after running pod install -- this is a fresh clone after running the carthage commands and pod install, before even opening the workspace in Xcode:

diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj
index 63acbc4..2536e5a 100644
--- a/pass.xcodeproj/project.pbxproj
+++ b/pass.xcodeproj/project.pbxproj
@@ -814,7 +814,6 @@
                                A260757C1EEC6F34005DB03E /* Sources */,
                                A260757D1EEC6F34005DB03E /* Frameworks */,
                                A260757E1EEC6F34005DB03E /* Resources */,
-                               6AEAED0AF4328940B21EAC44 /* [CP] Embed Pods Frameworks */,
                        );
                        buildRules = (
                        );
@@ -874,7 +873,6 @@
                                DC917BEC1E2F3659000FDF54 /* Run Script */,
                                A26700191EEC450100176B8A /* Embed App Extensions */,
                                A26075921EEC6F34005DB03E /* Embed Frameworks */,
-                               7F5ED3FD24ED627DC957D425 /* [CP] Embed Pods Frameworks */,
                        );
                        buildRules = (
                        );
@@ -1067,26 +1065,6 @@
                        shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n    # print error to STDERR\n    echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n    exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
                        showEnvVarsInLog = 0;
                };
-               6AEAED0AF4328940B21EAC44 /* [CP] Embed Pods Frameworks */ = {
-                       isa = PBXShellScriptBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                       );
-                       inputPaths = (
-                               "${SRCROOT}/Pods/Target Support Files/Pods-passKitTests/Pods-passKitTests-frameworks.sh",
-                               "${PODS_ROOT}/ObjectivePGP/Frameworks/ios/ObjectivePGP.framework",
-                               "${PODS_ROOT}/ObjectivePGP/Frameworks/ios/ObjectivePGP.framework.dSYM",
-                       );
-                       name = "[CP] Embed Pods Frameworks";
-                       outputPaths = (
-                               "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectivePGP.framework",
-                               "${DWARF_DSYM_FOLDER_PATH}/ObjectivePGP.framework.dSYM",
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-                       shellPath = /bin/sh;
-                       shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-passKitTests/Pods-passKitTests-frameworks.sh\"\n";
-                       showEnvVarsInLog = 0;
-               };
                736C6F64F90A20CB9A00B420 /* [CP] Check Pods Manifest.lock */ = {
                        isa = PBXShellScriptBuildPhase;
                        buildActionMask = 2147483647;
@@ -1105,26 +1085,6 @@
                        shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n    # print error to STDERR\n    echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n    exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
                        showEnvVarsInLog = 0;
                };
-               7F5ED3FD24ED627DC957D425 /* [CP] Embed Pods Frameworks */ = {
-                       isa = PBXShellScriptBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                       );
-                       inputPaths = (
-                               "${SRCROOT}/Pods/Target Support Files/Pods-pass/Pods-pass-frameworks.sh",
-                               "${PODS_ROOT}/ObjectivePGP/Frameworks/ios/ObjectivePGP.framework",
-                               "${PODS_ROOT}/ObjectivePGP/Frameworks/ios/ObjectivePGP.framework.dSYM",
-                       );
-                       name = "[CP] Embed Pods Frameworks";
-                       outputPaths = (
-                               "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectivePGP.framework",
-                               "${DWARF_DSYM_FOLDER_PATH}/ObjectivePGP.framework.dSYM",
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-                       shellPath = /bin/sh;
-                       shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-pass/Pods-pass-frameworks.sh\"\n";
-                       showEnvVarsInLog = 0;
-               };
                94AA4FCF7FF3474A970BE194 /* [CP] Check Pods Manifest.lock */ = {
                        isa = PBXShellScriptBuildPhase;
                        buildActionMask = 2147483647;

I'm not familiar with the internals of Cocoapods but is this expected behaviour? I'm using v1.6.1 of Cocoapods. Attempting a pod deintegrate && pod install made no difference, just regenerating a bunch of other references in the .pbxproj file but still the Embed Pods Frameworks references get deleted.

@davidjb davidjb changed the title Build target missing ObjectivePGP framework (dyld: Library not loaded: @rpath/ObjectivePGP.framework/ObjectivePGP) Build target missing ObjectivePGP framework (dyld: Library not loaded) Feb 26, 2019
@mssun
Copy link
Owner

mssun commented Mar 23, 2019

Hi @davidjb , is this issue still valid? I cannot reproduce this problem on my machine.

@davidjb
Copy link
Contributor Author

davidjb commented Mar 23, 2019

@mssun Yes, still an issue. For me to be able to build this project, I have to manually link in the ObjectivePGP pods after the Embed Pods Frameworks references get stripped out with pod install. What version of Cocoapods are you on?

@mssun
Copy link
Owner

mssun commented Mar 23, 2019

My pod version is 1.6.1. Also, Travis CI can compile the project (https://github.com/mssun/passforios/blob/master/.travis.yml) every time.

@davidjb
Copy link
Contributor Author

davidjb commented Mar 23, 2019

Interesting, so same versions of pod. Fwiw, the same issue occurs for me with 1.7.0.beta.2 (latest pre-release version).

Doing a bit of debugging around in cocoapod's source shows the build phase gets removed here: https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/installer/user_project_integrator/target_integrator.rb#L457-L462

In short, for the pass target, cocoapods considers there to be no frameworks to be embedded into this target (eg includes_frameworks returns false) and hence removes that section of of the .pbxproj file. For passKit, however, pod considers this to be true. Seems that the return value of includes_frameworks becomes true if you manually copy the pod 'ObjectivePGP' ... line under the target 'pass' section and re-run pod install -- so for some reason, pod is applying different behaviour to the parent target than the children.

Perhaps we can compare pod env results and determine a difference. Here's mine:

Stack

   CocoaPods : 1.6.1
        Ruby : ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
    RubyGems : 2.5.2.3
        Host : Mac OS X 10.14.3 (18D109)
       Xcode : 10.1 (10B61)
         Git : git version 2.17.0
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ c91ddad3634ed64208b9ecd498a8b9321e83401b

Installation Source

Executable Path: /usr/local/Cellar/cocoapods/1.6.1/libexec/bin/pod

Plugins

cocoapods-deintegrate : 1.0.3
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.3.1
cocoapods-try         : 1.1.0

Podfile

platform :ios, '10.2'
use_frameworks!

target 'passKit' do
    pod 'ObjectivePGP', :git => 'https://github.com/krzyzanowskim/ObjectivePGP.git', :tag => '0.13.0'
    target 'pass' do
        inherit! :search_paths
    end
    target 'passExtension' do
        inherit! :search_paths
    end
    target 'passKitTests' do
        inherit! :search_paths
    end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      cflags = config.build_settings['OTHER_CFLAGS'] || ['$(inherited)']
      cflags << '-fembed-bitcode'
      config.build_settings['OTHER_CFLAGS'] = cflags
    end
  end
end

@yishilin14
Copy link
Collaborator

@mssun If you delete ./Pods and do pod install again, you will see this error.

I found CocoaPods/CocoaPods#8664. Seems like It is a bug in cocoapods >=v1.6.0.

I have switched back to pod v1.5.3 now. Also, I updated .travis.yml so that fastlane test could pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants