Post

Replies

Boosts

Views

Activity

Running a Catalyst application via XCTest loads macOS specific frameworks
When trying to test a Catalyst application with XCTest the application crashes at startup with Symbol not found error when certain frameworks are in use. This is caused by XCTest / Xcode adding /Applications/Xcode.app/Contents/SharedFrameworks to DYLD_FRAMEWORK_PATH causing dyld to load the macOS specific framework variant of for example RealityKit instead from /System/iOSSupport/System/Library/Frameworks as defined in the load commands. Which leads to symbol mismatches, for example ARView.Environment.Color is a UIColor on Mac Catalyst but an NSColor on macOS (_$s10RealityKit6ARViewC11EnvironmentV10BackgroundV5coloryAGSo7UIColorCFZ vs. _$s10RealityKit6ARViewC11EnvironmentV10BackgroundV5coloryAGSo7NSColorCFZ) Tried prepending /System/iOSSupport/System/Library/Frameworks to the DYLD_FRAMEWORK_PATH env var of the test target, but via some private frameworks still wrong framework variants were loaded. Any ideas for possible fixes or workarounds?
8
0
639
May ’24
Duplicate symbols when linking a static library containing Objective-C++
ld_prime of Xcode 15 produces duplicate symbols when linking a static library containing Objective-C++ object in case using the flags -ObjC and -Wl,force_load. // foo.h #pragma once int Inc(int i); // foo.mm #include "foo.h" #include <Foundation/Foundation.h> @interface Foo : NSObject @end @implementation Foo @end int Inc(int i) { return i + 1; }; // main.cpp #include "foo.h" int main(int argc, const char * argv[]) { return Inc(0); } ❯ clang++ -c foo.mm ❯ ar rcs libfoo.a foo.o ❯ clang++ -framework Foundation libfoo.a -x c++ main.cpp -Wl,-force_load,libfoo.a -ObjC duplicate symbol '__Z3Inci' in: libfoo.a[2](foo.o) libfoo.a[2](foo.o) duplicate symbol '_OBJC_CLASS_$_Foo' in: libfoo.a[2](foo.o) libfoo.a[2](foo.o) duplicate symbol '_OBJC_METACLASS_$_Foo' in: libfoo.a[2](foo.o) libfoo.a[2](foo.o) ld: 3 duplicate symbols clang: error: linker command failed with exit code 1 (use -v to see invocation)```
4
0
2.5k
Oct ’23