mapbox-navigation-ios icon indicating copy to clipboard operation
mapbox-navigation-ios copied to clipboard

Linker error with Xcode 12 and CocoaPods 1.9.3 — building for iOS, but linking in dylib file

Open ehmjaysee opened this issue 4 years ago • 35 comments

Progress. I can now install v1.0.0 with cocoapods without error. However I cannot build for any iOS target other than simulator. I get the error:

ld: building for iOS, but linking in dylib file (/Users/mjc/Library/Developer/Xcode/DerivedData/test-eogwsxynjracdvgsbxwkmhvsrfzy/Build/Products/Debug-iphoneos/MapboxCommon.framework/MapboxCommon) built for iOS Simulator, file '/Users/mjc/Library/Developer/Xcode/DerivedData/test-eogwsxynjracdvgsbxwkmhvsrfzy/Build/Products/Debug-iphoneos/MapboxCommon.framework/MapboxCommon' for architecture arm64

I tested this by creating a new empty Xcode project and a new Podfile:

source 'https://github.com/CocoaPods/Specs.git'

# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'

inhibit_all_warnings!

target 'test' do
  use_frameworks!
  pod 'MapboxNavigation', '~> 1.0'
end


Using Xcode 12.0.1 pod version 1.9.3

ehmjaysee avatar Oct 02 '20 13:10 ehmjaysee

Hi, glad to hear your making progress. This linker error looks like CocoaPods/CocoaPods#10026. Upgrading to CocoaPods 1.10.rc.1 should fix the error. Please let us know if it persists after upgrading CocoaPods.

1ec5 avatar Oct 02 '20 14:10 1ec5

Confirmed, cocoa pods 1.10.rc.1 fixed the problem

ehmjaysee avatar Oct 02 '20 15:10 ehmjaysee

@1ec5 @ehmjaysee I have the same problem, installed 1.10.0.rc.1 but I still have the same problem, can build for simulator but cannot for my device

MarcoCarnevali avatar Oct 02 '20 18:10 MarcoCarnevali

@MarcoCarnevali, did you run pod install or pod update after upgrading CocoaPods? I wonder if it would make any difference one way or another. Which specific Xcode version and device model are you building for? Debug or Release configuration?

1ec5 avatar Oct 02 '20 19:10 1ec5

Here is what I did after I upgraded to 1.10.rc.1

  1. Edit Podfile and comment all lines that reference anything with MapBox
  2. pod install (this will remove Mapbox from the project)
  3. rm -rf Pods Podfile.lock
  4. Edit Podfile and un-command all lines that reference Mapbox
  5. pod install

ehmjaysee avatar Oct 02 '20 19:10 ehmjaysee

@1ec5 yes, I even deintegrated pod and re-installed from scratch. Both debug and release scheme, Xcode 12.0.1, iPhone 8 Plus with iOS 13 @ehmjaysee thank you, I’ll try and let you know but should be no difference with what I did

MarcoCarnevali avatar Oct 02 '20 19:10 MarcoCarnevali

Are you able to build for the “Any iOS Device” target? What are the values of the following build settings in your application target (as applicable)?

  • ARCHS
  • ONLY_ACTIVE_ARCH
  • EXCLUDED_ARCHS
  • EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200

1ec5 avatar Oct 02 '20 20:10 1ec5

@1ec5 no, can't build for Any iOS Device either. Values are: Architectures = ARCHS_STANDARD ONLY_ACTIVE_ARCH = YES EXCLUDED_ARCHS = Any iOS Simulator SDK -> arm64

MarcoCarnevali avatar Oct 03 '20 08:10 MarcoCarnevali

Seems that I fixed it, after several different try I was able to make it work, seems that you have to pod deintegrate, remove derived data, pod install and it should work! Thank you guys

MarcoCarnevali avatar Oct 03 '20 09:10 MarcoCarnevali

Actually little update, I can build it for my simulator and device but I cannot archive it. odd issue, archive is successfull but I can't locate it on the finder or organizer.

MarcoCarnevali avatar Oct 03 '20 17:10 MarcoCarnevali

Seems that I fixed it, after several different try I was able to make it work, seems that you have to pod deintegrate, remove derived data, pod install and it should work! Thank you guys

Hi, I try this workaround, still not work. My error is:

Library not loaded: @rpath/MapboxCommon.framework/MapboxCommon
  Referenced from: /private/var/containers/Bundle/Application/BF61D58B-AD39-4544-8AA0-614015AAD9B0/Micro Mobility.app/Micro Mobility
  Reason: no suitable image found.  Did find:
	/private/var/containers/Bundle/Application/BF61D58B-AD39-4544-8AA0-614015AAD9B0/Micro Mobility.app/Frameworks/MapboxCommon.framework/MapboxCommon: mach-o, but not built for platform iOS
	/private/var/containers/Bundle/Application/BF61D58B-AD39-4544-8AA0-614015AAD9B0/Micro Mobility.app/Frameworks/MapboxCommon.framework/MapboxCommon: stat() failed with errno=25
	/private/var/containers/Bundle/Application/BF61D58B-AD39-4544-8AA0-614015AAD9B0/Micro Mobility.app/Frameworks/MapboxCommon.framework/MapboxCommon: mach-o, but not built for platform iOS
	/private/var/containers/Bundle/Application/BF61D58B-AD39-4544-8AA0-614015AAD9B0/Micro Mobility.app/Frameworks/MapboxCommon.framework/MapboxCommon: stat() failed with errno=25
	/private/var/containers/Bundle/Application/BF61D58B-AD39-4544-8AA0-614015AAD9B0/Micro Mobility.app/Frameworks/MapboxCommon.framework/MapboxCommon: mach-o, but not built for platform iOS
	/private/var/containers/Bundle/Application/BF61D58B-AD39-4544-8AA0-614015AAD9B0/Micro Mobility.app/Frameworks/MapboxCommon.framework/MapboxCommon: stat() failed with errno=25

Do you want also my pod file?

ghost avatar Oct 05 '20 10:10 ghost

@lfongaroScp that error is a different one I think it's better if you open a new issue

MarcoCarnevali avatar Oct 05 '20 10:10 MarcoCarnevali

Actually little update, I can build it for my simulator and device but I cannot archive it. odd issue, archive is successfull but I can't locate it on the finder or organizer.

@MarcoCarnevali, I have the same problem as you

Knapiii avatar Oct 05 '20 12:10 Knapiii

https://stackoverflow.com/a/63955114

This post solved the problem for me

Knapiii avatar Oct 05 '20 12:10 Knapiii

https://stackoverflow.com/a/63955114

@Knapiii this fixed your problem with the archive?

MarcoCarnevali avatar Oct 05 '20 14:10 MarcoCarnevali

https://stackoverflow.com/a/63955114

This post solved the problem for me

This sounds similar to the workaround we put into #2667. I suppose it’s possible that CocoaPods fails to apply the workaround sometimes, in which case it might work to deintegrate and reintegrate as in https://github.com/mapbox/mapbox-navigation-ios/issues/2674#issuecomment-703074011.

Actually little update, I can build it for my simulator and device but I cannot archive it. odd issue, archive is successfull but I can't locate it on the finder or organizer.

That’s quite strange. Does Xcode print out anything to the system console or build log related to the archive?

1ec5 avatar Oct 05 '20 15:10 1ec5

@1ec5 nothing there and the archive is successful. I can find it on finder but when I open it : The archive could be corrupted or unreadable

MarcoCarnevali avatar Oct 05 '20 15:10 MarcoCarnevali

Same problem here with Cocoapods 1.10.0.rc.1 framework not found MapboxCommon when attempting to build on the sim. Is there any way to get Mapbox to work with Cocoapods & Xc 12? Specifying the pre-release version (that supposedly has as fix) also didn't work (even after deintegrating and clearing Derived Data): pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :tag => 'v1.1.0-beta.1' pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :tag => 'v1.1.0-beta.1'

  • When I try a new project with a podfile with just one entry: pod 'MapboxNavigation', '~> 1.0' it fails.
  • When I downgrade from Cocoapods 1.10.0.rc.1 to 1.9.3 for the same new project, it fails (in that case I get framework not found MapboxMobileEvents).
  • When I try to exclude arm64 it fails to build for simulator and device.

aodhol avatar Oct 10 '20 13:10 aodhol

The archive could be corrupted or unreadable

By way of an update, this issue was resolved in #2677 by removing a build phase that was incompatible with CocoaPods.

When I downgrade from Cocoapods 1.10.0.rc.1 to 1.9.3 for the same new project, it fails (in that case I get framework not found MapboxMobileEvents).

This is expected, because of CocoaPods/CocoaPods#10026.

When I try a new project with a podfile with just one entry: pod 'MapboxNavigation', '~> 1.0' it fails.

This is unexpected. 😕 https://github.com/mapbox/mapbox-navigation-ios/issues/2674#issuecomment-702950955 lists some build settings; if you provide that information about your project here, it might be clearer whether the workaround is being applied correctly.

1ec5 avatar Oct 13 '20 23:10 1ec5

The same struggle here. The app was compiling, archiving, and working alright. Last working build is still available on Testflight https://testflight.apple.com/join/1TpdHGJ4

Then I changed package manager, from Carthage to Cocoapod.

It works in the simulator. As soon as I try the real device, I get tons of weird errors.

I have CocoaPods 1.10.rc.1 I got this: building for iOS, but linking in dylib file Build/Products/Debug-iphoneos/MapboxCommon.framework/MapboxCommon) built for iOS Simulator, file Build/Products/Debug-iphoneos/MapboxCommon.framework/MapboxCommon' for architecture arm64

I tried this: https://stackoverflow.com/questions/24993752/os-x-framework-library-not-loaded-image-not-found

And this https://stackoverflow.com/questions/2718246/xcode-warning-multiple-build-commands-for-output-file

And this https://stackoverflow.com/questions/34433818/xcode-7-2-successful-archives-will-not-show-in-organizer-but-will-show-in-archi/45925542#45925542

byvalentino avatar Oct 13 '20 23:10 byvalentino

@byvalentino, what Xcode version are you using, and which device were you building for? What are your values for the build settings listed in https://github.com/mapbox/mapbox-navigation-ios/issues/2674#issuecomment-702950955? For what it’s worth, we’ve gotten fewer reports of problems with Carthage, provided that you use the workaround in #2676.

1ec5 avatar Oct 13 '20 23:10 1ec5

what Xcode version are you using, Xcode Version 12.0.1 (12A7300)

and which device were you building for?

iPhone 8, iOS 13.7

What are your values for the build settings listed in #2674 (comment)? Standard architectures - $(ARCHS_STANDARD) as for

@1ec5 no, can't build for Any iOS Device either. Values are: Architectures = ARCHS_STANDARD ONLY_ACTIVE_ARCH = YES EXCLUDED_ARCHS = Any iOS Simulator SDK -> arm64

byvalentino avatar Oct 13 '20 23:10 byvalentino

I think the workaround we applied in the podspec is supposed to clear out EXCLUDED_ARCHS, replacing it with EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200. My own test project ends up with:

EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = arm64 arm64e armv7 armv7s armv6 armv8

This project builds without errors in Xcode 12.0.1 and runs on an iPhone 8 device running iOS 13.7 in both the Debug and Release configurations. These are some of the cases we tested before landing the workaround in #2667, so I wonder if the issue is that the workaround isn’t being applied. Have you also tried deiniting and reinstalling the project using CocoaPods like the others above?

1ec5 avatar Oct 13 '20 23:10 1ec5

This linker error looks like CocoaPods/CocoaPods#10026. Upgrading to CocoaPods 1.10.rc.1 should fix the error.

If anyone has been holding off to avoid using a prerelease version of CocoaPods, v1.10.0 just came out and it includes the fix for CocoaPods/CocoaPods#10026.

1ec5 avatar Oct 21 '20 18:10 1ec5

My iPhone iOS devices are not working with my account please help me my iPhone 11 iPhone pro Max

habibahabiba77 avatar Nov 04 '20 22:11 habibahabiba77

Update your Xcode to 12.2 (if you are using macOS Big Sur) and install cocoapods version 1.10.rc.1. It will fix the error.

Stack Overflow

teddichiiwa avatar Nov 18 '20 05:11 teddichiiwa

Problem alive and kicking for me. It started with Xcode 12, macOS Catalina, Cocoapods 1.10.rc.1, and Mapbox for native iOS (thanks @1ec5). https://github.com/mapbox/mapbox-navigation-ios/issues/2674#issuecomment-708057307

Then, it continued with Xcode 12.2, macOS Big Sur, Cocoapods --pre, and Mapbox for Native React. https://github.com/CocoaPods/CocoaPods/issues/10135#issuecomment-730722345

Tried all these https://stackoverflow.com/questions/34433818/xcode-7-2-successful-archives-will-not-show-in-organizer-but-will-show-in-archi/45925542#45925542

Now the project compiles and runs only on a real device, not on iOS simulator. Builds are successful when archiving; however, the generated archive is corrupted and it does not show in the Organizer, thus the App can't be distributed on Appstore.

Just removing the following link from Podfile fixes the problem of corrupted Archives, but the App results amputated, as it no longer includes the Map.

pod 'react-native-mapbox-gl', :path => '../node_modules/@react-native-mapbox-gl/maps'

Post on stackoverflow

byvalentino avatar Nov 20 '20 05:11 byvalentino

If you’re using CocoaPods and your application target has a custom value for the EXCLUDED_ARCHS build setting in any configuration, chances are that that build setting is causing any linker errors you’re seeing (and presumably any missing bits in the archive). In https://github.com/mapbox/mapbox-gl-native-ios/pull/549#issuecomment-732638768, I found that even having the build setting set to a blank value is problematic, because it overwrites the build setting that the podspec tries to apply. If this build setting is specified but you don’t remember needing to tweak it for application-specific reasons, try deleting the build setting.

1ec5 avatar Nov 24 '20 07:11 1ec5

We just hotfixed the map SDK v6.2.2 and v6.3.0 podspecs on CocoaPods trunk to address another linker error that could occur, but you may need to wipe your CocoaPods caches to obtain the fix: https://github.com/mapbox/mapbox-gl-native-ios/pull/549#issuecomment-733822435.

1ec5 avatar Nov 25 '20 19:11 1ec5

I found a fix that is an abomination, but it works. At the same time, since it works, the problem seems simple. How to fix it? https://stackoverflow.com/questions/64933102/xcode-builds-successfully-a-corrupted-archive-not-showing-in-organizer-as-soon/64989153#64989153

byvalentino avatar Nov 27 '20 14:11 byvalentino