johnno1962 / HotReloading

Hot reloading as a Swift Package
MIT License
561 stars 49 forks source link

Loading .dylib has failed, This is likely because Swift code being injected references a function using a default argument or a member with access control that is too restrictive or perhaps an XCTest that depends on code not normally linked into your application. Rebuilding and re-running your project (without a build clean) can resolve this. #93

Closed zerocc2014 closed 6 months ago

zerocc2014 commented 7 months ago

Loading .dylib has failed, This is likely because Swift code being injected references a function using a default argument or a member with access control that is too restrictive or perhaps an XCTest that depends on code not normally linked into your application. Rebuilding and re-running your project (without a build clean) can resolve this.

use HotReloading SPM in .xcworkspace cocopods project

johnno1962 commented 7 months ago

Hi, Is this Swift or Objective-C? Can you tell me the name of the symbol that is not defined?

zerocc2014 commented 7 months ago

Hi, Is this Swift or Objective-C? Can you tell me the name of the symbol that is not defined?

my project Swift and Objective-C,symbol not found in flat namespace '_xxx';

` typedef NSString *URLConstString;

extern a URLConstString xxx;

URLConstString const xxx = @"yyyyy"; `

zerocc2014 commented 7 months ago

Hi, Is this Swift or Objective-C? Can you tell me the name of the symbol that is not defined?

dlopen(/..path/tmp/eval101.dylib, 0x0002): symbol not found in flat namespace '_xxx'

johnno1962 commented 7 months ago

Strange, can you remove the "const"?

zerocc2014 commented 7 months ago

Strange above i write error,original like this typedef NSString *URLConstString;

extern URLConstString const xxx;

URLConstString const xxx = @"yyyyy";

johnno1962 commented 7 months ago

I'm not sure what the problem is. If you can't inject files that refer to this definition you could consider creating a class method to access the variable.

zerocc2014 commented 7 months ago

I'm not sure what the problem is. If you can't inject files that refer to this definition you could consider creating a class method to access the variable.

thx, I use demo test inject success,but company project is fail.

johnno1962 commented 7 months ago

Not much more I can say here. When referring to a particular symbol gives you problems dynamically loading you have to explore ways to avoid referring to that symbol directly in the file being inject for example by using a class method.