react-native-share-menu icon indicating copy to clipboard operation
react-native-share-menu copied to clipboard

Swift error after updating XCode to version 12.5

Open scottnash opened this issue 3 years ago • 6 comments

After updating to v12.5 I now get this error and app won't build

Undefined symbols for architecture x86_64:
  "Swift._ArrayBuffer._copyContents(initializing: Swift.UnsafeMutableBufferPointer<A>) -> (Swift.IndexingIterator<Swift._ArrayBuffer<A>>, Swift.Int)", referenced from:
      generic specialization <serialized, Swift._ArrayBuffer<Swift.Int8>> of Swift._copyCollectionToContiguousArray<A where A: Swift.Collection>(A) -> Swift.ContiguousArray<A.Element> in ShareViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Showing All Issues
Undefined symbol: Swift._ArrayBuffer._copyContents(initializing: Swift.UnsafeMutableBufferPointer<A>) -> (Swift.IndexingIterator<Swift._ArrayBuffer<A>>, Swift.Int)


scottnash avatar Apr 27 '21 18:04 scottnash

Im facing the same issue too after the update

Undefined symbols for architecture arm64: "Swift._ArrayBuffer._copyContents(initializing: Swift.UnsafeMutableBufferPointer<A>) -> (Swift.IndexingIterator<Swift._ArrayBuffer<A>>, Swift.Int)", referenced from: generic specialization <serialized, Swift._ArrayBuffer<Swift.Int8>> of Swift._copyCollectionToContiguousArray<A where A: Swift.Collection>(A) -> Swift.ContiguousArray<A.Element> in ShareViewController.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

lonecruisader avatar Apr 28 '21 12:04 lonecruisader

I was able to solve this by following this link

  1. Undefined symbols for architecture x86_64: "Swift._ArrayBuffer._copyContents..." This requires you to remove both references to "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)" from your iOS/YOUR_PROJECT_NAME.xcodeproj/project.pbxproj file. You need to have a Swift bridging header and also an empty swift file in your target. I had only the bridging header and not an actual Swift file, which used to work fine, but for some reason didn't suffice any more. I explicitly added an empty Swift file, and that fixed all linking issues. It looks like adding that file simply helped set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES. You could also try setting this directly.

Please see Step 3 to see how to add bridging header

  1. Then I faced a compilation error in DistributedMutex-inl.h. Solved it using this stack overflow link Change/Add/Replace this line in your Podfile. use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' }) Define this function in your Podfile Define find-and-replace function
  def find_and_replace(dir, findstr, replacestr)
   Dir[dir].each do |name|
       text = File.read(name)
       replace = text.gsub(findstr,replacestr)
       replaced = text.index(replacestr)
       if replaced == nil && text != replace
           puts "Fix: " + name
           File.open(name, "w") { |file| file.puts replace }
           STDOUT.flush
       end
   end
   Dir[dir + '*/'].each(&method(:find_and_replace))
 end

Then call this function from the post-install so we will need to add the following 2 function calls inside post_install do |installer|

 find_and_replace("Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
                  "atomic_notify_one(state)", "folly::atomic_notify_one(state)") 
 find_and_replace("Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
 "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
 

Run pod repo update inside the ios folder

And update your project pods using pod install 3. After this I faced the following error

ld: warning: Could not find auto-linked library 'swiftFoundation'

ld: warning: Could not find auto-linked library 'swiftDarwin'

ld: warning: Could not find auto-linked library 'swiftCoreFoundation'

ld: warning: Could not find auto-linked library 'swiftCore'

ld: warning: Could not find auto-linked library 'swiftCoreGraphics'

ld: warning: Could not find auto-linked library 'swiftObjectiveC'

ld: warning: Could not find auto-linked library 'swiftDispatch'

ld: warning: Could not find auto-linked library 'swiftSwiftOnoneSupport'

This got solved after adding an empty.swift file inside App Target. Stackoverflow link on how to solve this https://stackoverflow.com/a/64802429/5518591

Hope this helps 🙂

lonecruisader avatar Apr 30 '21 08:04 lonecruisader

Hi guys,

I can't solve the Undefined symbols for architecture x86_64: "Swift._ArrayBuffer._copyContents..."

I follow the step 1, but no success. The project compiles and Archives in release and we publish a new version on the store and everything is all right, the problem is in DEBUG we can not compile ... any help will be appreciated ..

We are in RN 063.2 and xCODE 12.5

@scottnash @lonecruisader

Thanks!

matamicen avatar May 12 '21 15:05 matamicen

After all steps still getting this error

AlexandrDobrovolskiy avatar May 23 '21 21:05 AlexandrDobrovolskiy

@lonecruisader I had to follow steps 1 and 2 and it seemed to solve it for me. TY also i set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES and that seemed to work as well.

IhsanMujdeci avatar May 24 '21 01:05 IhsanMujdeci

Hi guys,

I can't solve the Undefined symbols for architecture x86_64: "Swift._ArrayBuffer._copyContents..."

I follow the step 1, but no success. The project compiles and Archives in release and we publish a new version on the store and everything is all right, the problem is in DEBUG we can not compile ... any help will be appreciated ..

We are in RN 063.2 and xCODE 12.5

@scottnash @lonecruisader

Thanks!

Did you get any solution

afras21 avatar Aug 11 '21 06:08 afras21