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

Add aggregated search paths targets to vendored build settings #5514

Closed
wants to merge 4 commits into from
Closed

Add aggregated search paths targets to vendored build settings #5514

wants to merge 4 commits into from

Conversation

plu
Copy link
Contributor

@plu plu commented Jun 13, 2016

Fix #5512

I assume this will break some tests. Before fixing/adapting them I'd like to see your approval that this is the correct fix :).

@@ -150,7 +150,9 @@ def generate_settings_to_import_pod_targets
# user target.
#
def generate_vendored_build_settings
pod_targets.each do |pod_target|
targets = pod_targets + target.search_paths_aggregate_targets.map(&:pod_targets)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use flat_map

@segiddins
Copy link
Member

@mrackwitz looks good to me, seem good to you too?

@plu
Copy link
Contributor Author

plu commented Jun 14, 2016

I'll have a look at the failing tests in the meantime.

@plu
Copy link
Contributor Author

plu commented Jun 14, 2016

I'm using Rainforest locally, but I have a list of failures on master:

-    - '[CP] Check Pods Manifest.lock': []
+    - "[CP] Check Pods Manifest.lock": []

Do you have any hint for me where this might be coming from?

@endocrimes
Copy link
Member

@plu Those should pass if you rebase on master, tests on Ruby >= 2.3 were fixed in #4687

@plu
Copy link
Contributor Author

plu commented Jun 14, 2016

I was using 2.1.2p95 before, now I'm trying with 2.3.1p112, both unsuccessful. I'm on this commit in spec/cocoapods-integration-specs:

commit 8d95e03ca3c6e3e2e8f0d870720110569ed3f45a (HEAD -> master, origin/master, origin/HEAD)
Merge: 4c7f241 409958a
Author: Samuel Giddins <segiddins@segiddins.me>
Date:   Fri Jun 10 00:35:41 2016 -0500

    Merge pull request #72 from Monits/circular_dependency

    [PodTarget] Add a cyclic dependencies between subspecs case

@plu
Copy link
Contributor Author

plu commented Jun 14, 2016

Ok, rebasing CocoaPods.git upon master worked - thanks :)

@plu
Copy link
Contributor Author

plu commented Jun 14, 2016

I've updated the test expectations. I'm not sure how to handle the submodule reference - am I supposed to update that one?

@plu plu mentioned this pull request Jun 15, 2016
1 task
@mrackwitz
Copy link
Member

It would be nice to have a unit test for that. Beside that this looks good to me though! 👍
You don't have to worry about updating the submodule.

@plu
Copy link
Contributor Author

plu commented Jun 18, 2016

I assume the test should go into spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb, but to be honest, I'm not sure how to create the nested targets with inherit! :search_path scenario there.

@benasher44
Copy link
Member

This might also fix #5173

@Coeur
Copy link
Contributor

Coeur commented Aug 11, 2016

@plu, this branch has conflicts
@mrackwitz, if it's too complex to write a test case, may we still merge the pull request for 1.1.0.beta.2 phase?

@mrackwitz
Copy link
Member

if it's too complex to write a test case, may we still merge the pull request for 1.1.0.beta.2 phase?

@Coeur: I'm asking mainly for tests not because I'm afraid that these changes here could be wrong or have unexpected effects, but more because untested code tends to break in the future when you're unaware because expectations were not encoded in the specs. So this is completely unrelated from the release context. If that makes it in without tests, no one is ever going to write tests for it.

@esetnik
Copy link

esetnik commented Sep 1, 2016

I think I just got bit by #5512, hoping to see this make it into 1.1.0. Let me know if I can help test.

@chrisortman
Copy link
Contributor

chrisortman commented Oct 19, 2016

Testing this branch and I get an error trying to install the KeychainAccess pod

NoMethodError - undefined method `try' for <Pod::PodTarget name=KeychainAccess >:Pod::PodTarget
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb:287:in `add_language_specific_settings'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb:228:in `add_target_specific_settings'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/generator/xcconfig/pod_xcconfig.rb:65:in `generate'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/generator/xcconfig/pod_xcconfig.rb:35:in `save_as'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:207:in `create_xcconfig_file'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:24:in `block in install!'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/user_interface.rb:141:in `message'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb:19:in `install!'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer/xcode/pods_project_generator.rb:154:in `block (2 levels) in install_libraries'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer/xcode/pods_project_generator.rb:152:in `each'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer/xcode/pods_project_generator.rb:152:in `block in install_libraries'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/user_interface.rb:141:in `message'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer/xcode/pods_project_generator.rb:151:in `install_libraries'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer/xcode/pods_project_generator.rb:64:in `generate!'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer.rb:177:in `block in generate_pods_project'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/user_interface.rb:63:in `section'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer.rb:176:in `generate_pods_project'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/installer.rb:116:in `install!'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/command/install.rb:37:in `run'
/Users/cortman/.gem/ruby/2.2.4/gems/claide-1.0.1/lib/claide/command.rb:334:in `run'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/lib/cocoapods/command.rb:50:in `run'
/Users/cortman/.gem/ruby/2.2.4/bundler/gems/CocoaPods-868991facb82/bin/pod:55:in `<top (required)>'
/Users/cortman/.gem/ruby/2.2.4/bin/pod:22:in `load'
/Users/cortman/.gem/ruby/2.2.4/bin/pod:22:in `<top (required)>'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
/Users/cortman/.gem/ruby/2.2.4/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'
/Users/cortman/.gem/ruby/2.2.4/bin/bundle:23:in `load'
/Users/cortman/.gem/ruby/2.2.4/bin/bundle:23:in `<main>'

I don't see anywhere that active support object or try is explicitly required.

chrisortman added a commit to chrisortman/CocoaPods that referenced this pull request Oct 20, 2016
@chrisortman
Copy link
Contributor

I put together a test for this PR. Not sure what to do with it
See this commit chrisortman@8ea1ac1

chrisortman added a commit to chrisortman/CocoaPods that referenced this pull request Oct 20, 2016
chrisortman added a commit to chrisortman/CocoaPods that referenced this pull request Oct 20, 2016
@trevonmckay
Copy link

Any update getting this merged?

@dnkoutso
Copy link
Contributor

@trevonmckay @plu this needs a rebase and some unit tests.

@chrisortman
Copy link
Contributor

I think in order to make the build pass this PR will need to be accepted first?

CocoaPods/cocoapods-integration-specs#73

I'm not the original author of the PR, but I have a unit test written and can do the rebase if it will help move this along. I think I'd have to make a new PR then though?

@Coeur
Copy link
Contributor

Coeur commented Nov 15, 2016

@dnkoutso, as a member of the project, you may have the ability to rebase during the merging process:
screen shot 2016-11-15 at 09 50 54

@dnkoutso
Copy link
Contributor

@Coeur sorry I am not a member of the project :)

@segiddins
Copy link
Member

Nope, this needs a manual rebase

@plu
Copy link
Contributor Author

plu commented Nov 16, 2016

Rebased and added @chrisortman's Unit Test.

@endocrimes endocrimes closed this Dec 8, 2016
@plu plu deleted the inherit_framework_search_path branch December 8, 2016 12:59
@YANOUSHek
Copy link

I'm using 1.2.0 and this bug seems to still be present. Had to extract my test targets from the app target and append all the pods to them manually because inherit! :search_paths didn't add all the required search paths.

@krider2010
Copy link

I think this has regressed in 1.2.0 final - it was fixed in one of the release candidates as I tested it then and it was fine, but have just spent a frustrating morning going in circles with it!

@plu
Copy link
Contributor Author

plu commented Feb 9, 2017

This broke via c45a4bb

@dnkoutso
Copy link
Contributor

dnkoutso commented Feb 9, 2017

@plu can you explain? Based on #6065 static frameworks on static libraries should not be linked if the target is using inherit! search_paths as it causes dup class warnings.

Search paths should still be added though.

There is one case where this is broken if the target explicitly asks for a pod to be integrated which at the moment will not properly add the -framework or -l flags.

I am working on a PR that fixes the case above.

@Coeur
Copy link
Contributor

Coeur commented Feb 9, 2017

So the pull request that broke it was #6437

@plu
Copy link
Contributor Author

plu commented Feb 9, 2017

Here's a sample project that shows the issue: https://github.com/plu/SearchPath

If you build the test target, it cannot find the GoogleMobileAds module.

Once I comment out these lines here it's working again (L106 & L108):

            #if aggregate_target.nil? || aggregate_target.target_definition.inheritance != 'search_paths'
              XCConfigHelper.add_framework_build_settings(vendored_static_framework, xcconfig, pod_target.sandbox.root)
            #end

After doing this change and running pod install again the local changes in the repository are:

diff --git a/Pods/Target Support Files/Pods-SearchPathTests/Pods-SearchPathTests.debug.xcconfig b/Pods/Target Support Files/Pods-SearchPathTests/Pods-SearchPa
index 5aa6975..4de062c 100644
--- a/Pods/Target Support Files/Pods-SearchPathTests/Pods-SearchPathTests.debug.xcconfig
+++ b/Pods/Target Support Files/Pods-SearchPathTests/Pods-SearchPathTests.debug.xcconfig
@@ -1,9 +1,9 @@
-FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/1PasswordExtension"
+FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/1PasswordExtension" "${PODS_ROOT}/Google-Mobile-Ads-SDK/Frameworks"
 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
 HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Google-Mobile-Ads-SDK"
 LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
 OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/1PasswordExtension/OnePasswordExtension.framework/Headers" -isystem "${PODS_ROOT}/Headers/
-OTHER_LDFLAGS = $(inherited) -framework "AVFoundation" -framework "AudioToolbox" -framework "CoreBluetooth" -framework "CoreGraphics" -framework "CoreMedia"
+OTHER_LDFLAGS = $(inherited) -framework "AVFoundation" -framework "AudioToolbox" -framework "CoreBluetooth" -framework "CoreGraphics" -framework "CoreMedia"
 PODS_BUILD_DIR = $BUILD_DIR
 PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
 PODS_ROOT = ${SRCROOT}/Pods
diff --git a/Pods/Target Support Files/Pods-SearchPathTests/Pods-SearchPathTests.release.xcconfig b/Pods/Target Support Files/Pods-SearchPathTests/Pods-Search
index 5aa6975..4de062c 100644
--- a/Pods/Target Support Files/Pods-SearchPathTests/Pods-SearchPathTests.release.xcconfig
+++ b/Pods/Target Support Files/Pods-SearchPathTests/Pods-SearchPathTests.release.xcconfig
@@ -1,9 +1,9 @@
-FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/1PasswordExtension"
+FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/1PasswordExtension" "${PODS_ROOT}/Google-Mobile-Ads-SDK/Frameworks"
 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
 HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Google-Mobile-Ads-SDK"
 LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
 OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/1PasswordExtension/OnePasswordExtension.framework/Headers" -isystem "${PODS_ROOT}/Headers/
-OTHER_LDFLAGS = $(inherited) -framework "AVFoundation" -framework "AudioToolbox" -framework "CoreBluetooth" -framework "CoreGraphics" -framework "CoreMedia"
+OTHER_LDFLAGS = $(inherited) -framework "AVFoundation" -framework "AudioToolbox" -framework "CoreBluetooth" -framework "CoreGraphics" -framework "CoreMedia"
 PODS_BUILD_DIR = $BUILD_DIR
 PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
 PODS_ROOT = ${SRCROOT}/Pods

@plu
Copy link
Contributor Author

plu commented Feb 9, 2017

I believe that def self.add_framework_build_settings must be split into two methods. One enhancing the FRAMEWORK_SEARCH_PATHS, and another one enhancing OTHER_LDFLAGS. For the search_paths use case, always call the method enhancing FRAMEWORK_SEARCH_PATHS.

@dnkoutso
Copy link
Contributor

dnkoutso commented Feb 9, 2017

Yes you are correct. I'll be opening a PR that fixes this.

@plu
Copy link
Contributor Author

plu commented Feb 9, 2017

Thank you!

@plu
Copy link
Contributor Author

plu commented Feb 9, 2017

I can also test on a more complex project once you have a patch ready.

@dnkoutso
Copy link
Contributor

dnkoutso commented Feb 9, 2017

@plu #6477

@dnkoutso
Copy link
Contributor

dnkoutso commented Feb 9, 2017

@plu I tried it on your SearchPath project and it fixes it. Would be good to get a more complicated project :)

@YANOUSHek
Copy link

I can test this on a more complicated project (3 framework targets, each with unit tests and an app target with unit and UI tests; all in one project), but I'd need some instructions on how to get the dev version working on my machine.

@dnkoutso
Copy link
Contributor

dnkoutso commented Feb 9, 2017

@YANOUSHek if you have a Gemfile then just add:

gem 'cocoapods', github: 'dnkoutso/CocoaPods', branch: 'better-static-linking'

Or you can choose the master branch now since it was merged.

@YANOUSHek
Copy link

@dnkoutso I think I've managed to get the current master branch installed and unfortunately it does not solve the problem. When I migrated my Podfile to use search path inheritance it still doesn't add the static libs into the project.

I'm not really sure if I'm running the version from master (they both report the same version number – 1.2.0) but I'm pretty sure I managed to get the newest one.

@dnkoutso
Copy link
Contributor

dnkoutso commented Feb 9, 2017

" it still doesn't add the static libs into the project."

what do you mean by that? Its not supposed to add pre-built static libraries or frameworks to your project.

Can you please open a new issue with a sample project instead so we don't post on a closed issue.

@krider2010
Copy link

A simple test case that now fails (again, after working in 1.2 beta 3) is to include Google Analytics into things. It fails to build any test target with the inherit paths option set. This regression is seriously problematic. Especially after it took so long to be solved in the first place. I had the luxery of it working for maybe a month at most 😞 I know this issue is closed, but a test case or something is needed to support it not happening again.

@YANOUSHek
Copy link

@dnkoutso I've created #6479 with all the examples I could have taught of.

@dnkoutso
Copy link
Contributor

dnkoutso commented Feb 9, 2017

@krider2010 tests were added and this was further improved and merged to master. It will most likely ship with 1.2.1.

@miktav
Copy link

miktav commented Mar 21, 2017

@krider2010 I had the same problem with Google Analytics, where my test target failed to build. I posted a question about this on stackoverflow before I saw this thread. The good news is that after upgrading to Cocoapods 1.2.1.beta.1, and re-running pod install, my test target now builds.

@dnkoutso
Copy link
Contributor

Yeap this is fixed in 1.2.1.beta.1 thanks for verifying again.

@miktav
Copy link

miktav commented Mar 21, 2017

@dnkoutso Thank you so much for resolving this.

@dnkoutso
Copy link
Contributor

@Oyashirox please do not respond to a close issue. File a new one and provide a sample project.

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

Successfully merging this pull request may close these issues.

1.0.1: Missing framework search path on Unit Test target