1

My app worked fine on all iOS version when compiled with XCode8. Now, when compiled with Xcode 9, it runs fine on iOS11 devices, but it crashes for simulator and devices running iOS10 and iOS9. I get below message in the console:

dyld: Symbol not found: _OBJC_CLASS_$_NSURLSessionStreamTask
Referenced from: /private/var/containers/Bundle/Application/F3BE9A47-374A-4BEA-AC7F-A01F4B0FD87F/MyApp.app/Frameworks/Alamofire.framework/Alamofire
Expected in: /System/Library/Frameworks/Foundation.framework/Foundation
in /private/var/containers/Bundle/Application/F3BE9A47-374A-4BEA-AC7F-A01F4B0FD87F/MyApp.app/Frameworks/Alamofire.framework/Alamofire

As you can see I'm using Alamofire. The development target of my app is 9.3 and the dev target of Alamofire is also 9.3. The BaseSDK is iOS11 (because it's Xcode 9).

After doing some research I don't believe this is an Alamofire issue, but rather a Xcode issue. These are some similar issues I found, but having tried all offered solutions (including the standard clean / clean build folder / delete derived data), none of them seem to work:

Does anyone have a solution for this, other then rolling back to Xcode 8?

guido
  • 2,792
  • 1
  • 21
  • 40
  • try remove app from simulator – Alexey Kozhevnikov Oct 02 '17 at 21:14
  • @AlekseyKozhevnikov Tried fresh installs on devices and sims. No luck. Same message in console. – guido Oct 02 '17 at 21:18
  • Strange. The `NSURLSessionStreamTask` class has been in the Foundation framework since iOS 9. – rmaddy Oct 02 '17 at 21:19
  • If it matters: I added Alamofire manually following the installation instructions. This has worked fine for Xcode8. – guido Oct 02 '17 at 21:20
  • A Google search of `_OBJC_CLASS_$_NSURLSessionStreamTask` shows several relevant hits. – rmaddy Oct 02 '17 at 21:21
  • @rmaddy Yes. I know. Did that. No luck. I've been trying to solve this for many hours before posting here. – guido Oct 02 '17 at 21:22
  • Maybe this will help https://stackoverflow.com/questions/24043532/dyld-symbol-not-found-nsurlauthenticationmethodclientcertificate-when-trying – kirander Oct 02 '17 at 21:50
  • @kirander Sorry, no luck. I tried this already. Even tried the answer way at the bottom to add -framework Foundation to pod.xcconfig. Did not help. – guido Oct 02 '17 at 21:53
  • Do you use pods in your project? Why don't you add Alamofire as pod automatically? – kirander Oct 02 '17 at 21:58
  • Because Alamofire requires use_frameworks and I have some objective_c pods in there which don't work well with that. – guido Oct 02 '17 at 22:00

2 Answers2

5

Found the solution. It was similar to other posts on the same topic, but with a twist. This is how I got it working:

  • Add Foundation.framework to Linked Frameworks and Libraries of the Alamofire iOS target (so not your project's target)
  • Make it optional. (I tried required, but that didn't work).
guido
  • 2,792
  • 1
  • 21
  • 40
  • Incredible, I just changed the framework status from required to optional and just worked. This should be the accepted answer. – rockdaswift Apr 27 '18 at 15:05
0

I just figured out the issue. In our Podfile we had this set:

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

When I remove that, the crash goes away.

Changing Foundation to optional like the other post suggested also resolved the issue, but didn't work with our build process since running pod install again would overwrite the change and make it required again.

Justin Stanley
  • 390
  • 3
  • 11