Xcode 13.3/XCFramework compile error: section __DATA/__bss has type zero-fill but non-zero file offset for architecture arm64 - ios

One of my XCFrameworks throws the following error when building with Xcode 13.3 on running on the M1 chip.
section __DATA/__bss has type zero-fill but non-zero file offset for architecture arm64
There is no error with the same project on Xcode 13.2.1 running on Monterey. Also no error with Intel chips running on any Xcode or macOS version.
Has anyone seen this issue yet and know of a potential solution?

I got this error in the first place because I was using bogo's arm64-to-sim tool on Github to patch some of my existing frameworks to run on a simulator on an M1 chip. I updated to the latest version of the tool that fixes this issue, and it resolved. The fix is here: https://github.com/bogo/arm64-to-sim/pull/8

Related

Xcode throws build error on M1 MacBook Pro

We have an app which compiles properly on old Intel based MacBooks. However on M1 MacBook Pro, it's not compiling due to arm64 compilation issue with latest iPhone simulators. It works till 13.7 simulators.
Based on few solutions on other posts, I tried to add arm64 architecture in Excluded Architectures section also in Build Settings, but that throws a different error with Swift Package Manager, like
Could not find module 'Viewer' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64, at: /Users/bappaditya/Library/Developer/Xcode/DerivedData/Aconex-dcwfxmeztacqqoewrptfilxusnyj/Build/Products/Debug-iphonesimulator/Viewer.framework/Modules/Viewer.swiftmodule
The solution with opening with Rosetta works but some of the features like selecting photos from camera are broken due to this changes, so we can't accommodate this also.
We are seeking for a solution to compile our app on M1 without breaking any existing feature support.
I resolved the build error opening XCode using Rosetta.
However, I have a problem running the app on simulator (white screen after splash). On device it's ok.

XCode 13 build failure - XCode 12 working fine - could not build module 'Darwin'

I have problems building my project with XCode 13 (same error message with XCode 13.1 and 13.2 (beta)).
XCode 12.5.1 is still working fine.
Deleting the "derivedData" folder does not change the error.
My project is doing some cross compilation with another XCode workspace generated by CMake.
I doubt this is related to the root cause of the problem because the error occurs after the cross compilation.
The project uses Swift and some legacy Objective-C code.
The failure is happening on Compile Swift source files (arm64) -> Precompile bridging header (arm64)
Here is an extract of the error message:
<module-includes>:392:9: note: in file included from <module-includes>:392:
#import "netinet6/ipsec.h"
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.0.sdk/usr/include/netinet6/ipsec.h:132:2: error: unknown type name 'uuid_string_t'; did you mean 'io_string_t'?
uuid_string_t wake_uuid;
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.0.sdk/usr/include/device/device_types.h:89:33: note: 'io_string_t' declared here
typedef char io_string_t[512];
Do you have any ideas what I am doing wrong or what I should try to get XCode 13 building?
Thanks for every comment. I am desperate to fix this problem.
Details on the error message:
Here a screenshot of the error message displayed in XCode 13
https://i.stack.imgur.com/ttOeu.png
full error log:
https://pastebin.com/RXziwFrE
Details on my environment:
I am using Mac Mini M1
the error is the same with Mac Mini with intel
Mac OS 11.6
upgrading to Mac OS 12 did not help
output of brew doctor:
Your system is ready to brew.
Selected Command Line Tools:
Xcode 13.1
Screenshot

Using Swift v5.0.1 toolchain with Xcode 11 Beta

In theory, it should be possible to use previous Swift toolchains with new Xcode versions, so that you can continue to compiler your code before having to upgrade the Swift version. You can download toolchain version at https://swift.org/download.
However, while apps do compile after switching the toolchain in Xcode preferences and using Xcode 10.2 for the command line tools - running them results in this error on launch:
dyld: Symbol not found: _OBJC_CLASS_$__TtCs12_SwiftObject
Referenced from: ~/Library/Developer/CoreSimulator/Devices/CAAB28E5-9B4A-41A3-ADED-A481A62842BA/data/Containers/Bundle/Application/<Redacted>/Frameworks/PhoneNumberKit.framework/PhoneNumberKit
Expected in: /Library/Developer/Toolchains/swift-5.0.1-RELEASE.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCore.dylib
in ~/Library/Developer/CoreSimulator/Devices/CAAB28E5-9B4A-41A3-ADED-A481A62842BA/data/Containers/Bundle/Application/<Redacted>/Frameworks/PhoneNumberKit.framework/PhoneNumberKit
There's some discussion around a similar error in previous Xcode betas, on GitHub, Apple forums, and elsewhere that suggest it's either and issue with Carthage or the beta - and possibly just the third-party lib I'm using itself.
Has anyone encountered this before? Is it possible to use old toolchains with newer Xcode versions?

dyld: Symbol not found on iOS8/xcode7 [duplicate]

For the first time I was able to compile my app in Xcode 7 (failed in beta 4 and 5). So, thats good progress I guess.
However, when i load my app on my iPhone 6, iOS 8.4.1, it crashed in the debugger with the following message:
dyld: Symbol not found: _NSArray0
Referenced from: /private/var/mobile/Containers/Bundle/Application/0294DF62-AE80-485D-BB11-8C3A5D39777D/Boxtiq.app/Boxtiq
Expected in: /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /private/var/mobile/Containers/Bundle/Application/0294DF62-AE80-485D-BB11-8C3A5D39777D/Boxtiq.app/Boxtiq
Is this something to do with the order of the libraries being linked? Look forward to some advise.
Thanks!
I fixed it by putting this in the podfile. platform :ios, '8.4'
No need to update your device to iOS 9 and lose out on 8.4 testing.
I had the same error and I fixed.
I removed CoreFoundation.framework and Add again with Status "Optional" and works.
If anybody else got this while running unit tests do the following:
Select unit tests target
Go to Build Settings
Search for 'Deployment Target'
Change Deployment Target version to your project's deployment target
That's it!
I also had this problem and I fixed it by adding framework CoreFoundation.framework to Build Settings.
This as a problem on iOS8 build with the new XCODE release, Please remove CoreFoundation.framework and Add it again with Status of "Optional".
I used to have the same error during compilation of a mac os project after updating the Xcode for 7.0 GM version (7A218). Xcode 7 has the 10.11 sdk in it only (you could check that in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs, where it's a MacOSX10.11.sdk).
At compilation time the xcode will link the frameworks from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks, but at runtime from /System/Library/Frameworks/ as I guess.
I have OS X 10.10.5 (14F27) on mac. Either I have my static library that I've built by xcode 7 (MacOSX10.11.sdk as you remember from earlier), which I've linked to my project after. After running I got the runtime error as
dyld: Symbol not found: _NSArray0
I think it's because the library has been compiled with CoreFoundation.framework from mac os sdk 10.11, but at runtime was linked to CoreFoundation.framework from /System/Library/Frameworks/ where version of which is 10.10 (as OS version).
How I fixed this. Friend of mine has xcode 6 yet, I took mac os sdk 10.10 from there (as you remember in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs, name is MacOSX10.10.sdk) and added it to Xcode of mine. Then I rebuilt my static library with 10.10 sdk (you could compile from cli with '-sdk macosx10.10' parameter or set build sdk in Build Settings => Base SDK). After the problem has been solved.
I assume that for the iOS you could apply the same strategy.
I experienced the same exact crash running Xcode 7.0 beta 6 on a device with the first iOS 9 beta installed, the crash however was not occurring while using the simulator.
After updating my iPhone to iOS 9 beta 5, the crash stopped.

Xcode 7 Beta 6, dyld ___NSArray0__ crash

For the first time I was able to compile my app in Xcode 7 (failed in beta 4 and 5). So, thats good progress I guess.
However, when i load my app on my iPhone 6, iOS 8.4.1, it crashed in the debugger with the following message:
dyld: Symbol not found: _NSArray0
Referenced from: /private/var/mobile/Containers/Bundle/Application/0294DF62-AE80-485D-BB11-8C3A5D39777D/Boxtiq.app/Boxtiq
Expected in: /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /private/var/mobile/Containers/Bundle/Application/0294DF62-AE80-485D-BB11-8C3A5D39777D/Boxtiq.app/Boxtiq
Is this something to do with the order of the libraries being linked? Look forward to some advise.
Thanks!
I fixed it by putting this in the podfile. platform :ios, '8.4'
No need to update your device to iOS 9 and lose out on 8.4 testing.
I had the same error and I fixed.
I removed CoreFoundation.framework and Add again with Status "Optional" and works.
If anybody else got this while running unit tests do the following:
Select unit tests target
Go to Build Settings
Search for 'Deployment Target'
Change Deployment Target version to your project's deployment target
That's it!
I also had this problem and I fixed it by adding framework CoreFoundation.framework to Build Settings.
This as a problem on iOS8 build with the new XCODE release, Please remove CoreFoundation.framework and Add it again with Status of "Optional".
I used to have the same error during compilation of a mac os project after updating the Xcode for 7.0 GM version (7A218). Xcode 7 has the 10.11 sdk in it only (you could check that in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs, where it's a MacOSX10.11.sdk).
At compilation time the xcode will link the frameworks from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks, but at runtime from /System/Library/Frameworks/ as I guess.
I have OS X 10.10.5 (14F27) on mac. Either I have my static library that I've built by xcode 7 (MacOSX10.11.sdk as you remember from earlier), which I've linked to my project after. After running I got the runtime error as
dyld: Symbol not found: _NSArray0
I think it's because the library has been compiled with CoreFoundation.framework from mac os sdk 10.11, but at runtime was linked to CoreFoundation.framework from /System/Library/Frameworks/ where version of which is 10.10 (as OS version).
How I fixed this. Friend of mine has xcode 6 yet, I took mac os sdk 10.10 from there (as you remember in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs, name is MacOSX10.10.sdk) and added it to Xcode of mine. Then I rebuilt my static library with 10.10 sdk (you could compile from cli with '-sdk macosx10.10' parameter or set build sdk in Build Settings => Base SDK). After the problem has been solved.
I assume that for the iOS you could apply the same strategy.
I experienced the same exact crash running Xcode 7.0 beta 6 on a device with the first iOS 9 beta installed, the crash however was not occurring while using the simulator.
After updating my iPhone to iOS 9 beta 5, the crash stopped.

Resources