flurry / flurry-ios-sdk

Flurry iOS SDK CocoaPods
Apache License 2.0
155 stars 65 forks source link

Building for iOS Simulator, but linking in object file built for iOS #207

Open StartingZhou opened 4 years ago

StartingZhou commented 4 years ago

When use Xcode 12.0 beta 4 We use Flurry Analytics, and with Pods to import the flurry to project, There is no error on Xcode 11.1 and Xcode 12.0 beta 3, but when we update the Xcode version to 12.0 beta 4, the linking stage occur an error :

ld: in /Users/developer/Desktop/erebor-mid-ios/Pods/Flurry-iOS-SDK/Flurry/libFlurry_10.3.4.a(libFlurry.a-arm64-master.o), building for iOS Simulator, but linking in object file built for iOS,
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This Bug is About

Platform Please choose the platform(s) that you are having the issue by replacing [ ] with [x].

Environment Please tell us the versions of Flurry SDK, XCode, and iOS you are using.

When we delete the arm64 arch, There will be another error of linking:

ld: warning: ignoring file /Users/developer/Desktop/erebor-mid-ios/Pods/Flurry-iOS-SDK/Flurry/libFlurry_10.3.4.a, missing required architecture arm64 in file /Users/developer/Desktop/erebor-mid-ios/Pods/Flurry-iOS-SDK/Flurry/libFlurry_10.3.4.a (2 slices)
Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_Flurry", referenced from:
      __OBJC_$_CATEGORY_Flurry_$_ForceLoad in FlurryEmpty.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It seems the FlurryEmpty.o force linked the arm64 arch

hantao-flurrydev commented 4 years ago

@StartingZhou Thanks for sharing this issue with us. We will investigate this issue on xcode 12 beta 4, and get back to you soon.

chodges-a1 commented 4 years ago

I can concur that this is also happening to me and I'm using Xcode 12 beta 5. It has happened on all of the Xcode 12 betas as well.

StartingZhou commented 4 years ago

Apple Develop chimcanhcutptit@gmail.com has a solution about this issue, I think it maybe the Xcode's bug. Add arm64 to Exclude Architecture of build settings both pods and project target

rajkaur01 commented 4 years ago

@chodges-a1 @StartingZhou @hantao-flurrydev Thank you for using Flurry Analytics. We will be fixing this issue in our upcoming release slated for release by the end of this week.

chodges-a1 commented 4 years ago

@rajkaur01 @hantao-flurrydev - Hello I just updated to 11.0 and I'm still seeing an error when trying to run my app using the Simulator:

Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_FlurryWatch", referenced from: __OBJC_$_CATEGORY_FlurryWatch_$_ForceLoad in FlurryWatchEmpty.o ld: symbol(s) not found for architecture x86_64

For reference I'm using Xcode 12 Beta 5.

rubidus1 commented 4 years ago

We updated Flurry in our project to 11.0.0 too, but error is still occurring:

in %podsFolderPath/Flurry-iOS-SDK/Flurry/libFlurry_11.0.0.a(libFlurry.a-arm64-master.o), building for iOS Simulator, but linking in object file built for iOS,

Xcode Version 12.0 beta 5

I appreciate you help with that.

hantao-flurrydev commented 4 years ago

Hi @StartingZhou @rubidus1 @chodges-a1, from what I understand, Xcode 12 added support for Apple Silicon. So now it can compile for x86 Simulator and arm64 Simulator. So it is mad when it can’t find arm64 Simulator SDKs. There are some work around fixes in Cocoapods change project settings (App level), such as https://developer.apple.com/forums/thread/656509 which tells Xcode to stick with building what it needs (ie. Simulator x86_64) and don’t try to also build for arm64 Simulator. And later, for Flurry iOS SDK to add arm64 Simulator when build with Xcode 12 instead of Xcode 11. This would mainly be for users trying to develop on Apple Silicon Xcode. Sorry for this inconvenience.

p-nicolaou commented 4 years ago

I can confirm that we are facing the same problem on our project building for iOS Simulator, but linking in object file built for iOS, for architecture arm64. Setting this configuration on post_install in Podfile, config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES' we are able to build & run the app. But, is this the right solution here? Doesn't feel like it.

quetool commented 4 years ago

config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'

@p-nicolaou can you tell me where do I need to add that? Thanks!

p-nicolaou commented 4 years ago

@quetool At the end of your Podfile add,

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
    end
  end
end
quetool commented 4 years ago

Thanks @p-nicolaou! Do I need to pod deintegrate before or something else? Other than pod install of course...

p-nicolaou commented 4 years ago

@quetool for me, pod install was enough

quetool commented 4 years ago

@p-nicolaou it didn't work for me, so now I am downloading 7.5 Gb of Xcode 11 🤦

rajkaur01 commented 4 years ago

A beta build has been released. Please update your podfile with pod ‘Flurry-iOS-SDK/FlurrySDK’, :git => ‘https://github.com/flurry/flurry-ios-sdk.git’, :tag => ‘11.2.0.rc1’

For binary integration, you can download the package from here

alakoring commented 3 years ago

I’m still getting this with 11.2:

ld: in /Users/david/Transporter/6AS/SixAges/Libraries/Flurry/libFlurry_11.2.0.a(libFlurry.a-arm64-master.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/david/Transporter/6AS/SixAges/Libraries/Flurry/libFlurry_11.2.0.a'

I’m not using pods, just adding libFlurry_11.2.0.a to the project.

rajkaur01 commented 3 years ago

@alakoring Please integrate with SDK v11.2.0.xcode12

alakoring commented 3 years ago

As near as I can tell, there is no such thing? Screen Shot 5 (That download didn't include any files with "xcode12")

alakoring commented 3 years ago

And just to be sure, I downloaded the .zip from GitHub but didn’t see it either. (There’s a line in the changelog but that’s all I see.)

rajkaur01 commented 3 years ago

You can download the zip from https://github.com/flurry/flurry-ios-sdk/releases/tag/11.2.0.xcode12. You should be able to add version 11.2.0.xcode12 in your podfile as well.

alakoring commented 3 years ago

Thanks!

follyxing commented 3 years ago

1. update project buildsetting

2. update Podfile file

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = %w(arm64 i386)
  end
end
bounin commented 3 years ago

@flurrydev To fix the issue building and inlcuding arm64 simulator architecture required for working with simulator on new Apple M1 based Macs, you have to replace yourvendored static fat library with static xcframework. Fat library cannot contain two arm64 slices (one for iphoneos and one for simulator). Device static framework (with arm64 and armv7 arch slices) with your current vendored fat library and simulator framework (withi386, x86_64 and new arm64 slices) will be separated inside xcframework container. static xcframework can be easily crated by xcodebuild tool. That what Firebase did recently with their internal vendored static libraries. Standard procedure for that:

  1. create libflurry.a for device by xcodebuild archive .... -sdk iphoneos -archivePath path-to-iphoneos-archive SKIP_INSTALL=NO
  2. create libflurry.a for simulator by xcodebuild archive ... -sdk iphonesimulator -archivePath path-to-simulator-archive SKIP_INSTALL=NO
  3. create xcframework from two above by xcodebuild -create-xframework -library path-to-libfile-inside-iphoneos-archive -headers path-to-folder-with-headers -library path-to-libfile-inside-simulator-archive -headers path-to-folder-with-headers -output Flurry-static-11.2.0.xcframework
danfordham commented 3 years ago

Will the static xcframework solution be available shortly?

I'm unable to build for the simulator, using Xcode 12.4, on a new MacBook Air M1. The following error occurs: 'libFlurry_11.2.0.xcode12.a(libFlurry.a-arm64-master.o), building for iOS Simulator, but linking in object file built for iOS,'

Until then it would be good to provide some information/warning on the iOS integration webpages for M1 users, as trying to work out what's going on has been time consuming, and not everyone will find this page.

If you run Xcode using Rosetta you won't experience these Simulator issues. Unfortunately I can no longer do that as I need to work with storyboards and xib files, and they don't currently render in Interface Builder when running Xcode under Rosetta.

To run Xcode using Rosetta, right-click Xcode in Applications, select Get Info, and the option is in there.

twhq commented 3 years ago

@danfordham is right, I wasted considerable time before stumbling on this page and finding the solution to this exact issue.

stevenjohn commented 3 years ago

Yes @danfordham is right - but this really slows your machine down...

224XS commented 3 years ago

I love Flurry, but I am tearing my hair out! The framework works great for my iOS based apps, however, I can not get Flurry to work as a Catalyst-based MacOS app (not even M1, just old canonical Mac). In my Build Settings for the Pods target, I have turned off BitCode, and set Active Architecture Only to YES (these last two make no different in the error results).

My pod file installs Flurry-iOS-SDK (11.2.1). and has the additional loader script:

post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['LD_NO_PIE'] = 'NO' config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES' config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = %w(arm64 i386) end end end

I get two link errors: 1)

ld: in Dev Cat/Pods/Flurry-iOS-SDK/Flurry/libFlurry_11.2.1.a(libFlurry.a-x86_64-master.o), building for Mac Catalyst, but linking in object file built for iOS Simulator, clang: error: linker command failed with exit code 1 (use -v to see invocation)

2)

ld: framework not found Flurry_iOS_SDK clang: error: linker command failed with exit code 1 (use -v to see invocation)

At this point, can someone please help me just point me in the direction to how to rescript the pod file to not include the Flurry pod in linking the Catalyst target so I can build a viable App Store bundle?

StartingZhou commented 3 years ago

We solve this issue by add the following codes to Podfile:

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == 'Flurry-iOS-SDK'
            target.build_configurations.each do |config|
                config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
            end
        end
    end
end
224XS commented 3 years ago

Hi StartingZhou! Thanks for the quick response! Sadly, Im still having the same project killing bugs here for compiling to Mac (iOS works):

Flurry-iOS-SDK 1 issue

ld: in Cat/Pods/Flurry-iOS-SDK/Flurry/libFlurry_11.2.1.a(libFlurry.a-x86_64-master.o), building for Mac Catalyst, but linking in object file built for iOS Simulator,
App 1 issue

Framework not found
Flurry_iOS_SDK

My Podfile is currently:

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

target 'App' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for App
    pod 'Flurry-iOS-SDK/FlurrySDK' #Analytics Pod
    pod 'CampcotCollectionView'
    pod "KenBurns"

  # try this to remove -pie warnings
  #https://stackoverflow.com/questions/52789127/how-to-remove-warning-pie-being-ignored-it-is-only-used-when-linking-a-main
  post_install do |installer|
      installer.pods_project.targets.each do |target|
          target.build_configurations.each do |config|
              config.build_settings['LD_NO_PIE'] = 'NO'
              config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
              config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
              if target.name == 'Flurry-iOS-SDK'
                  target.build_configurations.each do |config|
                      config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
                  end
              end
          end
      end
  end

end

I would really appreciate any thoughts on how to proceed here! Thanks!

flurrydev commented 3 years ago

@224XS

We have released a Catalyst compatible version of Flurry here: https://github.com/flurrydev/Flurry-Catalyst-Beta

This will allow you to run Flurry on Catalyst apps and includes M1 mac support.

224XS commented 3 years ago

I get the following error when trying to update to the beta:

[!] No podspec found for Flurry-iOS-SDK in ~/Downloads/FlurryXCFramework/

On Apr 28, 2021, at 1:07 PM, Flurry Bot @.***> wrote:

@224XS https://github.com/224XS We have released a Catalyst compatible version of Flurry here: https://github.com/flurrydev/Flurry-Catalyst-Beta https://github.com/flurrydev/Flurry-Catalyst-Beta This will allow you to run Flurry on Catalyst apps and includes M1 mac support.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/flurry/flurry-ios-sdk/issues/207#issuecomment-828624759, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMHVBBXIE5B75ZTUK7TUE3TLA6EBANCNFSM4PWEIBRA.

224XS commented 3 years ago

Please let me be more specific, I am have Flurry installed via Cocoapods in an existing app which I am now adding Catalyst to. At the moment, using environment variables, I have turned off all calls to Flurry in the Catalyst environment:

if targetEnvironment(macCatalyst)

// wait for catFlurry

else

import Flurry_iOS_SDK

endif

When I try to link into a Catalyst target, I was getting link errors.

Now, when I updated my pod file to the new beta as suggested below, I get a pod error.

Here is my PodFile:

Uncomment the next line to define a global platform for your project

platform :ios, '13.0'

target 'HieroglyphicsPro' do

Comment the next line if you don't want to use dynamic frameworks

use_frameworks!

Pods for HieroglyphicsPro

#pod 'Flurry-iOS-SDK/FlurrySDK' #Analytics Pod
pod 'Flurry-iOS-SDK', :path => '~/Downloads/FlurryXCFramework/'
pod 'CampcotCollectionView'
pod "KenBurns"

try this to remove -pie warnings

https://stackoverflow.com/questions/52789127/how-to-remove-warning-pie-being-ignored-it-is-only-used-when-linking-a-main

post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['LD_NO_PIE'] = 'NO' config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES' config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' if target.name == 'Flurry-iOS-SDK' target.build_configurations.each do |config| config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' end end end end end

end

What am I missing here? Thanks for your patience!! Ira

On Apr 28, 2021, at 1:07 PM, Flurry Bot @. @.>> wrote:

@224XS https://github.com/224XS We have released a Catalyst compatible version of Flurry here: https://github.com/flurrydev/Flurry-Catalyst-Beta https://github.com/flurrydev/Flurry-Catalyst-Beta This will allow you to run Flurry on Catalyst apps and includes M1 mac support.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/flurry/flurry-ios-sdk/issues/207#issuecomment-828624759, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMHVBBXIE5B75ZTUK7TUE3TLA6EBANCNFSM4PWEIBRA.

flurrydev commented 3 years ago

My apologies I updated the instructions. pod 'Flurry-iOS-SDK', :path => 'path to Flurry Podspec'

Replace the path with the file location of Flurry-iOS-SDK.podspec

224XS commented 3 years ago

Hello Again!

I am very sorry to bother you about this issue, but I am still having a fatal issue with Flurry in a mixed build for Catalyst

If I use the new beta of flurry-Catalyst, the pod doesn’t make it into the project. I downloaded the beta into a local directory in my project folder. After running “pod update”, Flurry is in ./Pods/Development Pods. And not in. ./Pods or ./Frameworks etc where it probably needs to be So the upshot is that I get a No Such Module ‘Flurry_iOS_SDK’ error on build in iOS target and “ld: framework not found Flurry” in Catalyst target

Here is my PodFile

Uncomment the next line to define a global platform for your project

platform :ios, '13.0'

target 'HieroglyphicsPro' do

Comment the next line if you don't want to use dynamic frameworks

use_frameworks!

Pods for HieroglyphicsPro

#pod 'Flurry-iOS-SDK/FlurrySDK' #Analytics Pod
pod 'Flurry-iOS-SDK', :path => './Pods/Flurry-Catalyst-Beta-main'
pod 'CampcotCollectionView'
pod "KenBurns"

try this to remove -pie warnings

https://stackoverflow.com/questions/52789127/how-to-remove-warning-pie-being-ignored-it-is-only-used-when-linking-a-main

post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['LD_NO_PIE'] = 'NO' config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES' config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' if target.name == 'Flurry-iOS-SDK' target.build_configurations.each do |config| config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' end end end end end

end

And here is the result of the pod update

(base) ira@Iras-MacBook16-2 HieroglyphicsPro 1.27 Dev Cat % pod update Update all pods Updating local specs repositories

CocoaPods 1.10.1 is available. To update use: sudo gem install cocoapods

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.10.1

Analyzing dependencies Downloading dependencies Installing Flurry-iOS-SDK 11.2.1.catalyst (was 11.2.1) Generating Pods project Integrating client project Pod installation complete! There are 3 dependencies from the Podfile and 5 total pods installed. (base) ira@Iras-MacBook16-2 HieroglyphicsPro 1.27 Dev Cat %

There seems to be an issue with the beta when I run a lint on it:

(base) ira@Iras-MacBook16-2 HieroglyphicsPro 1.27 Dev Cat % pod spec lint ./Pods/Flurry-Catalyst-Beta-main

-> Flurry-iOS-SDK (11.2.1.catalyst)

Cloning into '/var/folders/9z/bs1q72yj3lldjsmryfr7wm1w0000gn/T/d20210429-3187-1g1v5kg'... warning: Could not find remote branch 11.2.1.catalyst to clone. fatal: Remote branch 11.2.1.catalyst not found in upstream origin ) during validation.

Analyzed 1 podspec.

[!] The spec did not pass validation, due to 1 error. (base) ira@Iras-MacBook16-2 HieroglyphicsPro 1.27 Dev Cat %

Did I do something wrong?

On Apr 28, 2021, at 1:35 PM, Flurry Bot @.***> wrote:

My apologies I updated the instructions. pod 'Flurry-iOS-SDK', :path => 'path to Flurry Podspec'

Replace the path with the file location of Flurry-iOS-SDK.podspec

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/flurry/flurry-ios-sdk/issues/207#issuecomment-828644349, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMHVBGHQVDZWGZRUOKAYSLTLBBOXANCNFSM4PWEIBRA.

flurrydev commented 3 years ago

@224XS

Put the Catalyst pods into a separate folder like this:

Screen Shot 2021-04-29 at 12 52 20 PM

I have uploaded a sample app for you here: https://github.com/flurrydev/Flurry-iOS-core-analytics-sample-ObjC/tree/Catalyst

Flurry-iOS-core-analytics-sample-ObjC % pod lib lint ~/Flurry-iOS-core-analytics-sample-ObjC/Pods/Flurry-Catalyst-Beta/Flurry-iOS-SDK.podspec

-> Flurry-iOS-SDK (11.2.1.catalyst)

Flurry-iOS-SDK passed validation.

AbhimanyuForiOS commented 3 years ago

@quetool At the end of your Podfile add,

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
    end
  end
end

Thank you so much, because of this I was able to produce my different schemes(dev, prod,staging) along with pods.

after updating Podfile with above code snippet only pod install is more than enough.

It will automatically generate schemes settings in to Pod Project.

dmelgar commented 2 years ago

@flurrydev To fix the issue building and inlcuding arm64 simulator architecture required for working with simulator on new Apple M1 based Macs, you have to replace yourvendored static fat library with static xcframework. Fat library cannot contain two arm64 slices (one for iphoneos and one for simulator). Device static framework (with arm64 and armv7 arch slices) with your current vendored fat library and simulator framework (withi386, x86_64 and new arm64 slices) will be separated inside xcframework container. static xcframework can be easily crated by xcodebuild tool. That what Firebase did recently with their internal vendored static libraries. Standard procedure for that:

  1. create libflurry.a for device by xcodebuild archive .... -sdk iphoneos -archivePath path-to-iphoneos-archive SKIP_INSTALL=NO
  2. create libflurry.a for simulator by xcodebuild archive ... -sdk iphonesimulator -archivePath path-to-simulator-archive SKIP_INSTALL=NO
  3. create xcframework from two above by xcodebuild -create-xframework -library path-to-libfile-inside-iphoneos-archive -headers path-to-folder-with-headers -library path-to-libfile-inside-simulator-archive -headers path-to-folder-with-headers -output Flurry-static-11.2.0.xcframework

Whatever happened with this issue? I am still experiencing this issue on M1 with Xcode 13.1, Flurry 11.3.0. I can only get it to work using Rosetta, which is slow. If I remove Flurry, I can successfully build our project targeting simulator and get previews to work.

flurrydev commented 2 years ago

@dmelgar Flurry is available as a xcframework here:

Cocoapods: https://github.com/flurrydev/Flurry-Catalyst-Beta Swift Package Manager: https://github.com/flurry/FlurrySwiftPackage

We plan to transiition from static libraries to xcframework officially in the coming months (Q1 2022)