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

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

Open
ehmjaysee opened this issue Oct 2, 2020 · 35 comments
Labels
build Issues related to builds and dependency management. jira-sync-complete

Comments

@ehmjaysee
Copy link

ehmjaysee commented Oct 2, 2020

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

@1ec5 1ec5 added build Issues related to builds and dependency management. CocoaPods labels Oct 2, 2020
@1ec5
Copy link
Contributor

1ec5 commented Oct 2, 2020

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 1ec5 changed the title Link error with v1.0.0 Linker error with Xcode 12 and CocoaPods 1.9.3 — building for iOS, but linking in dylib file Oct 2, 2020
@1ec5 1ec5 pinned this issue Oct 2, 2020
@ehmjaysee
Copy link
Author

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

@MarcoCarnevali
Copy link

@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

@1ec5
Copy link
Contributor

1ec5 commented Oct 2, 2020

@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?

@ehmjaysee
Copy link
Author

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

@MarcoCarnevali
Copy link

@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

@1ec5
Copy link
Contributor

1ec5 commented Oct 2, 2020

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

@MarcoCarnevali
Copy link

@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
Copy link

MarcoCarnevali commented Oct 3, 2020

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
Copy link

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.

@ghost
Copy link

ghost commented Oct 5, 2020

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?

@MarcoCarnevali
Copy link

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

@Knapiii
Copy link

Knapiii commented Oct 5, 2020

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
Copy link

Knapiii commented Oct 5, 2020

https://stackoverflow.com/a/63955114

This post solved the problem for me

@MarcoCarnevali
Copy link

https://stackoverflow.com/a/63955114

@Knapiii this fixed your problem with the archive?

@1ec5
Copy link
Contributor

1ec5 commented Oct 5, 2020

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 #2674 (comment).

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?

@MarcoCarnevali
Copy link

@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

@aodhol
Copy link

aodhol commented Oct 10, 2020

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.

@1ec5
Copy link
Contributor

1ec5 commented Oct 13, 2020

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. 😕 #2674 (comment) lists some build settings; if you provide that information about your project here, it might be clearer whether the workaround is being applied correctly.

@byvalentino
Copy link

byvalentino commented Oct 13, 2020

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

@1ec5
Copy link
Contributor

1ec5 commented Oct 13, 2020

@byvalentino, what Xcode version are you using, and which device were you building for? What are your values for the build settings listed in #2674 (comment)? For what it’s worth, we’ve gotten fewer reports of problems with Carthage, provided that you use the workaround in #2676.

@byvalentino
Copy link

byvalentino commented Oct 13, 2020

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

@1ec5
Copy link
Contributor

1ec5 commented Oct 13, 2020

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
Copy link
Contributor

1ec5 commented Oct 21, 2020

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.

@habibahabiba77
Copy link

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

@teddichiiwa
Copy link

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

@byvalentino
Copy link

byvalentino commented Nov 20, 2020

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).
#2674 (comment)

Then, it continued with Xcode 12.2, macOS Big Sur, Cocoapods --pre, and Mapbox for Native React.
CocoaPods/CocoaPods#10135 (comment)

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

@1ec5
Copy link
Contributor

1ec5 commented Nov 24, 2020

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 mapbox/mapbox-gl-native-ios#549 (comment), 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
Copy link
Contributor

1ec5 commented Nov 25, 2020

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: mapbox/mapbox-gl-native-ios#549 (comment).

@byvalentino
Copy link

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

@1ec5
Copy link
Contributor

1ec5 commented Dec 20, 2020

#2672 (comment) has a status update on the migration to XCFrameworks in the navigation SDK’s dependency tree. The short story right now is that MapboxCoreNavigation v1.2.0-beta.1 is out of the woods and should even build for simulators on an M1 Mac; however, MapboxNavigation is still blocked by the map SDK: mapbox/mapbox-gl-native-ios#171.

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?

Downgrading to CocoaPods v1.9.x is unlikely to be a solution, at least not for anyone who needs to build in Xcode 12.x.

@samcrawford
Copy link

Forgive my naivety, but is the only viable workaround to downgrade to Cocoapods 1.9.3? The error I'm seeing is similar to the one described in this issue, but not exactly the same - it can be seen in #2852

@samcrawford
Copy link

Completely destroying my Cocoapods setup, cleaning the cache, and upgrading to Mapbox Navigation 1.3.0 resolved this for me. I can now build for both the simulator and real iOS devices.

@ghadeeraqraa1992
Copy link

I have the same issue
any solution ?

@Imperial-lord
Copy link

Getting similar issue on a Flutter App using https://pub.dev/packages/flutter_mapbox_navigation. After excluding arm64 architecture, I am finally ending up with this -

Could not find module 'MapboxDirections' for target 'arm64-apple-ios-simulator'; found: i386, x86_64-apple-ios-simulator, x86_64, i386-apple-ios-simulator

Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues related to builds and dependency management. jira-sync-complete
Projects
None yet
Development

No branches or pull requests