preface
Due to the epidemic, I can only debug the real machine on my non-paid developer account at home during the Spring Festival so far, so I found this problem. The simple new project has not been able to debug the real machine, which has stopped me intermittently for several days.
Key words:
Dyld: Library not loaded: @rpath/xx.framework/xx and code Signature invalid for XX. framework
Common conditions for encountering errors:
- Real machine commissioning
- Xcode 11.3.1 + iOS 13.3.1
- Non-paid developer accounts and credentials
- Introduced third-party frameworks using Cocoa Pods
Scene:
Under the above conditions, no matter the old project or a new OC/Swift blank project, it can run normally on the simulator. But when debugging on a real machine, Xcode crashes and console output looks like the image above
To solve
Dyld: Library not loaded: @rpath/xx. Framework /xx
-
CMD + Shift + K cleanup project
-
Empty/Users/xx/Library/Developer/Xcode/DerivedData directory
-
General — embeded binaries embed files (this step is new thanks to an update to Xcode11, as shown below)
-
Add Copy Files to Build Phases
-
Change the Dynam Library in Mach -O Type to Static Library
-
Change the trust of debugging certificates used in keychain to “Use system Defaults”
-
Reinstall RVM, Cocoa Pods, Xcode
Code Signature Invalid for XX. framework was searched for in the Apple Developer forum. Link to several open source frameworks on GitHub, including issues (flutter and Alamofire fail 😂) and Stack Overflow.
code signature invalid for Framework
Causes Runtime Error for frameworks “Code Signature invalid”
App crashes on iPhone but works fine with android emulator, android device and iOS simulator
Simply put, both the new Xcode and iOS versions have the potential to invalidate the signature of the embedded dynamic library when we use an unpaid developer account. The solutions are:
- If possible, clean up the certificates and configuration files generated by non-paid developer accounts and replace them with paid developer certificates
- Open the Cocoa Pods Podfile and comment it out
use_frameworks!
- Add a sentence to your Podfile
Use_modular_headers!
- perform
pod deintegrate
+pod install
Reconfigure the third-party library once