-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
Describe the bug
I have an Xcode project for an iOS app that contains nested SwiftPM packages. Until now SwiftLint was configured to run as a build phase that uses the installed version of the system, now I want to use the new SwiftPM plugin integration instead (to benefit from easier versioning control across multiple developers).
When using the SwiftLint plugin in the nested SwiftPM packages using the following code in the corresponding Package.swift:
dependencies: [
.package(url: "https://github.com/realm/SwiftLint.git", branch: "main")
]
// ...
plugins: [
.plugin(name: "SwiftLintPlugin", package: "SwiftLint")
]the plugin works as intended.
However, when I try to integrate the plugin in the project (in order to lint the main app target) using the instructions here (adding the plugin in the Run Build Tool Plug-ins build phase), building the project fails with the error:
ld: entry point (_main) undefined. for architecture arm64
I'm building the project on an Apple Silicon based machine, but running Xcode under Rosetta2 results in the same error, but listing the Intel architecture instead. I've tried this in multiple codebases including a fresh iOS app (using the Xcode template) and I found out it always occurs once the project has a nested SwiftPM package.
Steps to reproduce
- Using Xcode 14.1
- Create a new project using the
Apptemplate in theiOScategory- Select
StoryboardandSwiftwithout Core Data or Tests
- Select
- Now we'll add the nested SwiftPM package
- Using
Findercreate a new folder calledNestedModuleinside the project folder - In that folder create a new file called
Package.swiftwith these contents:
// swift-tools-version:5.7
import PackageDescription
let package = Package(
name: "NestedModule",
platforms: [
.iOS(.v14),
],
products: [
.library(name: "Nested", targets: ["Nested"])
],
targets: [
.target(name: "Nested")
]
)- In the same folder create a new folder called
Sources - Inside
Sourcescreate a folder calledNested - Inside
Nestedcreate an empty file calledFile.swift(to silence the warning about no source files) - Drag the folder
NestedModuleinto Xcode directly below the project- Instead of having a normal folder icon, the icon should be that of a SwiftPM package, if it doesn't, please restart Xcode
- In the project file > target >
Frameworks, Libraries, and Embedded Content: press + to add theNestedmodule - Try to build the project -> succeeds
- In the project file > project > SwiftPM dependencies: add SwiftLint (
https://github.com/realm/SwiftLint.gittargeting themainbranch) without ticking any boxes when being asked if it should be included in the app - In the project file > target > build phases tab >
Run Build Tool Plug-ins: press + to add the SwiftLint plug-in - Try to build the project -> fails with error
ld: entry point (_main) undefined. for architecture arm64
Environment
-
SwiftLint version (run
swiftlint versionto be sure)?mainbranch (which currently uses a prebuilt binary of0.50.1under the hood)
-
Installation method used (Homebrew, CocoaPods, building from source, etc)?
- SwiftPM
-
Paste your configuration file:
- Default
-
Are you using nested configurations?
- No
-
Which Xcode version are you using (check
xcodebuild -version)?- 14.1
-
Do you have a sample that shows the issue?
- Reproducible with the steps above