BelledonneCommunications / linphone-iphone

Linphone is a free VoIP and video softphone based on the SIP protocol. Mirror of linphone-iphone (git://git.linphone.org/linphone-iphone.git)
http://linphone.org
GNU General Public License v3.0
580 stars 344 forks source link

Link failed on Mac M1 with last version #818

Open flyingcong opened 2 years ago

flyingcong commented 2 years ago

I tried to build linphone-iphone with local linphone sdk with Xcode generator. I'v gotten the last versions by git, and built linphone-iphone in Xcode 13. And all things went right, except the link step. The only error in Xcode list as below:

Ld /Users/test/Library/Developer/Xcode/DerivedData/linphone-afdpkwjhekpmqybowkvxlohvgcsj/Build/Products/Debug-iphonesimulator/linphone-sdk/linphonesw.framework/linphonesw normal (in target 'linphone-sdk' from project 'Pods')
    cd /Users/test/linphone-iphone/Pods

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios9.0-simulator -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.4.sdk -L/Users/test/Library/Developer/Xcode/DerivedData/linphone-afdpkwjhekpmqybowkvxlohvgcsj/Build/Products/Debug-iphonesimulator/linphone-sdk -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.4.sdk/usr/lib/swift -F/Users/test/Library/Developer/Xcode/DerivedData/linphone-afdpkwjhekpmqybowkvxlohvgcsj/Build/Products/Debug-iphonesimulator/linphone-sdk -F/Users/test/linphone-iphone/Pods/../../linphone-sdk/build/linphone-sdk/apple-darwin/Frameworks -filelist /Users/test/Library/Developer/Xcode/DerivedData/linphone-afdpkwjhekpmqybowkvxlohvgcsj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/linphone-sdk.build/Objects-normal/arm64/linphonesw.LinkFileList -install_name @rpath/linphonesw.framework/linphonesw -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/test/Library/Developer/Xcode/DerivedData/linphone-afdpkwjhekpmqybowkvxlohvgcsj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/linphone-sdk.build/Objects-normal/arm64/linphonesw_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/test/Library/Developer/Xcode/DerivedData/linphone-afdpkwjhekpmqybowkvxlohvgcsj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/linphone-sdk.build/Objects-normal/arm64/linphonesw.swiftmodule -framework bctoolbox -framework bctoolbox-ios -framework belle-sip -framework linphone -framework bctoolbox -framework bctoolbox-ios -framework belle-sip -framework Foundation -framework linphone -Xlinker -no_adhoc_codesign -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/test/Library/Developer/Xcode/DerivedData/linphone-afdpkwjhekpmqybowkvxlohvgcsj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/linphone-sdk.build/Objects-normal/arm64/linphonesw_dependency_info.dat -o /Users/test/Library/Developer/Xcode/DerivedData/linphone-afdpkwjhekpmqybowkvxlohvgcsj/Build/Products/Debug-iphonesimulator/linphone-sdk/linphonesw.framework/linphonesw

ld: building for iOS Simulator, but linking in dylib built for iOS, file '/Users/test/linphone-sdk/build/linphone-sdk/apple-darwin/Frameworks/bctoolbox.framework/bctoolbox' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

How can i resolve this problem?

tharwat commented 2 years ago

I was able to fix it by:

  1. Adding the following to my Podfile:

post_install do |installer|

  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end

Screen Shot 2022-04-07 at 21 43 01

Then remove the Podfile.lock and run pod install

  1. In the Build Setting, All search for Architectures, and then In the Excluded Architecture add 'arm64' to Debug, Distribution, Adhoc, and Release for all Targets

Screen Shot 2022-04-07 at 21 39 36

flyingcong commented 2 years ago

Thanks for your step by step guidance. It works for me.

RaviMalviya commented 2 years ago

In the above answer In the 2nd Step, Screenshot shows "Any SDK" in "Excluded Architectures", it must be "Any iOS Simulator SDK" instead. otherwise, For every SDK either iOS Simulator or iOS Device, arm64 will be excluded, As we know Any iOS device only runs upon arm64, So your build will be failed on the iOS device.

mattsegura commented 1 year ago

In the above answer In the 2nd Step, Screenshot shows "Any SDK" in "Excluded Architectures", it must be "Any iOS Simulator SDK" instead. otherwise, For every SDK either iOS Simulator or iOS Device, arm64 will be excluded, As we know Any iOS device only runs upon arm64, So your build will be failed on the iOS device.

currently running into the issue by completely excluding arm64 and trying to build on my local iOS device, works fine through emulator though

rvgeerligs commented 8 months ago

I downloaded zip and pod install generated Pod installation complete! There are 7 dependencies from the Podfile and 7 total pods installed.