How to compile arm .s, x86 .s (and .c, .m ) files to a single universal .app in Xcode project ?

How to compile arm .s, x86 .s (and .c, .m ) files to a single universal .app in Xcode project ?

How to tell Xcode a f1.s file is for Intel assembler and f2.s file is for Arm assembler ?

Or equivalent of "C"

#if TARGET_CPU_ARM64
#elif TARGET_CPU_X86_64
#endif 

directive in assembler

Partial solution:

let d_tst the directory holding main.c, arm.s, intel.s and source_c a folder of other C files

cd d_tst gcc main.c intel.s ./source_c/.c -o x86_app -target x86_64-apple-macos10.12 gcc main.c arm.s ./source_c/.c -o arm_app -target arm64-apple-macos11 lipo -create -output universal_app x86_app arm_app

But this work only for command tool with terminal.

How to make a universal application with Xcode project and gui (and intel.s, arm.s)? Or to link in a such project ?

Solution: insert .s assembly code between .if TARGET_CPU_ARM64 and #if TARGET_CPU_X86_64

test_cpu.c

#include <stdio.h>
#include "TargetConditionals.h"

#include "test_cpu.h"

extern int64_t add_test_asm(int64_t, int64_t);

char buf[128];

int64_t a, b, sum;

void test()
	{
	#if TARGET_CPU_ARM64
	a = 4; b = 70;
	sum = add_test_asm(a, b);
	snprintf(buf, 128, "CPU is ARM64, %llu + %llu = %llu", a, b, sum);
	#elif TARGET_CPU_X86_64
	a = 40; b = 7;
	sum = add_test_asm(a, b);
	snprintf(buf, 128, "CPU is X86_64, %llu + %llu = %llu", a, b, sum);
	#endif
	}

test_cpu.h

extern char buf[];
extern void test(void);

add_arm.s file

#include "TargetConditionals.h"

.if TARGET_CPU_ARM64

.globl _add_test_asm

.align 4

_add_test_asm:

		add			x0,x0,x1
		ret

.endif

add_intel.s file

#include "TargetConditionals.h"

#if TARGET_CPU_X86_64

.globl _add_test_asm

.align 4

_add_test_asm:

		movq	%rdi,%rax
		addq	%rsi,%rax
		retq

#endif
How to compile arm .s, x86 .s (and .c, .m ) files to a single universal .app in Xcode project ?
 
 
Q