Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcodebuild -create-framework error: unable to read the file

I have watched "binary framework in swift" and tried to build xcframework using xcodebuild -create-framework but it is not working properly.

I enabled "Build libraries for Distribution", then I archived and then used the command xcodebuild -create-framework -framework /path/sample.xarchive -output sample.xcframework

But it is showing an error "unable to read the file at /path/sample/sample". I am not sure what I am missing.

Sysytem Info:

MacOS: Catalina beta 1

Xcode 11

like image 318
venky Avatar asked Jun 15 '19 11:06

venky


People also ask

Does xcodebuild require Xcode?

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance -rwxr-xr-x 1 root wheel 31488 May 27 19:37 /usr/bin/xcodebuild

How do I export my App from xcodebuild -exportarchive?

We use the xcodebuild -exportArchive command to export our app. This command has code signing issues with Xcode 13, where apparently a communication with Apple failed. The command is executed on macOS 12.0 Beta (21A5304g). By switching to Xcode Version 12.2 (12B45b) using xcode-select, the export works under equal conditions!

Why can’t I use bitcode on Xcode?

The bug was introduced in our project because one of our dependencies is not ready to use bitcode. Disabling bitcode on Xcode was solving the issue, but using the xcodebuild command was not, because we tried using an export options plist file generated by Fastlane, which seems to be defective.

Does Xcode-select change the path to the Xcode app on Mac?

No it does not. When Xcode is installed, setting the xcode-select path to Xcode app gives you more features: in particular xcodebuild which is required for making Xcode projects from cmake etc. The Command Line Tools package installs the macOS system headers inside the macOS SDK.


2 Answers

Here are step by step instructions, I think you might be missing step 2:

1) Set Build Library for Distribution in the build settings for the target framework to YES

2) Again in the build settings, set Skip Install to NO otherwise the framework won't show up in the Archive output folder.

3) Archive from the Xcode Product menu after selecting your Generic iOS Device the output will appear in the Organizer. Control-Click on the Archive. Select Show in Finder Drag that to the terminal to get the path to the archive and append the path (yellow part is the dragged path, gray is navigated in subfolders). In this case it looks like this, I used the ~ to avoid showing entire path.

~/Library/Developer/Xcode/Archives/2019-06-22/Output\ 6-22-19,\ 11.50\ AM.xcarchive/Products/Library/Frameworks/MyFramework.framework

4) Then create the XCFramework by inserting the command in front of the above path:

xcodebuild -create-xcframework -output Output.xcframework -framework ~/Library/Developer/Xcode/Archives/2019-06-22/Output\ 6-22-19,\ 11.50\ AM.xcarchive/Products/Library/Frameworks/MyFramework.framework 

5) You then should see the output:

xcframework successfully written out to: ~/Project/Output.xcframework

I expect that someday soon Xcode will add a the ability to directly create the XCFramework without the command line.

like image 117
possen Avatar answered Oct 22 '22 02:10

possen


You have to do a two step process via the command line.

  1. xcodebuild archive

This will archive the framework and stick it likely in the build directory of your project.

  1. xcodebuild -create-xcframework -output FrameworkName.xcframework -framework build/Release-iphoneos/ArchivedFramework.framework

This should successfully generate the XCFramework.

like image 21
cfihelp Avatar answered Oct 22 '22 00:10

cfihelp