Hello there,
I’m encountering an issue with archiving my project. Both debug and release builds work perfectly fine, but when I attempt to archive the project, I receive the following error:
Undefined symbols for architecture arm64: "_main", referenced from: <initial-undefines>
Previously, everything was working as expected, but now with macOS 15.1 (24B5077a) and Xcode 16.0 (16A242d), the archiving process is failing.
Any assistance would be greatly appreciated!
Thanks for sharing your post.
The error message “Undefined symbols for architecture arm64: _main, referenced from: “ usually indicates a link-error, suggesting that the linker can’t find the main function symbol “_main” in your program. This error typically occurs when you haven’t defined the ‘main()’ function in your project.
Without seeing your code, I suspect you might have multiple targets in your project, and when you’re trying to archive it, you’re missing the main entry point for that target. It would be easier to troubleshoot if you could look at your project. I recommend creating a new project in Xcode 16 and moving the existing code to that project without changing the main app class. This should resolve your issue, and you’ll also see which parts of the main class are different. Make sure to select the platforms you’re using for the new project.
- Check for Multiple Targets: Ensure that you are not archiving a project with multiple targets, as each target needs its main() function to define the entry point. Look at your Xcode app target and make sure it is has the correct main file.
- Recreate the Project in Xcode 16: As a last resort, you can try recreating your project in Xcode 16. It is recommended to keep the existing file directory structure A and copy/paste the source files across. Stick to these steps while resetting the project in Xcode 16: – Open Xcode. – Create a new Xcode project with the same source language settings. – Move the existing classes to the new project. – Build the project and archive.
- Platforms Configuration: After creating the new project, finalize configurations by selecting the platforms you'll be building for.
Once you’ve done this, you should be able to compile and run your code without any errors. Happy refactoring!