orta / cocoapods-keys

A key value store for storing per-developer environment and application keys
MIT License
1.55k stars 93 forks source link

Obsolete key's value in generated file #223

Open PatrykKaczmarek opened 2 years ago

PatrykKaczmarek commented 2 years ago

I'm experiencing a very strange issue nobody else can reproduce...I wanted to change bunch of previously define values for existing keys. All changes were applied successfully however there is one value which is always taken from previous .env definition. No matter what I do it still takes previous value.

Prerequisites

  1. Xcode 13.x (didn't work for Xcode 12.x either)
  2. CocoaPods v 1.11.x (didn't work for 1.10.x either)
  3. cocoapods-keys 2.1.0 or 2.2.1
  4. ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
  5. macOS 11.x

Podfile:

plugin 'cocoapods-keys', {
    project: 'MyProject',
    target: 'MyTarget',
    keys: [
        'MY_KEY',
        'MY_SECOND_KEY'
    ]
}

.env file

MY_KEY = value.1
MY_SECOND_KEY = value.2

Example

Before change:

# .env file
MY_KEY = value.1
MY_SECOND_KEY = value.2

# .swift file
print(Keys().mY_KEY) // prints "value.1" 
print(Keys().mY_SECOND_KEY) // prints "value.2" 

After change:

# .env file
MY_KEY = value.11
MY_SECOND_KEY = value.22

# pod install

# .swift file
print(Keys().mY_KEY) // still prints "value.1" 
print(Keys().mY_SECOND_KEY) // prints correctly "value.22" 

What I did:

  1. deintegrate pods: pod deintegrate
  2. removed all cocoapods keys occurrences in my keychain
  3. removed ~/.cocoapods/keys
  4. removed .env file and defined values via terminal prompts
  5. rm -rf "${HOME}/Library/Caches/CocoaPods"
    rm -rf "`pwd`/Pods/"
    pod update
  6. removed CocoaPods from Mac entirely
  7. removed all Xcode caches I found:
    killall Xcode
    xcrun -k
    xcodebuild -alltargets clean
    rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
    rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
    rm -rf ~/Library/Developer/Xcode/DerivedData/*
    rm -rf ~/Library/Caches/com.apple.dt.Xcode/*

If I remove this key from .env file and install pods then script prompts for giving a value. Calling bundle exec pod keys prints nothing. So far I use Keys.m file generated by a second developer. By "using" I mean I copy-paste content of his file to my file after every pod install what is not very efficient way of work.

This issue drives me crazy. Can someone have other idea what to do?

ashfurrow commented 2 years ago

Could the key value be stored in your keychain? Open Keychain Access.app and look for the MyProject project name.

PatrykKaczmarek commented 2 years ago

@ashfurrow No, the value isn't stored in the Keychain. I was looking for it and I did even remove all projects's entries from the keychain - I mean all projects I have, not only this one particularly which I currently work on.

ashfurrow commented 2 years ago

Wow, that is bananas. Sorry you're hitting that error – I'm not sure what the cause could be. The steps you've outlined are exhaustive and should definitely have removed this. I can also recommend a reboot (if you haven't yet) and moving the code into a new directory (cocoapods-keys uses the directory of the Podfile as a key lookup).