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

Linker plugin not working when running tests #47

Open
joharei opened this issue Jan 17, 2023 · 5 comments
Open

Linker plugin not working when running tests #47

joharei opened this issue Jan 17, 2023 · 5 comments

Comments

@joharei
Copy link

joharei commented Jan 17, 2023

I have added the linker plugin, but when running iosX64Test or iosSimulatorArm64Test I get the undefined symbols error when building:

Undefined symbols for architecture arm64:
  "_FIRCLSExceptionRecordNSException", referenced from:
      _co_touchlab_crashkios_crashlytics_FIRCLSExceptionRecordNSException_wrapper0 in result.o
  "_OBJC_CLASS_$_FIRCrashlytics", referenced from:
      objc-class-ref in result.o
  "_OBJC_CLASS_$_FIRExceptionModel", referenced from:
      objc-class-ref in result.o
  "_OBJC_CLASS_$_FIRStackFrame", referenced from:
      objc-class-ref in result.o

I have tried similar workarounds like in #46, but I can't get it working.

@jjcoffman
Copy link

i have the same issue as above fox x86_64:

▸ Linking MyAppUITests

❌  ld: symbol(s) not found for architecture x86_64



❌  clang: error: linker command failed with exit code 1 (use -v to see invocation)


    Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'MDFInternationalization' from project 'Pods')
Testing failed:
	Undefined symbol: _FIRCLSExceptionRecordNSException
	Undefined symbol: _OBJC_CLASS_$_FIRCrashlytics
	Undefined symbol: _OBJC_CLASS_$_FIRExceptionModel
	Undefined symbol: _OBJC_CLASS_$_FIRStackFrame
	Linker command failed with exit code 1 (use -v to see invocation)
	Testing cancelled because the build failed.

** TEST FAILED **

@LukasHromadnik
Copy link

Hi!
Any updates on this issue?
I cannot run the tests, I can build them though. But still the workaround is not working for tests.

@joharei
Copy link
Author

joharei commented Jul 19, 2023

I finally found the right place to apply the linker options so that our tests can run:

tasks.withType<KotlinNativeCompile>().configureEach {
    compilerOptions.freeCompilerArgs.addAll(
        listOf(
            "-linker-options",
            "-U _FIRCLSExceptionRecordNSException " +
                "-U _OBJC_CLASS_\$_FIRStackFrame " +
                "-U _OBJC_CLASS_\$_FIRExceptionModel " +
                "-U _OBJC_CLASS_\$_FIRCrashlytics",
        ),
    )
}

@LukasHromadnik
Copy link

@joharei thanks for the response. But I'm still getting symbol not found in flat namespace: '_OBJ_CLASS_$_FIRCrashlytics'.
Which method (SPM, Cococapods, Carthage, XCFramework directly) do you use to integrate Crashlytics into the app?

@joharei
Copy link
Author

joharei commented Jul 20, 2023

@LukasHromadnik right, I got that one too. You need to make sure you're not importing CrashlyticsLogWriter (or probably any other Crashlytics related from this library) anywhere in the code that you're testing. In my case I had to refactor the way I set up the Kermit Logger.

I'm building a dynamic XCFramework published as an SPM package.

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

3 participants