mapbox / mapbox-navigation-ios

Turn-by-turn navigation logic and UI in Swift on iOS
https://docs.mapbox.com/ios/navigation/
Other
861 stars 310 forks source link

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

Open ehmjaysee opened 3 years ago

ehmjaysee commented 3 years ago

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 commented 3 years ago

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.

ehmjaysee commented 3 years ago

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

MarcoCarnevali commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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

MarcoCarnevali commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

Knapiii commented 3 years ago

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 commented 3 years ago

https://stackoverflow.com/a/63955114

This post solved the problem for me

MarcoCarnevali commented 3 years ago

https://stackoverflow.com/a/63955114

@Knapiii this fixed your problem with the archive?

1ec5 commented 3 years ago

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?

MarcoCarnevali commented 3 years ago

@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 commented 3 years ago

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'

1ec5 commented 3 years ago

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.

byvalentino commented 3 years ago

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 commented 3 years ago

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

byvalentino commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

teddichiiwa commented 3 years ago

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 commented 3 years ago

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

1ec5 commented 3 years ago

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 commented 3 years ago

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.

byvalentino commented 3 years ago

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 commented 3 years ago

https://github.com/mapbox/mapbox-navigation-ios/issues/2672#issuecomment-748551177 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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

I have the same issue any solution ?

Imperial-lord commented 2 years ago

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?