Is there any way to find out what line is triggering the warning
ld: warning: linking against a dylib which is not safe for use in application extensions
I went through my package code and I couldn't find any API unsafe for application extensions
Is there any way to find out what line is triggering the warning
ld: warning: linking against a dylib which is not safe for use in application extensions
I went through my package code and I couldn't find any API unsafe for application extensions
I don’t have any useful insight into to the SPM aspect of this (sorry) but I can answer this:
Is there any way to find out what line is triggering the warning
It’s not a line of code but rather the presence of a framework or library that’s marked as being unsafe for an appex. Consider this:
% otool -h libSafe.dylib
libSafe.dylib:
… flags
… 0x02100085
% otool -h libUnsafe.dylib
libUnsafe.dylib:
… flags
… 0x00100085
The first library is appex safe, and so MH_APP_EXTENSION_SAFE
is set in its flags.
Once you know what library is appex unsafe, you can then nm -m
to find out what symbols you’re using from it.
Share and Enjoy
Quinn “The Eskimo!” @ DTS @ Apple
Hi! I'm on Xcode 13.0(13A233) and I still have "Linking against a dylib which is not safe for use in application extensions" warnings.
Even linking against a package with only this code gets an error
public func foo() {
print(1)
}
Can you take a look at my otool output?
otool -h libLibTest.dylib
libLibTest.dylib:
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
0xfeedfacf 16777223 3 0x00 6 18 2840 0x00100085
nm -m libLibTest.dylib
0000000000004050 (__TEXT,__text) external _$s7LibTest3fooyyF
(undefined) external _$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC (from libswiftCore)
0000000000004170 (__TEXT,__text) non-external (was a private external) _$sSa12_endMutationyyF
(undefined) external _$sSaMa (from libswiftCore)
(undefined) external _$sSiN (from libswiftCore)
(undefined) external _$ss27_allocateUninitializedArrayySayxG_BptBwlF (from libswiftCore)
00000000000040f0 (__TEXT,__text) non-external (was a private external) _$ss27_finalizeUninitializedArrayySayxGABnlF
(undefined) external _$ss5print_9separator10terminatoryypd_S2StF (from libswiftCore)
0000000000004130 (__TEXT,__text) non-external (was a private external) _$ss5print_9separator10terminatoryypd_S2StFfA0_
0000000000004150 (__TEXT,__text) non-external (was a private external) _$ss5print_9separator10terminatoryypd_S2StFfA1_
(undefined) external _$sypN (from libswiftCore)
(undefined) external _CFStringGetCStringPtr (from CoreFoundation)
00000000000086a8 (__DATA,__data) non-external _DummyTargetContextDescriptor
0000000000008558 (__DATA,__objc_data) non-external (was a private external) _OBJC_METACLASS_$___ARCLite__
00000000000086b8 (__DATA,__swift_hooks) external _Swift50Overrides
0000000000008770 (__DATA,__swift51_hooks) external _Swift51Overrides
(undefined) external __Block_copy (from libSystem)
(undefined) external __DefaultRuneLocale (from libSystem)
00000000000083b8 (__DATA,__objc_const) non-external __OBJC_$_PROTOCOL_INSTANCE_METHODS___ARCLiteIndexedSubscripting__
0000000000008400 (__DATA,__objc_const) non-external __OBJC_$_PROTOCOL_INSTANCE_METHODS___ARCLiteKeyedSubscripting__
00000000000083f0 (__DATA,__objc_const) non-external __OBJC_$_PROTOCOL_METHOD_TYPES___ARCLiteIndexedSubscripting__
0000000000008438 (__DATA,__objc_const) non-external __OBJC_$_PROTOCOL_METHOD_TYPES___ARCLiteKeyedSubscripting__
00000000000082f0 (__DATA,__objc_protolist) non-external (was a private external) __OBJC_LABEL_PROTOCOL_$___ARCLiteIndexedSubscripting__
00000000000082f8 (__DATA,__objc_protolist) non-external (was a private external) __OBJC_LABEL_PROTOCOL_$___ARCLiteKeyedSubscripting__
00000000000085a8 (__DATA,__data) non-external (was a private external) __OBJC_PROTOCOL_$___ARCLiteIndexedSubscripting__
0000000000008608 (__DATA,__data) non-external (was a private external) __OBJC_PROTOCOL_$___ARCLiteKeyedSubscripting__
0000000000008548 (__DATA,__objc_protorefs) non-external (was a private external) __OBJC_PROTOCOL_REFERENCE_$___ARCLiteIndexedSubscripting__
0000000000008550 (__DATA,__objc_protorefs) non-external (was a private external) __OBJC_PROTOCOL_REFERENCE_$___ARCLiteKeyedSubscripting__
0000000000006370 (__TEXT,__text) external __Z34_swiftoverride_class_getSuperclassPKN5swift14TargetMetadataINS_9InProcessEEE
0000000000008940 (__DATA,__bss) non-external __ZGVZL18add_image_hook_ARCPK11mach_headerlE7patches
0000000000008a60 (__DATA,__bss) non-external __ZGVZL22add_image_hook_swiftV1PK11mach_headerlE7patches
0000000000008860 (__DATA,__bss) non-external __ZGVZL30add_image_hook_autoreleasepoolPK11mach_headerlE7patches
0000000000007c30 (__TEXT,__objc_classname) non-external __ZL11_class_name
00000000000060cb (__TEXT,__text) non-external __ZL12cxxConstructP11objc_object
0000000000008668 (__DATA,__data) non-external __ZL12demangleLock
0000000000005ead (__TEXT,__text) non-external __ZL13demangledNamePKcb
0000000000008978 (__DATA,__bss) non-external __ZL14NSString_class
0000000000005cfd (__TEXT,__text) non-external __ZL14initialize_impP11objc_objectP13objc_selector
0000000000008ac8 (__DATA,__bss) non-external __ZL15OldGetClassHook
0000000000004176 (__TEXT,__text) non-external __ZL15__ARCLite__loadv
0000000000006260 (__TEXT,__text) non-external __ZL16addImageCallbackPK11mach_headerl
0000000000006050 (__TEXT,__text) non-external __ZL16scanMangledFieldRPKcS0_S1_Ri
0000000000007c78 (__TEXT,__objc_methname) non-external __ZL17_load_method_name
0000000000007ea0 (__TEXT,__objc_methtype) non-external __ZL17_load_method_type
0000000000006f10 (__TEXT,__text) non-external __ZL17swift_unreachablePKc
0000000000005bb0 (__TEXT,__text) non-external __ZL17transcribeMethodsP10objc_classP15glue_class_ro_t
0000000000004a1f (__TEXT,__text) non-external __ZL18add_image_hook_ARCPK11mach_headerl
0000000000005d03 (__TEXT,__text) non-external __ZL18allocateMaybeSwiftP18glue_swift_class_tm
00000000000046fc (__TEXT,__text) non-external __ZL19patch_lazy_pointersPK11mach_headerP7patch_tm
0000000000005c34 (__TEXT,__text) non-external __ZL19transcribeProtocolsP10objc_classP15glue_class_ro_t
00000000000060f2 (__TEXT,__text) non-external __ZL20fixStringForCoreDataP11objc_object
0000000000005c7f (__TEXT,__text) non-external __ZL20transcribePropertiesP10objc_classP15glue_class_ro_t
0000000000004f0c (__TEXT,__text) non-external __ZL21__arclite_objc_retainP11objc_object
0000000000004d90 (__TEXT,__text) non-external __ZL21__arclite_object_copyP11objc_objectm
0000000000008970 (__DATA,__bss) non-external __ZL22NSConstantString_class
0000000000004f28 (__TEXT,__text) non-external __ZL22__arclite_objc_releaseP11objc_object
0000000000005016 (__TEXT,__text) non-external __ZL22add_image_hook_swiftV1PK11mach_headerl
0000000000005d8a (__TEXT,__text) non-external __ZL22copySwiftV1MangledNamePKcb
0000000000008aa0 (__DATA,__bss) non-external __ZL22original_class_getName
0000000000008a78 (__DATA,__bss) non-external __ZL22original_objc_getClass
0000000000008830 (__DATA,__bss) non-external __ZL23NSAutoreleasePool_class
0000000000005b21 (__TEXT,__text) non-external __ZL23__arclite_class_getNameP10objc_class
0000000000005975 (__TEXT,__text) non-external __ZL23__arclite_objc_getClassPKc
0000000000008580 (__DATA,__objc_data) non-external __ZL24OBJC_CLASS_$___ARCLite__
0000000000004c25 (__TEXT,__text) non-external __ZL24__arclite_object_setIvarP11objc_objectP9objc_ivarS0_
0000000000006240 (__TEXT,__text) non-external __ZL24registerAddImageCallbackPv
0000000000008968 (__DATA,__bss) non-external __ZL25NSMutableDictionary_class
0000000000008a98 (__DATA,__bss) non-external __ZL25original_objc_getProtocol
0000000000008a90 (__DATA,__bss) non-external __ZL25original_objc_lookUpClass
0000000000008aa8 (__DATA,__bss) non-external __ZL25original_protocol_getName
0000000000004f3a (__TEXT,__text) non-external __ZL26__arclite_objc_autoreleaseP11objc_object
0000000000005ac9 (__TEXT,__text) non-external __ZL26__arclite_objc_getProtocolPKc
0000000000005a74 (__TEXT,__text) non-external __ZL26__arclite_objc_lookUpClassPKc
0000000000004f1e (__TEXT,__text) non-external __ZL26__arclite_objc_retainBlockP11objc_object
0000000000004fc6 (__TEXT,__text) non-external __ZL26__arclite_objc_storeStrongPP11objc_objectS0_
0000000000005b36 (__TEXT,__text) non-external __ZL26__arclite_protocol_getNameP8Protocol
0000000000008a80 (__DATA,__bss) non-external __ZL26original_objc_getMetaClass
0000000000008350 (__DATA,__objc_const) non-external __ZL27OBJC_CLASS_RO_$___ARCLite__
0000000000007c10 (__TEXT,__const) non-external __ZL27ProtocolConformancesSection
00000000000059ca (__TEXT,__text) non-external __ZL27__arclite_objc_getMetaClassPKc
0000000000004bc7 (__TEXT,__text) non-external __ZL27__arclite_objc_loadClassrefPP10objc_class
0000000000008988 (__DATA,__bss) non-external __ZL27original_NSKKMS_indexForKey
00000000000052ef (__TEXT,__text) non-external __ZL28__arclite_NSKKMS_indexForKeyP11objc_objectP13objc_selectorS0_
0000000000005565 (__TEXT,__text) non-external __ZL28__arclite_objc_readClassPairP10objc_classPK15objc_image_info
0000000000008990 (__DATA,__bss) non-external __ZL28original_NSKKsD_objectForKey
0000000000005341 (__TEXT,__text) non-external __ZL29__arclite_NSKKsD_objectForKeyP11objc_objectP13objc_selectorS0_
00000000000062f0 (__TEXT,__text) non-external __ZL29installGetClassHook_untrustedv
0000000000008950 (__DATA,__bss) non-external __ZL29original_NSManagedObject_init
0000000000008948 (__DATA,__bss) non-external __ZL30NSUndoManagerProxy_targetClass
000000000000523a (__TEXT,__text) non-external __ZL30__arclite_NSManagedObject_initP11objc_objectP13objc_selector
0000000000004647 (__TEXT,__text) non-external __ZL30add_image_hook_autoreleasepoolPK11mach_headerl
00000000000060c5 (__TEXT,__text) non-external __ZL30arclite_uninitialized_functionv
0000000000008a88 (__DATA,__bss) non-external __ZL30original_objc_getRequiredClass
0000000000008308 (__DATA,__objc_const) non-external __ZL31OBJC_METACLASS_RO_$___ARCLite__
0000000000005a1f (__TEXT,__text) non-external __ZL31__arclite_objc_getRequiredClassPKc
0000000000008a68 (__DATA,__bss) non-external __ZL31original_objc_allocateClassPair
0000000000008a70 (__DATA,__bss) non-external __ZL31original_object_getIndexedIvars
0000000000008398 (__DATA,__objc_const) non-external __ZL32OBJC_$_CLASS_METHODS___ARCLite__
0000000000005885 (__TEXT,__text) non-external __ZL32__arclite_objc_allocateClassPairP10objc_classPKcm
0000000000004f4c (__TEXT,__text) non-external __ZL32__arclite_objc_retainAutoreleaseP11objc_object
0000000000005924 (__TEXT,__text) non-external __ZL32__arclite_object_getIndexedIvarsP11objc_object
00000000000089a0 (__DATA,__bss) non-external __ZL32original_NSKKsD_setObject_forKey
00000000000053e7 (__TEXT,__text) non-external __ZL33__arclite_NSKKsD_setObject_forKeyP11objc_objectP13objc_selectorS0_S0_
00000000000046ea (__TEXT,__text) non-external __ZL33__arclite_objc_autoreleasePoolPopPv
00000000000046d1 (__TEXT,__text) non-external __ZL34__arclite_objc_autoreleasePoolPushv
0000000000008998 (__DATA,__bss) non-external __ZL34original_NSKKsD_removeObjectForKey
0000000000005393 (__TEXT,__text) non-external __ZL35__arclite_NSKKsD_removeObjectForKeyP11objc_objectP13objc_selectorS0_
0000000000006330 (__TEXT,__text) non-external __ZL35getObjCClassByMangledName_untrustedPKcPP10objc_class
0000000000008960 (__DATA,__bss) non-external __ZL35original_NSManagedObject_allocBatch
0000000000005260 (__TEXT,__text) non-external __ZL36__arclite_NSManagedObject_allocBatchP11objc_objectP13objc_selectorPS0_S0_j
0000000000004bcf (__TEXT,__text) non-external __ZL36__arclite_object_setInstanceVariableP11objc_objectPKcPv
0000000000008980 (__DATA,__bss) non-external __ZL36original_NSKKMS_fastIndexForKnownKey
0000000000008ab0 (__DATA,__bss) non-external __ZL36original_objc_copyClassNamesForImage
000000000000529d (__TEXT,__text) non-external __ZL37__arclite_NSKKMS_fastIndexForKnownKeyP11objc_objectP13objc_selectorS0_
0000000000004f77 (__TEXT,__text) non-external __ZL37__arclite_objc_autoreleaseReturnValueP11objc_object
0000000000005b4e (__TEXT,__text) non-external __ZL37__arclite_objc_copyClassNamesForImagePKcPj
00000000000089a8 (__DATA,__bss) non-external __ZL40original_NSKKsD_addEntriesFromDictionary
0000000000008958 (__DATA,__bss) non-external __ZL40original_NSManagedObject_allocWithEntity
0000000000005450 (__TEXT,__text) non-external __ZL41__arclite_NSKKsD_addEntriesFromDictionaryP11objc_objectP13objc_selectorP12NSDictionary
000000000000524d (__TEXT,__text) non-external __ZL41__arclite_NSManagedObject_allocWithEntityP11objc_objectP13objc_selectorS0_
000000000000494d (__TEXT,__text) non-external __ZL42__arclite_NSArray_objectAtIndexedSubscriptP7NSArrayP13objc_selectorm
0000000000005201 (__TEXT,__text) non-external __ZL42__arclite_NSUndoManagerProxy_isKindOfClassP11objc_objectP13objc_selectorP10objc_class
0000000000004f89 (__TEXT,__text) non-external __ZL43__arclite_objc_retainAutoreleaseReturnValueP11objc_object
0000000000004fb4 (__TEXT,__text) non-external __ZL44__arclite_objc_retainAutoreleasedReturnValueP11objc_object
00000000000049c1 (__TEXT,__text) non-external __ZL46__arclite_NSDictionary_objectForKeyedSubscriptP12NSDictionaryP13objc_selectorP11objc_object
00000000000049d3 (__TEXT,__text) non-external __ZL47__arclite_NSOrderedSet_objectAtIndexedSubscriptP12NSOrderedSetP13objc_selectorm
000000000000495f (__TEXT,__text) non-external __ZL53__arclite_NSMutableArray_setObject_atIndexedSubscriptP14NSMutableArrayP13objc_selectorP11objc_objectm
00000000000049f7 (__TEXT,__text) non-external __ZL58__arclite_NSMutableDictionary__setObject_forKeyedSubscriptP19NSMutableDictionaryP13objc_selectorP11objc_objectS4_
00000000000049e5 (__TEXT,__text) non-external __ZL58__arclite_NSMutableOrderedSet_setObject_atIndexedSubscriptP19NSMutableOrderedSetP13objc_selectorP11objc_objectm
0000000000008ab8 (__DATA,__bss) non-external __ZL9Demangled
0000000000008ad0 (__DATA,__bss) non-external __ZN12_GLOBAL__N_112ConformancesE
0000000000006da0 (__TEXT,__text) non-external __ZN12_GLOBAL__N_116ConformanceState12cacheFailureEPKvPKN5swift24TargetProtocolDescriptorINS3_9InProcessEEEm
0000000000007140 (__TEXT,__text) non-external __ZN12_GLOBAL__N_116addImageCallbackEPK11mach_header
0000000000007340 (__TEXT,__text) non-external __ZN12_GLOBAL__N_116addImageCallbackEPK11mach_headerl
0000000000006f50 (__TEXT,__text) non-external __ZN12_GLOBAL__N_122override_equalContextsEPKN5swift23TargetContextDescriptorINS0_9InProcessEEES5_
0000000000006af0 (__TEXT,__text) non-external __ZN12_GLOBAL__N_124searchInConformanceCacheEPKN5swift14TargetMetadataINS0_9InProcessEEEPKNS0_24TargetProtocolDescriptorIS2_EE
0000000000006430 (__TEXT,__text) non-external (was a private external) __ZN5swift17getRootSuperclassEv
00000000000061d0 (__TEXT,__text) external __ZN5swift34swift50override_conformsToProtocolEPKNS_14TargetMetadataINS_9InProcessEEEPKNS_24TargetProtocolDescriptorIS1_EEPFPKNS_18TargetWitnessTableIS1_EES4_S8_E
0000000000006470 (__TEXT,__text) external __ZN5swift39swift51override_conformsToSwiftProtocolEPKNS_14TargetMetadataINS_9InProcessEEEPKNS_24TargetProtocolDescriptorIS1_EEN7__swift9__runtime4llvm9StringRefEPFPKNS_35TargetProtocolConformanceDescriptorIS1_EES4_S8_SC_E
0000000000006a90 (__TEXT,__text) non-external __ZN5swift4LazyIN12_GLOBAL__N_116ConformanceStateEE19defaultInitCallbackEPv
0000000000008870 (__DATA,__bss) non-external __ZZL18add_image_hook_ARCPK11mach_headerlE7patches
00000000000089b0 (__DATA,__bss) non-external __ZZL22add_image_hook_swiftV1PK11mach_headerlE7patches
0000000000008840 (__DATA,__bss) non-external __ZZL30add_image_hook_autoreleasepoolPK11mach_headerlE7patches
0000000000008ac0 (__DATA,__bss) non-external __ZZN5swift34swift50override_conformsToProtocolEPKNS_14TargetMetadataINS_9InProcessEEEPKNS_24TargetProtocolDescriptorIS1_EEPFPKNS_18TargetWitnessTableIS1_EES4_S8_EE5token
0000000000008b58 (__DATA,__bss) non-external __ZZZL20getObjCClassMetadataPKN5swift19TargetClassMetadataINS_9InProcessEEEENK3$_1clEvE7TheLazy
0000000000006e90 (__TEXT,__text) non-external __ZZZL20getObjCClassMetadataPKN5swift19TargetClassMetadataINS_9InProcessEEEENK3$_1clEvENUlPvE_8__invokeES6_
0000000000008b78 (__DATA,__bss) non-external __ZZZL24getTypeContextDescriptorPKN5swift14TargetMetadataINS_9InProcessEEEENK3$_2clEvE7TheLazy
0000000000006ee0 (__TEXT,__text) non-external __ZZZL24getTypeContextDescriptorPKN5swift14TargetMetadataINS_9InProcessEEEENK3$_2clEvENUlPvE_8__invokeES6_
0000000000008b88 (__DATA,__bss) non-external __ZZZL26getExistentialTypeMetadataN5swift23ProtocolClassConstraintEPKNS_14TargetMetadataINS_9InProcessEEEmPKNS_27TargetProtocolDescriptorRefIS2_EEENK3$_3clEvE7TheLazy
0000000000006f20 (__TEXT,__text) non-external __ZZZL26getExistentialTypeMetadataN5swift23ProtocolClassConstraintEPKNS_14TargetMetadataINS_9InProcessEEEmPKNS_27TargetProtocolDescriptorRefIS2_EEENK3$_3clEvENUlPvE_8__invokeESB_
0000000000008b68 (__DATA,__bss) non-external __ZZZN5swift17getRootSuperclassEvENK3$_0clEvE7TheLazy
0000000000006ec0 (__TEXT,__text) non-external __ZZZN5swift17getRootSuperclassEvENK3$_0clEvENUlPvE_8__invokeES1_
(undefined) external ___stack_chk_fail (from libSystem)
(undefined) external ___stack_chk_guard (from libSystem)
0000000000007c00 (__TEXT,__const) non-external (was a private external) ___swift_reflection_version
(undefined) external __dyld_register_func_for_add_image (from libSystem)
(undefined) external __objc_empty_cache (from libobjc)
(undefined) external __objc_empty_vtable (from libobjc)
00000000000086b0 (__DATA,__data) non-external (was a private external) __swift_FORCE_LOAD_$_swiftCompatibility50
00000000000082d0 (__DATA,__const) non-external (was a private external) __swift_FORCE_LOAD_$_swiftCompatibility50_$_LibTest
00000000000086b1 (__DATA,__data) non-external (was a private external) __swift_FORCE_LOAD_$_swiftCompatibility51
00000000000082d8 (__DATA,__const) non-external (was a private external) __swift_FORCE_LOAD_$_swiftCompatibility51_$_LibTest
00000000000086b2 (__DATA,__data) non-external (was a private external) __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements
00000000000082e0 (__DATA,__const) non-external (was a private external) __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_LibTest
(undefined) external _abort (from libSystem)
(undefined) external _asprintf (from libSystem)
(undefined) external _bzero (from libSystem)
(undefined) external _calloc (from libSystem)
(undefined) external _class_addMethod (from libobjc)
(undefined) weak external _class_addProperty (from libobjc)
(undefined) external _class_addProtocol (from libobjc)
(undefined) external _class_getInstanceMethod (from libobjc)
(undefined) external _class_getInstanceSize (from libobjc)
(undefined) external _class_getInstanceVariable (from libobjc)
(undefined) external _class_getIvarLayout (from libobjc)
(undefined) external _class_getName (from libobjc)
(undefined) external _class_getSuperclass (from libobjc)
(undefined) external _class_isMetaClass (from libobjc)
(undefined) external _class_replaceMethod (from libobjc)
(undefined) external _class_respondsToSelector (from libobjc)
(undefined) external _dispatch_once_f (from libSystem)
(undefined) external _dlsym (from libSystem)
(undefined) external _free (from libSystem)
(undefined) external _getsectiondata (from libSystem)
(undefined) external _hash_create (from libSystem)
(undefined) external _hash_search (from libSystem)
(undefined) external _ivar_getName (from libobjc)
(undefined) external _ivar_getOffset (from libobjc)
(undefined) external _kCFCoreFoundationVersionNumber (from CoreFoundation)
(undefined) external _malloc (from libSystem)
(undefined) external _memcmp (from libSystem)
(undefined) external _memcpy (from libSystem)
(undefined) external _memmove (from libSystem)
(undefined) external _method_setImplementation (from libobjc)
(undefined) external _objc_allocateClassPair (from libobjc)
(undefined) weak external _objc_autoreleasePoolPush (from libobjc)
(undefined) external _objc_constructInstance (from libobjc)
(undefined) external _objc_copyClassNamesForImage (from libobjc)
(undefined) external _objc_getClass (from libobjc)
(undefined) external _objc_getMetaClass (from libobjc)
(undefined) external _objc_getProtocol (from libobjc)
(undefined) external _objc_getRequiredClass (from libobjc)
(undefined) external _objc_initializeClassPair (from libobjc)
(undefined) weak external _objc_loadClassref (from libobjc)
(undefined) external _objc_lookUpClass (from libobjc)
(undefined) external _objc_msgSend (from libobjc)
(undefined) weak external _objc_readClassPair (from libobjc)
(undefined) external _objc_registerClassPair (from libobjc)
(undefined) weak external _objc_retain (from libobjc)
(undefined) weak external _objc_setHook_getClass (from libobjc)
(undefined) external _object_getClass (from libobjc)
(undefined) external _object_getIndexedIvars (from libobjc)
(undefined) external _object_getIvar (from libobjc)
(undefined) external _object_setIvar (from libobjc)
(undefined) external _posix_memalign (from libSystem)
(undefined) weak external _property_copyAttributeList (from libobjc)
(undefined) external _protocol_getMethodDescription (from libobjc)
(undefined) external _protocol_getName (from libobjc)
(undefined) external _pthread_getspecific (from libSystem)
(undefined) external _pthread_mutex_init (from libSystem)
(undefined) external _pthread_mutex_lock (from libSystem)
(undefined) external _pthread_mutex_unlock (from libSystem)
(undefined) external _pthread_setspecific (from libSystem)
(undefined) external _realloc (from libSystem)
(undefined) external _sel_getUid (from libobjc)
(undefined) external _strcmp (from libSystem)
(undefined) external _strlen (from libSystem)
(undefined) external _strncmp (from libSystem)
(undefined) external _swift_bridgeObjectRelease (from libswiftCore)
(undefined) weak external _swift_getFunctionReplacement (from libswiftCore)
0000000000007350 (__TEXT,__text) non-external (was a private external) _swift_getFunctionReplacement50
(undefined) weak external _swift_getOrigOfReplaceable (from libswiftCore)
00000000000073a0 (__TEXT,__text) non-external (was a private external) _swift_getOrigOfReplaceable50
(undefined) external dyld_stub_binder (from libSystem)
What can be unsafe here?
I no longer had the issue since it was fixed in the beta. Make sure you are using the right command line tools using Xcode-select or via the Xcode settings.
I have the same version without any issue. Did you try to clear any build cache ? Maybe one of your package has not been rebuilt since you updated to a fixed toolchain, I guess it could be in a dependency too.
I've updated a week ago or so. I've tried cleaning the derived data folder, reset package versions, resolve package versions and rebuild the app. At first, I thought that it might be connected with the fact that I develop SPM modules for my project as a git submodule. Then, I checked, and I can confirm that other libs produce this error too
I can cofirm same behaviour. I tryed everything. Nothing helps. For watch app is SPM package automatically marked as unsafe..
I'm still able to reproduce the issue with Xcode 13.2 beta 1.
Xcode 13.2 beta 2 did not resolve the issue for me, unfortunately. I can still reproduce it with my sample project (watch app + dynamic package).
I was able to silence the warnings by adding "-Xlinker -no_application_extension"
to OTHER_LDFLAGS
in my project settings. Alternatively, you can also specify this setting in your Package.swift
file:
linkerSettings: [
.unsafeFlags(["-Xlinker", "-no_application_extension"])
]),
I will report back if I encounter any issues with this workaround.
I also have this problem, and I don't understand how the linker option "-no_application_extension"
can help me to get rid of the warning.
My project setup is (a bit simplified) like this: I have an iOS app with an app extension, let's call them MyApp and MyAppExtension. I also have a framework project, let's call it MyFramework. MyFramework is linked to the Swift Package AppAuth, specifically the target AppAuthCore which is safe for app extensions.
MyFramework is marked as safe for app extensions, and is itself linked to MyApp and MyAppExtension, as a dynamic library. The MyApp and MyFramework projects are part of a workspace in Xcode.
Now when I build the MyApp target in the workspace, I get the warning about linking to a library that is not safe for app extensions. This warning is from the linker when linking AppAuthCore to MyFramework. (Interesting side note: I do not get the warning when I just open the MyFramework project and build just that target.)
However, when I add the linker flag "-no_application_extension"
to the MyFramework project, I do not get the warning for MyFramework. Instead, I get the warning when linking MyFramework to MyAppExtension. Because that linker flag, if I understand correctly, explicitly sets the framework as not safe for app extensions. But I do need to use it with an app extension, and it should be safe.
What am I missing here?
I can't believe that was the issue. Thank you.
I can still reproduce this issue in the latest Xcode 13.2.1. I haven't encountered any issues with my workaround so far.
@holgerde You probably need to set this flag in both your app extension target and your framework target. This is how it looks in my project:
I've found the -no_application_extension
flag in the man page of the ld
command:
-no_application_extension
Specifies that the code is being linked is not safe for use in an application extension. For instance, can be used when
creating a framework that should not be used in an application extension.
Was this ever fixed? We are having this issue on Xcode 13.3.1...
Not fixed yet. The warning is still present in Xcode 14.0 beta 1.
We ran into an issue with our library when adding tvOS support. This is on Xcode 13.2.1. We suspect that the changes weren't reverted for the tvOSApplicationExtension case. I have filed a ticket here: Feedback Assistant
In Xcode 13.4.1, I'm still getting this warning.
I found a promising almost-solution:
linkerSettings: [
.unsafeFlags(["-fapplication-extension"])
]
Putting this in my Swift package gets rid of the warning about that particular Swift package.
However due to a bizarre Xcode bug where the unsafe flags of any Swift package will override the proeject settings of any Xcode projects that link to them, now my app and other frameworks that depend on this package are acting like the APPLICATION_EXTENSION_API_ONLY
flag is set to YES
when really it's set to NO
.
Apple really needs to open-source Xcode... it's ridiculous that these bugs persist for year after year. The problem with closed-source is that it results in managers deciding which bugs get fixed, and well, here we are.
Note: my package doesn't even use any UIApplication methods.
The only thing remotely that could maybe qualify as not proper for App Extensions might be DispatchQueue.main? But I removed that and the error doesn't go away.
The warning does even say which line of code is supposedly unsafe to use in an application extension.
I'm not sure what good this would do, since Xcode already believes my package is not safe for application extensions. Yet none of the code in it is actually unsafe. What we need is the opposite of this: a way to declare that the Swift Package is safe without that setting being inherited by anything that links to the package.
Note: I confirm the following have no effect (the flags do get added in the compile steps but they do not result in the warning going away):
swiftSettings: [
.define("APPLICATION_EXTENSION_API_ONLY=YES"),
.unsafeFlags(["-application-extension"]),
],
You could think that adding the -fapplication-extension
flag to the linker settings of your target (to get rid of the warning) while at the same time setting the -no_application_extension
flag on the Other Linker Flags of your app target (to avoid raising warnings if you link your app to other frameworks that are not available for use in app extensions) would get you the expected behaviour.
Unfortunately, after test, it actually disables completely any linker check. Your framework would be marked as safe for use in app extensions yet could still call UIApplication.shared
without the linker raising an eyebrow...
Is there a way to specify
swiftSettings: [
.define("APPLICATION_EXTENSION_API_ONLY=YES"),
]),
We figured out to use
swiftSettings: [
.unsafeFlags(["-Xfrontend", "-application-extension"])
],
linkerSettings: [
.unsafeFlags(["-Xlinker", "-application_extension"])
]
The first setting is for giving you a nice red compile error in Xcode on the spot if you try to use some unsafe API. The second setting tells the linker 'this is an extension safe package' so you won't get warnings if you link the package to an extension target or another framework that is extension safe.