Skip to content

A library with the identifier 'ios-arm64_x86_64-simulator' already exists. #348

@shirakaba

Description

@shirakaba

I'm running the following cmake-rn invocation with cmake-rn@0.6.3:

npx cmake-rn \
  --source ./NativeScript \
  --build /Users/jamie/Documents/git/napi-ios/dist/intermediates \
  --out packages/ios/build/RelWithDebInfo \
  -D TARGET_ENGINE=none \
  --triplet arm64-apple-ios-sim \
  --triplet x86_64-apple-ios-sim \
  --triplet arm64-apple-ios \
  --triplet 'arm64;x86_64-apple-darwin'

It raises the following error:

A library with the identifier 'ios-arm64_x86_64-simulator' already exists.

I notice a relevant guard in react-native-node-api's apple.ts file, but it's not helping:

// Delete any existing xcframework to prevent the error:
// - A library with the identifier 'macos-arm64' already exists.
// Ideally, it would only be necessary to delete the specific platform+arch, to allow selectively building from source.
fs.rmSync(outputPath, { recursive: true, force: true });

For a reproduction, I'll describe how to get set up with https://github.com/NativeScript/napi-ios/tree/jb/cmake-rn. This branch is my very belated (sorry!) effort to review your much-appreciated PR NativeScript/napi-ios#22.

Reproduction steps:

# Clone the repo and check out my branch.
git clone git@github.com:NativeScript/napi-ios.git
git fetch origin
# At the time of filing this issue, I'm working on commit 8332775: "uninstall react-native-node-api from scripts".
git checkout jb/cmake-rn

# Install npm deps.
npm install

# Run the script that ultimately calls cmake-rn.
./build_all_react_native.sh

Running that command produces a lot of build logs, finally ending in this failure log:

--------------------------------------------------------------------------------
--- 08:01:37 --- Building NativeScript prebuilt for React Native Node-API (NativeScript.apple.node) 
--------------------------------------------------------------------------------

✔ Configured projects (apple: arm64-apple-ios-sim, x86_64-apple-ios-sim, arm64-apple-ios, arm64;x86_64-apple-darwin)
✔ Built projects
✖ Failed to assemble XCFramework (NativeScript): Running 'xcodebuild' failed (code = 70)
A library with the identifier 'ios-arm64_x86_64-simulator' already exists.

Looking into it, the failing command itself was:

xcodebuild \
  -create-xcframework \
  -framework \
  /Users/jamie/Documents/git/napi-ios/dist/intermediates/arm64-apple-ios-sim/out/Release/NativeScript.framework \
  -framework \
  /Users/jamie/Documents/git/napi-ios/dist/intermediates/x86_64-apple-ios-sim/out/Release/NativeScript.framework \
  -framework \
  /Users/jamie/Documents/git/napi-ios/dist/intermediates/arm64-apple-ios/out/Release/NativeScript.framework \
  -framework \
  /Users/jamie/Documents/git/napi-ios/dist/intermediates/arm64_x86_64-apple-darwin/out/Release/NativeScript.framework \
  -output \
  /Users/jamie/Documents/git/napi-ios/packages/ios/build/RelWithDebInfo/NativeScript.apple.node.xcframework

And here's all the local state just before it ran it. We can see it deleted /Users/jamie/Documents/git/napi-ios/packages/ios/build/RelWithDebInfo/NativeScript.apple.node.xcframework before attempting the command, but to no avail.

Image

And just before this command was run, the state of the repo was as follows:

.
├── dist
│   └── intermediates
│       ├── arm64-apple-ios
│       │   ├── CMakeCache.txt
│       │   ├── CMakeFiles
│       │   ├── CMakeScripts
│       │   ├── NativeScript.xcodeproj
│       │   ├── build
│       │   ├── cmake_install.cmake
│       │   └── out
│       ├── arm64-apple-ios-sim
│       │   ├── CMakeCache.txt
│       │   ├── CMakeFiles
│       │   ├── CMakeScripts
│       │   ├── NativeScript.xcodeproj
│       │   ├── build
│       │   ├── cmake_install.cmake
│       │   └── out
│       ├── arm64_x86_64-apple-darwin
│       │   ├── CMakeCache.txt
│       │   ├── CMakeFiles
│       │   ├── CMakeScripts
│       │   ├── NativeScript.xcodeproj
│       │   ├── build
│       │   ├── cmake_install.cmake
│       │   └── out
│       └── x86_64-apple-ios-sim
│           ├── CMakeCache.txt
│           ├── CMakeFiles
│           ├── CMakeScripts
│           ├── NativeScript.xcodeproj
│           ├── build
│           ├── cmake_install.cmake
│           └── out
├── metadata-generator
│   ├── dist
│   │   ├── arm64
│   │   │   └── bin
│   │   └── x86_64
│   │       └── bin
│   └── metadata
│       ├── metadata.ios-sim.arm64.h
│       ├── metadata.ios-sim.arm64.nsmd
│       ├── metadata.ios-sim.x86_64.h
│       ├── metadata.ios-sim.x86_64.nsmd
│       ├── metadata.ios.arm64.h
│       ├── metadata.ios.arm64.nsmd
│       ├── metadata.macos.arm64.h
│       ├── metadata.macos.arm64.nsmd
│       ├── metadata.macos.x86_64.h
│       ├── metadata.macos.x86_64.nsmd
│       ├── metadata.visionos-sim.arm64.nsmd
│       ├── metadata.visionos.arm64.nsmd
│       └── metadata.visionos.x86_64.nsmd
└── packages
    ├── ios
    │   └── build
    │       └── RelWithDebInfo # Currently empty
    ├── ios-sim                # Irrelevant (types-only)
    ├── macos
    │   ├── LICENSE
    │   ├── README.md
    │   ├── build
    │   │   └── RelWithDebInfo # Currently empty
    ├── objc                   # Irrelevant (uninvolved)
    ├── visionos               # Irrelevant (excluded)
    └── visionos-sim           # Irrelevant (types-only)

So there's no occurrence of ios-arm64_x86_64-simulator anywhere in the file tree. I'm wondering whether xcodebuild is actually generating it mid-run and tripping over its own output?

Metadata

Metadata

Assignees

Labels

CMake RNOur `cmake` wrapping CLIenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions