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

Cocoa pods TRACE_RESOURCES setup #301

Closed
sergdort opened this issue Nov 30, 2015 · 4 comments
Closed

Cocoa pods TRACE_RESOURCES setup #301

sergdort opened this issue Nov 30, 2015 · 4 comments

Comments

@sergdort
Copy link
Contributor

Hi, guys
Sorry if its not related to Rx, but could you please describe how should I set up my podfile in order to be able to see resources in the debug mode

Because now I do this manualy

@kzaher
Copy link
Member

kzaher commented Nov 30, 2015

Hi @sergdort ,

I believe you need a post install hook.

More info here

http://www.mokacoding.com/blog/cocoapods-and-custom-build-configurations/

... and you need to set these Swift flags (I believe it is called OTHER_SWIFT_FLAGS in configuration).

screen shot 2015-11-30 at 22 13 10

@sergdort
Copy link
Contributor Author

sergdort commented Dec 1, 2015

Hi, @kzaher
Thanks, I did this with example of this post http://marginalfutility.net/2015/10/11/swift-compiler-flags/

If somebody interested this is my post install hook, I also did what you said with the app target, in order do use #if macro

   #if TRACE_RESOURCES
....
   #endif
post_install do |installer|
   installer.pods_project.targets.each do |target|
      if target.name == 'RxSwift'
         target.build_configurations.each do |config|
            if config.name == 'Debug'
               config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['-D', 'TRACE_RESOURCES']
            end
         end
      end
   end
end

@scotteg
Copy link
Contributor

scotteg commented Apr 20, 2016

Thanks @sergdort and @kzaher, that post_install hook did the trick! I only needed to add the post_install hook in order to access RxSwift.resourceCount. Adding the compiler flag (using whatever name) just lets you conditionally execute whatever code you write in the #if #endif block. Another way to do this is to set an environment variable in the scheme...

screenshot 2016-04-20 03 57 35

...and then conditionally check it using NSProcessInfo:

if NSProcessInfo.processInfo().environment["TRACE_RESOURCES"] != nil {
  print(RxSwift.resourceCount)
}

That way you can just check/uncheck a box when you want to enable or disable certain code. 😀

@caoer
Copy link

caoer commented Aug 3, 2020

we can use macro now.
image

   #if TRACE_RESOURCES
....
   #endif

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

4 participants