Preview not working: linker command failed
MatteCarra opened this issue · 9 comments
Since I started developing with XCode 12 beta I have been unable to use the preview tool for my app.
When I try to render the preview the linking process fails with exit code 1:
ld: in /PATH_TO_FILE/libcrypto.a(bio_b64.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have built openssl without http2 support.
The project is building and running fine for the emulator and for iphones and ipads. The preview is the only thing that is not working.
Please let me know if you need any information.
Thanks a lot for your useful scripts!
Hi @MatteCarra thanks for the kind note!
As to the error, are you using the Mac Catalyst libraries that are built by the script (use ./build.sh -m
) or are you using the standard iOS +Mac fat binaries?
The Catalyst binaries should be stored here:
openssl/Catalyst/lib/libcrypto.a are: x86_64
openssl/Catalyst/lib/libssl.a are: x86_64
nghttp2/lib/libnghttp2_Catalyst.a are: x86_64
curl/lib/libcurl_Catalyst.a are: x86_64
I haven't been using these so I'll need to try to replicate the error you are getting.
Ok @MatteCarra - I'm able to get a build without errors.
In addition to the existing FAT libraries you have for iOS and the iOS-simulator, you should build the Mac Catalyst libraries and copy the Catalyst libraries to your project (replace ~/project/libs with your real project folder):
./build -m # This will build with Mac Catalyst libraries
# Copy the fat (iOS and iOS Simulator) libraries to your project
cp curl/lib/libcurl_iOS-fat.a ~/project/libs/libcurl.a
cp nghttp2/lib/libnghttp2_iOS-fat.a ~/project/libs/libnghttp2.a
cp openssl/iOS-fat/lib/libcrypto.a ~/project/libs/libcrypto.a
cp openssl/iOS-fat/lib/libssl.a ~/project/libs//libssl.a
# Copy the Catalyst libraries to your project
cp openssl/openssl-ios-x86_64-maccatalyst.a ~/project/libs
cp nghttp2/lib/libnghttp2_Catalyst.a ~/project/libs
cp curl/lib/libcurl_Catalyst.a ~/project/libs
Drag these *.a
file into your project under the "Frameworks" folder. In the project "General" tab, update the libraries to be the right "Platform" with iOS select for the FAT libraries and macOS for the Catalyst binaries:
I've updated the iOS example so that it automatically builds for Mac Catalyst as well (I'll check it in tonight):
Thanks for your answer!
I'm currently using the standard iOS +Mac fat binaries, no Mac Catalyst.
I'm almost sure I have the *.a files in the section you are mentioning, but I will have a look as soon as possible.
I want to make it clear that the app builds and runs fine on the simulator or device, but only fails to build in the UI preview (in my case a simple SwiftUI project).
I can confirm that the issue is present in your example project as well.
Steps to reproduce:
- Change the iOS Development Target to >= iOS 13.0 ( I selected 14.0), in the Project settings
- Right click -> Add file -> Add SwiftUI file
- Resume the preview of the SwiftUI preview in the file you just created.
The build process will fail with the said issue.
I wouldn't rule out the possibility that this is an xcode bug.
Thanks again!
Ah! I see. I can only set target to 13.7. I'm still on Xcode 11.7. I'll install a beta image and give it a try. Thanks, Matteo.
Thanks!
I just wanted to inform that xcode 12 stable will most likely be released today
Xcode 12 GM seed has fixed the issue.
It was an xcode issue all along.
Thanks for your help!
That's great news! Thanks, Matteo.
I have a request - I would love to add a Swift openssl/libcurl example to this repo. Would you be interested in helping? If so, submit a pull request or send me a note!
Stay safe!
Jason
I think I can do that!
I will update you as soon as I have something ready!