1

My client has an old Obj-C based iOS project and wanted me to update it.

The problem is, on my computer, the project is clean of warnings. But on his computer, Xcode is showing 130+ Block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior warnings.

I want to push the project warning-free, but cannot see/show/re-create them on my Mac.

Any suggestions? Thank you.

Notes:

  • Development target is iOS 11.3.
  • We are using the same and latest versions of macOS and Xcode.
  • My client is using a MacBook Pro, I think it is a 2013 or 2014 version.
  • I'm using late 2013 MacPro.
  • The project uses CocoaPods with these Pods:
    • pod 'Firebase/Core'
    • pod 'Firebase/AdMob'
    • pod 'JGProgressHUD'
Arda Oğul Üçpınar
  • 881
  • 1
  • 14
  • 38
  • Possible duplicate of [Block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior](https://stackoverflow.com/questions/21577711/block-implicitly-retains-self-explicitly-mention-self-to-indicate-this-is-i) – staticVoidMan Apr 06 '18 at 08:45
  • It is not a duplicate. I've already looked at that question. I know how to fix them and that is not my question. My problem is I cannot see these warnings on my machine, and If I cannot see, I cannot fix. + I will not set CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF to NO. – Arda Oğul Üçpınar Apr 06 '18 at 08:48
  • 2
    Do the opposite. Go through the projects & targets and check if `CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF` is `YES` – staticVoidMan Apr 06 '18 at 09:18
  • Oh my gosh. Yes, it was set to NO. But who did that!? And why on client's code it was YES? He forked mine. Anyway... Thank you very much. – Arda Oğul Üçpınar Apr 06 '18 at 11:04
  • wat da fork! :D well.. that's weird :D. Btw, it would make sense to accept your own answer now :) – staticVoidMan Apr 06 '18 at 11:10
  • SO says I cannot accept my answer in 2 days. Maybe you can write an answer and I accept that :) – Arda Oğul Üçpınar Apr 06 '18 at 11:15
  • No, it's okay :P Happy code fixing :) – staticVoidMan Apr 06 '18 at 11:20

2 Answers2

2

Xcode 9.3 (9E145) will set the CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF to YES as part of it's "update project settings" step.

Also, Cocoapod depends on a gem called Xcodeproj and starting with version 1.5.5 (I think) Xcodeproj will also set this flag to YES for each pod target by default. (Note that you can be using the same version of Cocoapods with different versions of Xcodeproj and get different results when you run pod install/update).

You can force these errors to show up by manually setting this flag to YES for each build target (do this in Build Settings, search for "Implicit retain" - the entry is labeled "Implicit retain of 'self' within blocks" and it maps to the Clang flag CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF).

If you are using the same versions of Xcode I suspect you have different versions of Cocoapods (or Xcodeproj). Note that these warnings may be coming from the pods and not your code.

1

Very much thanks to @staticVoidMan, -I don't know why and who did that. I'm the 3rd developer of the project- CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF was set to NO. Setting it to YES show me the warnings.

The interesting part is my client cloned my project and in his project, it's set to YES. Odd. Whatever. It is solved.

Arda Oğul Üçpınar
  • 881
  • 1
  • 14
  • 38