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

[SR-9821] Swift Static Standard Library is being treated as private api #52238

Closed
swift-ci opened this issue Jan 31, 2019 · 1 comment
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-9821
Radar None
Original Reporter KarosLi (JIRA User)
Type Bug
Status Resolved
Resolution Invalid
Environment

Xcode 10.1

Swift 4.2

Mac OS 10.14

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 8a8e795235bb7f1b9ab39ca22458b87d

relates to:

  • SR-730 Flag to statically link Swift standard library

Issue Description:

Since Xcode 10 with swift 4.2 support swift static standard library, so I try it in my oc&swift mix project. And everything is ok in my debug and testing phase. But once I upload I to apple connect, it will give me following issue:

Non-public API usage:
  •  The app references non-public symbols in LeoaoApp: __NSGetMachExecuteHeader, _unorm2_getNFCInstance, _unorm2_hasBoundaryBefore, _unorm2_normalize, _unorm2_spanQuickCheckYes

But if I upload build by using swift dynamic standard library, I can upload build successfully.

So I use nm tool to check which library contains these symbol.

nm -u /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/iphoneos/libswiftCore.a >> symbols.txt

I found that libswiftCore.a contains these private api.

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/iphoneos/libswiftCore.a:ImageInspectionMachO.cpp.o:
         U __NSGetMachExecuteHeader
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/iphoneos/libswiftCore.a:UnicodeNormalization.cpp.o:
         U _u_hasBinaryProperty
         U _u_isdefined
         U _ubrk_close
         U _ubrk_following
         U _ubrk_open
         U _ubrk_preceding
         U _ubrk_setText
         U _unorm2_getNFCInstance
         U _unorm2_hasBoundaryBefore
         U _unorm2_normalize
         U _unorm2_spanQuickCheckYes

Continue, I try to print libswiftCore.dyld symbols. The dynamic symbols also contains these private api.

nm -u /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib >> dynamicsymbols.txt
_unorm2_getNFCInstance _unorm2_hasBoundaryBefore _unorm2_normalize _unorm2_spanQuickCheckYes

So I don't know why apple treat swift static standard library as a private api not swift dynamic standard library. Could any one help me to know this? Very thanks.

Following is my steps for to involve it:

1. add swift static standard library path to library search path.

$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)

2. add force_load to other link flags. It will make my swift code link to swift static standard library.

-force_load
$(TOOLCHAIN_DIR)/usr/lib/arc/libarclite_iphoneos.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftCoreFoundation.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftObjectiveC.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftDispatch.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftQuartzCore.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftCore.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftCoreGraphics.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftMetal.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftFoundation.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftDarwin.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftUIKit.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftSwiftOnoneSupport.a
-force_load
$(TOOLCHAIN_DIR)/usr/lib/swift_static/$(PLATFORM_NAME)/libswiftCoreImage.a
  1. add libc++.tbd to link library in build phase.

  2. set Always Embed Swift Standard Libraries to NO. Because we don't need swift dynamic swift standard library any more. If you still set it to YES, the apple connect process will give the following error

Invalid Swift Support - The SwiftSupport folder is empty. Rebuild your app using the current public (GM) version of Xcode and resubmit it. 
@belkadan
Copy link
Contributor

Hi, Karos. The static standard libraries are not supported for iOS (for various reasons, not just this); it is a mistake that they were shipped at all. Sorry for the trouble.

For future issues with the App Store, please file at https://bugreport.apple.com; the Swift Open Source project usually doesn't have control over these things.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

2 participants