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

Obsolete key's value in generated file #223

Open
PatrykKaczmarek opened this issue Oct 25, 2021 · 3 comments
Open

Obsolete key's value in generated file #223

PatrykKaczmarek opened this issue Oct 25, 2021 · 3 comments

Comments

@PatrykKaczmarek
Copy link

PatrykKaczmarek commented Oct 25, 2021

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
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
  1. removed CocoaPods from Mac entirely
  2. 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?

@PatrykKaczmarek PatrykKaczmarek changed the title Obsolete key's value in generate file Obsolete key's value in generated file Oct 25, 2021
@ashfurrow
Copy link
Collaborator

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

@PatrykKaczmarek
Copy link
Author

@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
Copy link
Collaborator

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).

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

2 participants